/* Kỷ yếu 30 năm THPT Long Hải – Phước Tỉnh — giao diện */

:root {
  --bg1: #b9dcf3;               /* viền ngoài */
  --bg2: #eaf6fe;               /* tâm sáng */
  --bar: rgba(255, 255, 255, .72);
  --line: rgba(13, 60, 110, .14);
  --fg: #143b66;
  --muted: #3f6a99;
  --accent: #0d3c6e;            /* tiêu đề */
  --accent2: #1f7ad0;           /* slider, viền focus */
  --ov-fg: #e8f0fa;             /* chữ trên nền tối (zoom, lưới) */
  --ov-muted: #9db3cc;

  /* Material You (M3) – tông xanh dương */
  --m-primary: #1a5fa8;
  --m-on-primary: #ffffff;
  --m-primary-container: #d3e4ff;
  --m-on-primary-container: #001c39;
  --m-surface: #fbfcff;
  --m-surface-container: #e4edf8;
  --m-surface-container-high: #d9e5f2;
  --m-on-surface: #172b44;
  --m-on-surface-variant: #44607f;
  --m-outline-variant: #bfd0e2;
  --m-state-hover: rgba(26, 95, 168, .08);
  --m-state-press: rgba(26, 95, 168, .14);
  --m-radius: 32px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background: radial-gradient(ellipse at 50% 35%, var(--bg2), var(--bg1) 75%);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  display: flex;
  flex-direction: column;
}

header {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 10px 12px 4px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  line-height: 1.15;
}

header b {
  font-family: 'Dancing Script', 'Brush Script MT', 'Segoe Script', cursive;
  font-size: 30px;
  line-height: 1.1;
  color: var(--accent);
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .8);
}

header span {
  font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: .4px;
  color: var(--m-primary);
}

header em {
  font-style: normal;
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 400;
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--m-on-surface-variant);
  opacity: .8;
}

#stage {
  flex: 1;
  min-height: 0;
  position: relative;
  padding: 8px 14px;
}

#book {
  width: 100%;
  height: 100%;
}

.page {
  background: #fff;
  overflow: hidden;
  box-shadow: 0 0 6px rgba(0, 0, 0, .25);
}

/* mặt sau tờ đang lật (mobile): giấy trắng */
.page.page-back {
  background: #fff;
}

.page.page-back img {
  visibility: hidden;
}

.page img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  background: #fff center / 100% 100% no-repeat;
}

.page.-hard {
  background: #f7f3e8;
}

.stf__parent {
  margin: 0 auto;
}


#hint {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  background: #2b3d55;
  color: #eef3fa;
  font-size: 12px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 8px;
  pointer-events: none;
  transition: opacity .6s;
  white-space: nowrap;
}

/* ---------- Nút nhạc nền (góc trên phải) ---------- */
#b-music {
  position: fixed;
  top: 10px;
  right: 12px;
  z-index: 20;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--m-primary-container);
  color: var(--m-on-primary-container);
  box-shadow: 0 1px 2px rgba(23, 43, 68, .10), 0 4px 12px rgba(23, 43, 68, .14);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color .15s, transform .1s, box-shadow .15s;
}

#b-music[hidden] {
  display: none;
}

#b-music:hover {
  background: #c2d9fb;
}

#b-music:active {
  transform: scale(.94);
}

#b-music:focus-visible {
  outline: 2px solid var(--m-primary);
  outline-offset: 2px;
}

#b-music svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#b-music .off-ic,
#b-music.off .on-ic,
#b-music:not(.playing) .eq {
  display: none;
}

#b-music.off .off-ic {
  display: block;
}

#b-music.off {
  background: var(--m-surface-container);
  color: var(--m-on-surface-variant);
}

/* 3 vạch nhảy nhỏ ở góc nút khi đang phát */
#b-music .eq {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--m-primary);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 1.5px;
  padding-bottom: 4px;
}

#b-music .eq i {
  width: 2px;
  height: 4px;
  background: #fff;
  border-radius: 1px;
  animation: eq .9s ease-in-out infinite;
}

#b-music .eq i:nth-child(2) {
  animation-delay: .3s;
}

#b-music .eq i:nth-child(3) {
  animation-delay: .6s;
}

@keyframes eq {

  0%,
  100% {
    height: 3px;
  }

  50% {
    height: 8px;
  }
}

/* ---------- Thanh điều khiển (Material You) ---------- */
#bar-wrap {
  flex: none;
  padding: 4px 14px calc(10px + env(safe-area-inset-bottom));
}

#bar {
  height: 54px;
  max-width: 1100px;
  margin: 0 auto;
  border-radius: var(--m-radius);
  background: var(--m-surface-container);
  box-shadow: 0 1px 2px rgba(23, 43, 68, .10), 0 6px 18px rgba(23, 43, 68, .12);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px;
}

#bar button,
#bar a,
#ov button,
#grid-close {
  position: relative;
  text-decoration: none;
  background: none;
  border: 0;
  color: var(--m-on-surface-variant);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
  transition: background-color .15s, color .15s, transform .1s;
}

#bar button:hover,
#bar a:hover {
  background: var(--m-state-hover);
  color: var(--m-primary);
}

#bar button:active,
#bar a:active {
  background: var(--m-state-press);
  transform: scale(.94);
}

#bar button:focus-visible,
#bar a:focus-visible {
  outline: 2px solid var(--m-primary);
  outline-offset: 2px;
}

/* nút tonal (lật trang) */
#bar button.tonal {
  background: var(--m-primary-container);
  color: var(--m-on-primary-container);
  width: 42px;
  height: 42px;
}

#bar button.tonal:hover {
  background: #c2d9fb;
  color: var(--m-on-primary-container);
}

#bar button.tonal:active {
  background: #b3cef5;
}

/* nút tải PDF + menu 2 dòng (M3 menu) */
#dl {
  position: relative;
  flex: none;
  margin-left: 2px;
}

#dl[hidden] {
  display: none;
}

#dl-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  min-width: 230px;
  padding: 6px;
  border-radius: 16px;
  background: var(--m-surface);
  box-shadow: 0 2px 6px rgba(23, 43, 68, .14), 0 10px 28px rgba(23, 43, 68, .18);
  opacity: 0;
  transform: translateY(6px) scale(.96);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity .15s, transform .15s;
  z-index: 30;
}

#dl-menu.on {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

#bar #dl-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: auto;
  padding: 8px 14px 8px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--m-on-surface);
  justify-content: flex-start;
}

#bar #dl-menu a:hover {
  background: var(--m-state-hover);
  color: var(--m-on-surface);
}

#dl-menu a svg {
  flex: none;
  color: var(--m-primary);
}

#dl-menu a span {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  white-space: nowrap;
}

#dl-menu a b {
  font-size: 14px;
  font-weight: 600;
}

#dl-menu a small {
  font-size: 11.5px;
  color: var(--m-on-surface-variant);
}

#bar button:disabled {
  opacity: .38;
  cursor: default;
  transform: none;
  background: none;
  color: var(--m-on-surface-variant);
}

#bar button.tonal:disabled {
  background: var(--m-primary-container);
  color: var(--m-on-primary-container);
}

#ov button,
#grid-close {
  color: var(--ov-fg);
}

#ov button:hover,
#grid-close:hover {
  background: rgba(255, 255, 255, .12);
}

#bar svg,
#ov svg,
#grid-close svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ô số trang: chip */
#pg {
  display: flex;
  align-items: center;
  height: 34px;
  padding: 0 10px 0 4px;
  margin: 0 4px;
  border-radius: 17px;
  background: var(--m-surface);
  border: 1px solid var(--m-outline-variant);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 500;
  color: var(--m-on-surface-variant);
  flex: none;
  transition: border-color .15s, box-shadow .15s;
}

#pg:focus-within {
  border-color: var(--m-primary);
  box-shadow: 0 0 0 1px var(--m-primary);
}

#pg input {
  width: 50px;
  height: 30px;
  text-align: center;
  background: transparent;
  color: var(--m-on-surface);
  border: 0;
  border-radius: 18px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
}

#pg input:focus {
  outline: none;
}

/* thanh trượt kiểu M3 */
#slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  min-width: 48px;
  height: 38px;
  margin: 0 10px;
  background: transparent;
  cursor: pointer;
  --p: 0%;
}

#slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, var(--m-primary) var(--p), var(--m-primary-container) var(--p));
}

#slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 5px;
  height: 22px;
  border-radius: 3px;
  background: var(--m-primary);
  margin-top: -7px;
  box-shadow: 0 0 0 4px var(--m-surface-container);
  transition: transform .1s;
}

#slider:active::-webkit-slider-thumb {
  transform: scaleX(.6);
}

#slider::-moz-range-track {
  height: 8px;
  border-radius: 4px;
  background: var(--m-primary-container);
}

#slider::-moz-range-progress {
  height: 8px;
  border-radius: 4px;
  background: var(--m-primary);
}

#slider::-moz-range-thumb {
  width: 5px;
  height: 22px;
  border: 0;
  border-radius: 3px;
  background: var(--m-primary);
  box-shadow: 0 0 0 4px var(--m-surface-container);
}

#slider:focus-visible {
  outline: none;
}

.sep {
  width: 1px;
  height: 24px;
  background: var(--m-outline-variant);
  margin: 0 4px;
  flex: none;
}

@media (max-width: 560px) {
  .hide-sm {
    display: none !important;
  }

  header {
    gap: 0;
    padding: 8px 12px 2px;
  }

  header b {
    font-size: 24px;
  }

  header span {
    font-size: 12px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  header em {
    font-size: 11px;
  }

  #stage {
    padding: 6px;
  }

  #b-music {
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
  }

  #b-music svg {
    width: 20px;
    height: 20px;
  }

  #bar-wrap {
    padding: 4px 8px calc(8px + env(safe-area-inset-bottom));
  }

  #bar {
    height: 50px;
    padding: 0 8px;
    gap: 2px;
  }

  #bar button,
  #bar a {
    width: 36px;
    height: 36px;
  }

  #bar button.tonal {
    width: 40px;
    height: 40px;
  }

  #pg {
    height: 32px;
  }

  #pg {
    padding: 0 8px 0 2px;
    margin: 0 2px;
  }

  #pg input {
    width: 44px;
  }

  #slider {
    margin: 0 4px;
    min-width: 36px;
  }

  .sep {
    display: none;
  }
}

/* điện thoại nhỏ (≤ 400px): co gọn thêm để đủ chỗ cho nút tải PDF */
@media (max-width: 400px) {
  #bar {
    padding: 0 6px;
    gap: 0;
  }

  #bar button,
  #bar a {
    width: 32px;
    height: 32px;
  }

  #bar button.tonal {
    width: 36px;
    height: 36px;
  }

  #dl {
    margin-left: 0;
  }

  #bar svg {
    width: 20px;
    height: 20px;
  }

  #pg {
    padding: 0 6px 0 0;
    margin: 0 2px;
    font-size: 13px;
  }

  #pg input {
    width: 38px;
    font-size: 14px;
  }

  #slider {
    margin: 0 2px;
    min-width: 28px;
  }

  #hint {
    white-space: normal;
    text-align: center;
    max-width: calc(100% - 24px);
    font-size: 11px;
  }
}

/* ---------- Zoom overlay ---------- */
#ov {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 22, .96);
  color: var(--ov-fg);
  z-index: 50;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

#ov.on {
  opacity: 1;
  pointer-events: auto;
}

#ov-top {
  flex: none;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
}

#ov-top span {
  flex: 1;
  text-align: center;
  font-size: 14px;
  color: var(--ov-muted);
}

#ov-view {
  flex: 1;
  position: relative;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

#ov-view.drag {
  cursor: grabbing;
}

#ov-img {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  max-width: none;
  background: #fff;
}

#ov-nav button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 64px;
  background: rgba(0, 0, 0, .4);
  border-radius: 12px;
}

#ov-prev {
  left: 8px;
}

#ov-next {
  right: 8px;
}

#ov-load {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 13px;
  color: var(--ov-muted);
  background: rgba(0, 0, 0, .5);
  padding: 6px 12px;
  border-radius: 8px;
  pointer-events: none;
}

#ov-load[hidden] {
  display: none;
}

/* ---------- Lưới trang ---------- */
#grid {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 22, .96);
  color: var(--ov-fg);
  z-index: 40;
  display: none;
  flex-direction: column;
}

#grid.on {
  display: flex;
}

#grid-head {
  flex: none;
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 8px 0 16px;
  font-size: 15px;
}

#grid-head span {
  flex: 1;
}

#grid-body {
  flex: 1;
  overflow-y: auto;
  touch-action: pan-y;
  padding: 8px 12px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}

.th {
  cursor: pointer;
  text-align: center;
  font-size: 12px;
  color: var(--ov-muted);
}

.th img {
  width: 100%;
  aspect-ratio: var(--ratio, .707);
  object-fit: cover;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
  display: block;
  margin-bottom: 4px;
}

.th.cur img {
  outline: 3px solid #f4c860;
}

.th:hover img {
  transform: scale(1.03);
}

/* ---------- Splash ---------- */
#splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  transition: opacity .4s;
  color: var(--muted);
  font-size: 14px;
}

#splash.off {
  opacity: 0;
  pointer-events: none;
}

.spin {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(13, 60, 110, .15);
  border-top-color: var(--accent2);
  border-radius: 50%;
  animation: sp .8s linear infinite;
}

@keyframes sp {
  to {
    transform: rotate(360deg);
  }
}
