/* ==========================================================
   Album gia đình — giao diện dạng sách lật trang
   Đổi màu / font ở phần :root bên dưới
   ========================================================== */

:root {
  --bg: #f8f3ea;
  --paper: #fffdf8;
  --ink: #2d2520;
  --ink-soft: #5b4f46;
  --muted: #8b7e72;
  --line: #e5d8c5;
  --accent: #b9573a;
  --accent-ink: #fff;
  --shadow: 0 1px 2px rgb(70 45 25 / .05), 0 6px 20px rgb(70 45 25 / .07);
  --shadow-lg: 0 2px 4px rgb(70 45 25 / .06), 0 18px 40px rgb(70 45 25 / .14);
  --radius: 16px;
  --bar-h: 64px;
  --font-display: "Playfair Display", Georgia, "Times New Roman", serif;
  --font-body: "Quicksand", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-hand: "Great Vibes", "Brush Script MT", cursive;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1613;
    --paper: #241e1a;
    --ink: #f3eadf;
    --ink-soft: #cfc1b1;
    --muted: #9d8f81;
    --line: #3b322b;
    --accent: #e3875f;
    --accent-ink: #1a1613;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 20px rgb(0 0 0 / .25);
    --shadow-lg: 0 2px 4px rgb(0 0 0 / .3), 0 18px 40px rgb(0 0 0 / .45);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* Số thẳng hàng, cao đều như chữ (Playfair mặc định dùng số kiểu cổ, cao thấp lệch nhau).
   Cần !important vì các khai báo `font:` rút gọn sẽ đặt lại thuộc tính này. */
*, *::before, *::after { font-variant-numeric: lining-nums !important; }
body {
  margin: 0;
  padding-top: var(--bar-h);
  background: var(--bg);
  color: var(--ink);
  font: 500 15px/1.7 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
body:has(.lightbox[open]) { overflow: hidden; }
img { display: block; max-width: 100%; }
button, select { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
[tabindex="-1"]:focus { outline: none; }

/* ---------- Thanh trên cùng ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40; height: var(--bar-h);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.topbar-inner { display: flex; align-items: center; gap: 20px; max-width: 1240px; height: 100%; margin-inline: auto; padding-inline: 24px; }
.brand { display: inline-flex; flex-shrink: 0; align-items: center; gap: 10px; font: 700 21px/1 var(--font-display); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); }
.page-nav { position: relative; display: flex; flex: 1; gap: 2px; min-width: 0; padding-inline: 6px; overflow-x: auto; scrollbar-width: none; }
.page-nav::-webkit-scrollbar { display: none; }
.page-nav > :first-child { margin-left: auto; }
.page-nav > :last-child { margin-right: auto; }
.page-nav a {
  flex-shrink: 0; padding: 4px 13px; border-radius: 999px;
  font: 500 15px/1.4 var(--font-display); color: var(--muted); text-decoration: none;
  transition: background .25s, color .25s;
}
.page-nav a:hover { color: var(--ink); }
.page-nav a.is-active { background: var(--accent); color: var(--accent-ink); }

/* ---------- Sân khấu & trang ---------- */
.stage { position: relative; perspective: 2400px; overflow-x: clip; }
.page {
  min-height: calc(100vh - var(--bar-h));
  min-height: calc(100dvh - var(--bar-h));
  padding: 24px max(24px, calc((100% - 1120px) / 2)) 140px;
  background: var(--bg);
}

/* Nền riêng của trang (Admin → Giao diện → Nền từng trang) */
.page.has-bg { position: relative; background: var(--page-bg, var(--bg)); }
.page.has-bg > :not(.page-bg) { position: relative; }
.page-bg { position: absolute; inset: 0; z-index: 0; overflow: clip; pointer-events: none; }
/* Ảnh luôn phủ vừa khung nhìn và đứng yên khi cuộn; lớp màu nền phủ lên để chữ dễ đọc */
.page-bg-img {
  position: sticky; top: var(--bar-h); height: calc(100dvh - var(--bar-h));
  background-position: center; background-size: cover;
}
.page-cover.has-bg::before, .page-cover.has-bg::after { z-index: 1; }
/* Chữ nằm thẳng trên ảnh nền: thêm quầng màu nền quanh chữ để luôn đọc được, kể cả khi độ mờ thấp */
.has-bg-img :is(.year-head, .page-head, .cover-text, .person-filter, .chapter-end > :not(.next-chapter)) {
  text-shadow: 0 0 2px var(--bg), 0 0 12px var(--bg), 0 0 26px var(--bg);
}
.page-bg-img::after { content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--bg) var(--page-bg-dim, 60%), transparent); }

.kicker { margin: 0 0 6px; font: 400 36px/1.2 var(--font-hand); color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; gap: 10px; padding: 12px 22px;
  border: 1px solid var(--ink); border-radius: 999px; background: var(--ink); color: var(--bg);
  font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background .2s, color .2s, border-color .2s, translate .2s;
}
.btn:hover { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); translate: 0 -1px; }
.btn-ghost { border-color: var(--line); background: var(--paper); color: var(--ink); }
.link-btn {
  margin-top: auto; padding: 14px 0 0; border: 0; background: none;
  color: var(--accent); font-size: 14px; font-weight: 600; cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- Trang bìa ---------- */
.page-cover {
  position: relative; display: flex; flex-direction: column; justify-content: center; overflow-x: clip;
  /* chữ luôn cách khung viền (inset 20–28px) ít nhất ~40px */
  padding-inline: max(72px, calc((100% - 1120px) / 2));
  padding-top: 72px;
}
.page-cover::before {
  content: ""; position: absolute; inset: 20px; pointer-events: none;
  border: 1px solid var(--line); border-radius: 28px;
}
.page-cover::after {
  content: ""; position: absolute; inset: 28px; pointer-events: none;
  border: 1px solid color-mix(in srgb, var(--line) 55%, transparent); border-radius: 22px;
}
.cover-grid { position: relative; z-index: 1; display: grid; grid-template-columns: 1.1fr 1fr; gap: 56px; align-items: center; }
.cover-title { margin: 0 0 22px; font: 600 clamp(42px, 5.4vw, 70px)/1.05 var(--font-display); letter-spacing: -0.01em; }
.cover-title em { display: block; font-weight: 500; font-style: italic; color: var(--accent); }
.cover-lead { max-width: 44ch; margin: 0 0 30px; font-size: 16px; font-weight: 500; color: var(--ink-soft); }
.stats { display: flex; flex-wrap: wrap; gap: 16px 34px; margin: 0 0 32px; padding: 0; list-style: none; }
.stat strong { display: block; font: 600 28px/1.15 var(--font-display); }
.stat span { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.cover-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 32px; }
.cover-foot { position: relative; z-index: 1; margin: 48px 0 0; font: italic 400 17px/1.4 var(--font-display); color: var(--muted); text-align: center; }

.collage { position: relative; height: 480px; }
.polaroid {
  position: absolute; width: 56%; padding: 12px 12px 48px; border: 0; border-radius: 3px;
  background: #fffefb; box-shadow: var(--shadow-lg); cursor: pointer;
  transition: transform .35s ease, rotate .35s ease;
}
.polaroid img { width: 100%; aspect-ratio: 1; object-fit: cover; background: #e9e1d6; }
.polaroid span {
  position: absolute; left: 10px; right: 10px; bottom: 11px;
  font: 400 25px/1.2 var(--font-hand); color: #3b302a; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.polaroid:nth-child(1) { top: 0; left: 0; rotate: -6deg; z-index: 1; }
.polaroid:nth-child(2) { top: 36px; right: 0; rotate: 5deg; z-index: 2; }
.polaroid:nth-child(3) { bottom: 0; left: 24%; rotate: -1.5deg; z-index: 3; }
.polaroid:hover, .polaroid:focus-visible { transform: scale(1.04); rotate: 0deg; z-index: 5; }

.otd { display: grid; gap: 10px; max-width: 460px; }
.otd-label { margin: 0; font: 400 29px/1.2 var(--font-hand); color: var(--accent); }
.otd-card {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper);
  box-shadow: var(--shadow); text-align: left; cursor: pointer;
  transition: translate .2s, box-shadow .2s;
}
.otd-card:hover { translate: 0 -2px; box-shadow: var(--shadow-lg); }
.otd-card img { flex-shrink: 0; width: 68px; height: 68px; border-radius: 10px; object-fit: cover; background: var(--line); }
.otd-text { flex: 1; min-width: 0; }
.otd-when { display: block; font-size: 12px; color: var(--muted); }
.otd-text strong { display: block; font: 600 18px/1.3 var(--font-display); }
.otd-arrow { padding-right: 6px; font-size: 20px; color: var(--accent); }

/* ---------- Trang gia đình ---------- */
.page-head { margin-bottom: 44px; text-align: center; }
.page-title { margin: 0; font: 600 clamp(38px, 5vw, 60px)/1.1 var(--font-display); letter-spacing: -0.01em; }
.member-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 18px; margin: 0; padding: 0; list-style: none; }
.member {
  display: flex; flex-direction: column; align-items: center; padding: 30px 18px 22px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper);
  box-shadow: var(--shadow); text-align: center;
}
.avatar {
  display: grid; place-items: center; width: 84px; height: 84px; margin-bottom: 14px;
  border-radius: 50%; overflow: hidden; background: var(--mc); color: #fff;
  font: 600 32px/1 var(--font-display);
  box-shadow: 0 0 0 4px var(--paper), 0 0 0 6px var(--mc);
}
.avatar img, .mini-avatar img { width: 100%; height: 100%; object-fit: cover; }
.member-name { margin: 0; font: 600 23px/1.2 var(--font-display); }
.member-role { margin: 2px 0 12px; font-size: 14px; color: var(--muted); }
.member-age { margin: 0; font-weight: 600; }
.member-bday { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.member-bday.is-soon { color: var(--accent); font-weight: 600; }
.member-bio { margin: 12px 0 0; font-size: 13px; line-height: 1.5; color: var(--ink-soft); }

/* Cuối trang: thẻ "chương tiếp theo" */
.chapter-end { display: grid; justify-items: center; gap: 26px; margin-top: 80px; text-align: center; }
.ornament { display: flex; align-items: center; gap: 14px; font-size: 18px; color: var(--accent); }
.ornament span { width: 90px; height: 1px; background: linear-gradient(to right, transparent, var(--line)); }
.ornament span:last-child { background: linear-gradient(to left, transparent, var(--line)); }

.next-chapter {
  --flap: color-mix(in srgb, var(--line) 70%, var(--paper));
  position: relative; display: flex; align-items: center; gap: 26px;
  width: min(540px, 100%); padding: 20px 24px 20px 22px; overflow: hidden;
  border: 1px solid var(--line); border-radius: 18px; background: var(--paper);
  box-shadow: var(--shadow); text-align: left; cursor: pointer;
  transition: translate .35s ease, box-shadow .35s ease, border-color .35s ease;
}
.next-chapter:hover, .next-chapter:focus-visible {
  translate: 0 -4px; box-shadow: var(--shadow-lg);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
/* Góc trang gấp lại khi rê chuột, như sắp lật */
.next-chapter::after {
  content: ""; position: absolute; right: 0; bottom: 0; width: 0; height: 0;
  background: linear-gradient(135deg, var(--flap) 50%, var(--bg) 50%);
  border-top-left-radius: 6px; box-shadow: -3px -3px 8px rgb(30 18 10 / .12);
  transition: width .35s ease, height .35s ease;
}
.next-chapter:hover::after, .next-chapter:focus-visible::after { width: 36px; height: 36px; }

.nc-photos { position: relative; flex-shrink: 0; width: 108px; height: 92px; }
.nc-photos img {
  position: absolute; top: 10px; width: 70px; height: 70px; object-fit: cover;
  border: 4px solid #fffefb; border-radius: 3px; box-shadow: 0 4px 12px rgb(0 0 0 / .22);
  transition: rotate .45s ease, translate .45s ease;
}
.nc-photos img:nth-child(1) { left: 0; rotate: -9deg; }
.nc-photos img:nth-child(2) { left: 19px; top: 2px; rotate: 2deg; z-index: 1; }
.nc-photos img:nth-child(3) { left: 36px; top: 12px; rotate: 11deg; z-index: 2; }
.next-chapter:hover .nc-photos img:nth-child(1) { translate: -6px 2px; rotate: -14deg; }
.next-chapter:hover .nc-photos img:nth-child(2) { translate: 0 -4px; }
.next-chapter:hover .nc-photos img:nth-child(3) { translate: 8px 2px; rotate: 16deg; }

.nc-text { display: grid; flex: 1; min-width: 0; }
.nc-label { font-size: 11px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.nc-year { font: 600 40px/1.15 var(--font-display); }
.nc-note { font: 400 26px/1.2 var(--font-hand); color: var(--accent); }
.nc-arrow {
  display: grid; flex-shrink: 0; place-items: center; width: 46px; height: 46px;
  border: 1px solid var(--line); border-radius: 50%; color: var(--accent);
  transition: background .3s, color .3s, border-color .3s, translate .3s;
}
.next-chapter:hover .nc-arrow { translate: 4px 0; border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }

.text-link {
  padding: 4px 2px; border: 0; background: linear-gradient(currentColor, currentColor) no-repeat 0 100% / 0 1px;
  color: var(--accent); font-size: 14px; font-weight: 600; letter-spacing: .02em; cursor: pointer;
  transition: background-size .35s ease;
}
.text-link:hover, .text-link:focus-visible { background-size: 100% 1px; }
.the-end { margin: 0; font: 400 34px/1.3 var(--font-hand); color: var(--accent); }

/* ---------- Trang theo năm ---------- */
.year-head { margin-bottom: 18px; text-align: center; }
.chapter { margin: 0 0 4px; font-size: 12px; font-weight: 600; letter-spacing: .28em; text-transform: uppercase; color: var(--muted); }
.year-num { margin: 0; font: 600 clamp(44px, 5.5vw, 68px)/1 var(--font-display); letter-spacing: -0.01em; }
.year-num-sm { font-size: clamp(34px, 4.5vw, 52px); }
.year-note { margin: 2px 0 0; font: 400 28px/1.25 var(--font-hand); color: var(--accent); }

.filters { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 20px; margin-bottom: 8px; }
.chip-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--paper);
  font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background .2s, border-color .2s, color .2s;
}
.chip:hover { border-color: var(--muted); }
.chip .swatch { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.chip .count { font-size: 12px; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip[aria-pressed="true"] .count { color: inherit; opacity: .65; }
.person-filter { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.person-filter select {
  padding: 6px 34px 6px 13px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%238b7e72' stroke-width='1.6' stroke-linecap='round' d='m3 4.5 3 3 3-3'/%3E%3C/svg%3E") no-repeat right 12px center / 12px;
  appearance: none; color: var(--ink); font-size: 13px; font-weight: 500; cursor: pointer;
}
.filter-status { margin: 10px 0 0; font-size: 14px; color: var(--muted); text-align: center; }
.filter-status .link-btn { margin: 0 0 0 6px; padding: 0; }
.empty { margin: 48px 0 0; color: var(--muted); text-align: center; }

/* Dòng thời gian trong trang (mobile trước, desktop ở dưới) */
.timeline { position: relative; margin-top: 36px; }
.timeline-line { position: absolute; top: 0; bottom: 0; left: 16px; width: 2px; margin-left: -1px; border-radius: 2px; background: var(--line); }
.moments { display: flex; flex-direction: column; gap: 24px; margin: 0; padding: 0; list-style: none; }
.moment { position: relative; margin-left: 40px; scroll-margin-top: calc(var(--bar-h) + 20px); }
.moment-dot {
  position: absolute; top: 26px; left: -32px; z-index: 2; width: 16px; height: 16px;
  border: 3px solid var(--bg); border-radius: 50%; background: var(--cat);
  box-shadow: 0 0 0 2px var(--cat);
}

.card {
  overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); box-shadow: var(--shadow); transition: box-shadow .25s;
}
.card:hover { box-shadow: var(--shadow-lg); }
.card-body { padding: 22px 26px 24px; }
.ribbon { margin: 0 0 4px; font: 400 25px/1.2 var(--font-hand); color: var(--cat); }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.badge {
  padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: color-mix(in srgb, var(--cat) 14%, transparent);
  color: color-mix(in srgb, var(--cat) 72%, var(--ink));
}
.card-title { margin: 0 0 8px; font: 600 23px/1.25 var(--font-display); }
.card-place { display: flex; align-items: center; gap: 5px; margin: 0 0 10px; font-size: 13px; color: var(--ink-soft); }
.card-place svg { flex-shrink: 0; color: var(--cat); }
.card-story p { margin: 0 0 10px; color: var(--ink-soft); }
.card-story p:last-child { margin-bottom: 0; }
.card-people { display: flex; align-items: center; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.people-stack { display: flex; }
.mini-avatar {
  display: grid; place-items: center; width: 28px; height: 28px; overflow: hidden;
  border: 2px solid var(--paper); border-radius: 50%; background: var(--mc); color: #fff;
  font: 600 12px/1 var(--font-body);
}
.mini-avatar + .mini-avatar { margin-left: -8px; }
.people-names { font-size: 13px; color: var(--muted); }
.card-video { margin-top: 14px; overflow: hidden; border-radius: 10px; aspect-ratio: 16 / 9; background: #000; }
.card-video iframe, .card-video video { display: block; width: 100%; height: 100%; border: 0; }

/* Ảnh trong thẻ */
.media { display: grid; gap: 3px; background: var(--paper); }
.media-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.media-3 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); grid-template-rows: repeat(2, minmax(0, 1fr)); aspect-ratio: 3 / 2; }
.media-3 .ph:first-child { grid-row: span 2; }
.ph {
  position: relative; display: block; width: 100%; height: 100%; min-height: 0;
  padding: 0; border: 0; overflow: hidden; background: var(--line); cursor: zoom-in;
}
.media-1 .ph { aspect-ratio: 16 / 10; }
.media-2 .ph { aspect-ratio: 1; }
.ph img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s ease; }
.ph:hover img { transform: scale(1.04); }
.ph-more {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgb(25 18 14 / .55); color: #fff; font: 600 22px/1 var(--font-body);
}

/* Hiệu ứng hiện dần khi cuộn tới */
.moment { opacity: 0; translate: 0 20px; transition: opacity .7s ease, translate .7s ease; }
.moment.is-visible { opacity: 1; translate: 0 0; }
.moment.flash .card { animation: flash 1.8s ease .5s; }
@keyframes flash {
  0%, 100% { box-shadow: var(--shadow); }
  25%, 60% { box-shadow: 0 0 0 3px var(--cat), var(--shadow-lg); }
}

@media (min-width: 900px) {
  .timeline { --gap: 44px; }
  .timeline-line { left: 50%; }
  .moments { gap: 32px; }
  .moment { width: calc(50% - var(--gap)); margin-left: 0; }
  .moment.side-left { align-self: flex-start; }
  .moment.side-right { align-self: flex-end; }
  .moment.stagger { margin-top: -96px; }
  .moment.is-featured { align-self: center; width: min(860px, 100%); margin-block: 16px; }
  .moment.is-featured:first-child { margin-top: 8px; }

  .moment-dot { top: 30px; }
  .side-left .moment-dot { left: auto; right: calc(-1 * var(--gap) - 8px); }
  .side-right .moment-dot { left: calc(-1 * var(--gap) - 8px); }
  .is-featured .moment-dot { top: -8px; left: 50%; margin-left: -8px; }
  .side-left::before, .side-right::before {
    content: ""; position: absolute; top: 37px; width: calc(var(--gap) - 12px); height: 2px; background: var(--line);
  }
  .side-left::before { right: calc(12px - var(--gap)); }
  .side-right::before { left: calc(12px - var(--gap)); }

  .is-featured .card { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
  .is-featured .media { aspect-ratio: auto; min-height: 340px; }
  .is-featured .media .ph { aspect-ratio: auto; }
  .is-featured .media-1, .is-featured .media-2 { grid-template-rows: minmax(0, 1fr); }
  .is-featured .card-body { align-self: center; padding: 30px 32px; }
  .is-featured .card-title { font-size: 31px; }
}

/* ---------- Hiệu ứng lật trang ---------- */
.page-out {
  position: absolute; left: 0; right: 0; z-index: 10;
  pointer-events: none; backface-visibility: hidden; will-change: transform;
}
.page-out.to-left { transform-origin: left center; animation: flip-out-left .85s cubic-bezier(.45, .05, .3, 1) forwards; }
.page-out.to-right { transform-origin: right center; animation: flip-out-right .85s cubic-bezier(.45, .05, .3, 1) forwards; }
@keyframes flip-out-left {
  0% { transform: rotateY(0); filter: brightness(1); box-shadow: 0 0 0 rgb(30 18 10 / 0); }
  45% { filter: brightness(.92); box-shadow: 40px 0 70px rgb(30 18 10 / .28); }
  100% { transform: rotateY(-100deg); filter: brightness(.7); box-shadow: 80px 0 90px rgb(30 18 10 / 0); }
}
@keyframes flip-out-right {
  0% { transform: rotateY(0); filter: brightness(1); box-shadow: 0 0 0 rgb(30 18 10 / 0); }
  45% { filter: brightness(.92); box-shadow: -40px 0 70px rgb(30 18 10 / .28); }
  100% { transform: rotateY(100deg); filter: brightness(.7); box-shadow: -80px 0 90px rgb(30 18 10 / 0); }
}
.page-in { animation: page-reveal .85s ease both; }
@keyframes page-reveal {
  from { opacity: .4; transform: scale(.975); filter: brightness(.8); }
  to { opacity: 1; transform: none; filter: none; }
}
.page-in .year-num, .page-in .page-title, .page-in .cover-title { animation: title-in .9s .25s cubic-bezier(.2, .7, .2, 1) both; }
.page-in .year-note, .page-in .chapter, .page-in .kicker { animation: title-in .9s .4s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes title-in {
  from { opacity: 0; translate: 0 18px; letter-spacing: .04em; }
}

/* Hiệu ứng GSAP: bóng trên trang đang lật và bóng đổ xuống trang mới */
.ghost-shade, .cast-shade { position: absolute; inset: 0; pointer-events: none; }
.ghost-shade { z-index: 20; opacity: 0; }
.ghost-shade.is-left { background: linear-gradient(to left, rgb(20 12 6 / .6), rgb(20 12 6 / .2) 65%, rgb(255 250 240 / .12)); }
.ghost-shade.is-right { background: linear-gradient(to right, rgb(20 12 6 / .6), rgb(20 12 6 / .2) 65%, rgb(255 250 240 / .12)); }
.cast-shade { z-index: 9; }
.cast-shade.is-left { background: linear-gradient(to right, rgb(20 12 6 / .5), rgb(20 12 6 / .12) 45%, transparent 75%); }
.cast-shade.is-right { background: linear-gradient(to left, rgb(20 12 6 / .5), rgb(20 12 6 / .12) 45%, transparent 75%); }
.word { display: inline-block; white-space: nowrap; }
.char { display: inline-block; }
.has-gsap .moment { opacity: 1; translate: none; transition: none; }
.has-gsap .polaroid { transition: scale .35s ease, rotate .35s ease; }
.has-gsap .polaroid:hover, .has-gsap .polaroid:focus-visible { transform: none; scale: 1.05; }
.card { transition: box-shadow .25s, translate .3s ease; }
.card:hover { translate: 0 -4px; }

/* ---------- Thanh lật trang (dưới cùng) ---------- */
.flipbar {
  position: fixed; left: 50%; bottom: 14px; z-index: 40; translate: -50% 0;
  display: flex; align-items: center; gap: 10px; color: var(--ink);
  transition: translate .4s cubic-bezier(.2, .7, .2, 1), opacity .3s ease;
}
/* Tự ẩn khi đang cuộn xuống đọc */
.flipbar.is-hidden { translate: -50% calc(100% + 30px); opacity: 0; pointer-events: none; }
.flipbar > button, .dial {
  /* Kính trong suốt: thấy được nội dung phía sau, chỉ làm mờ nhẹ */
  border: 1px solid color-mix(in srgb, var(--ink) 16%, transparent);
  background: color-mix(in srgb, var(--paper) 16%, transparent);
  -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
  box-shadow: 0 6px 18px rgb(0 0 0 / .1), inset 0 1px 0 rgb(255 255 255 / .08);
}
.flipbar > button {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  color: var(--muted); cursor: pointer; transition: background .2s, color .2s;
}
.flipbar > button:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.flipbar > button:disabled { opacity: .35; cursor: default; }

/* Núm vặn: mặt đồng hồ có vạch chia, núm khía xoay theo trang */
.dial {
  position: relative; width: 72px; height: 72px; border-radius: 50%;
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
}
.dial.dragging { cursor: grabbing; }
.dial:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.dial-ticks { position: absolute; inset: 0; }
.tick {
  position: absolute; left: 50%; top: 50%; width: 12px; height: 16px; margin: -8px 0 0 -6px;
  padding: 0; border: 0; background: none; cursor: pointer;
  transform: rotate(var(--a)) translateY(-28px);
}
.tick::before {
  content: ""; position: absolute; left: 50%; top: 4px; width: 1.5px; height: 4px; margin-left: -.75px;
  border-radius: 1px; background: var(--muted); opacity: .55;
  transition: height .3s, top .3s, opacity .3s, background .3s;
}
.tick:hover::before { opacity: 1; background: var(--ink); }
.tick.on::before { top: 2px; height: 7px; width: 2px; opacity: 1; background: var(--accent); }
.knob {
  --rot: -135deg;
  position: absolute; inset: 12px; border-radius: 50%; rotate: var(--rot);
  background:
    radial-gradient(circle, color-mix(in srgb, var(--paper) 22%, transparent) 0 60%, transparent 61%),
    repeating-conic-gradient(color-mix(in srgb, var(--ink) 32%, transparent) 0 2.5deg, transparent 2.5deg 7.5deg);
  box-shadow: 0 2px 6px rgb(0 0 0 / .12), inset 0 0 0 1px color-mix(in srgb, var(--ink) 18%, transparent);
  transition: rotate .55s cubic-bezier(.34, 1.56, .64, 1);
}
/* Kim chỉ: chấm cam trên núm */
.knob::after {
  content: ""; position: absolute; left: 50%; top: 3px; width: 4px; height: 4px; margin-left: -2px;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px var(--accent);
}
.dial.dragging .knob { transition: rotate .14s ease-out; }
.dial-face {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center;
  pointer-events: none; text-align: center;
}
#dial-year { font: 600 10px/1 var(--font-display); }
/* Chữ trên nền trong suốt: viền sáng mờ để vẫn đọc được trên ảnh */
.dial-face { text-shadow: 0 0 4px var(--bg), 0 0 8px var(--bg); }
.dial-face small { margin-top: 2px; font: 600 7px/1 var(--font-body); letter-spacing: .06em; color: var(--muted); }
.dial-tip {
  position: absolute; bottom: calc(100% + 10px); left: 50%; translate: -50% 6px;
  padding: 5px 10px; border-radius: 999px; background: var(--ink); color: var(--bg);
  font: 600 12px/1 var(--font-display); white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .25s, translate .25s;
}
.dial-tip.show, .dial:hover .dial-tip, .dial:focus-visible .dial-tip { opacity: 1; translate: -50% 0; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.to-top {
  position: fixed; right: 20px; bottom: 18px; z-index: 30;
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--line) 85%, transparent); color: var(--muted); font-size: 16px; text-decoration: none;
  background: color-mix(in srgb, var(--paper) 70%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.3); backdrop-filter: blur(16px) saturate(1.3);
  box-shadow: 0 10px 30px rgb(20 12 6 / .18);
  opacity: 0; pointer-events: none; translate: 0 10px; transition: opacity .25s, translate .25s;
}
.to-top.is-shown { opacity: 1; pointer-events: auto; translate: 0 0; }

/* ---------- Xem ảnh phóng to ---------- */
.lightbox {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; background: rgb(14 10 8 / .95); color: #f3ebe1;
}
.lightbox[open] { display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.lightbox::backdrop { background: transparent; }
.lb-stage { display: flex; align-items: center; justify-content: center; min-height: 0; padding: 64px 84px 8px; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; box-shadow: 0 20px 60px rgb(0 0 0 / .5); }
.lb-caption { margin: 0; padding: 12px 24px 26px; font-size: 15px; text-align: center; }
.lb-caption span { display: block; margin-top: 2px; font-size: 13px; color: rgb(243 235 225 / .6); }
.lb-count { position: absolute; top: 26px; left: 24px; font-size: 14px; color: rgb(243 235 225 / .7); }
.lb-btn {
  position: absolute; display: grid; place-items: center; width: 48px; height: 48px;
  border: 0; border-radius: 50%; background: rgb(255 255 255 / .1); color: #fff; cursor: pointer;
}
.lb-btn[hidden] { display: none; }
.lb-btn:hover { background: rgb(255 255 255 / .2); }
.lb-close { top: 14px; right: 14px; }
.lb-prev, .lb-next { top: 50%; translate: 0 -50%; }
.lb-prev { left: 16px; }
.lb-next { right: 16px; }

/* ---------- Màn hình nhỏ ---------- */
@media (max-width: 860px) {
  .cover-grid { grid-template-columns: 1fr; gap: 44px; }
  .collage { width: 100%; max-width: 440px; height: 330px; margin-inline: auto; }
  .polaroid { width: 54%; padding: 8px 8px 36px; }
  .polaroid span { bottom: 8px; font-size: 17px; }
}

@media (max-width: 600px) {
  :root { --bar-h: 56px; }
  .topbar-inner { gap: 10px; padding-inline: 12px; }
  .brand-name { display: none; }
  .page-nav a { padding: 4px 10px; font-size: 14px; }
  .page { padding: 16px 20px 130px; }
  .page-cover::before { inset: 10px; border-radius: 20px; }
  .page-cover::after { display: none; }
  .page-cover { padding: 48px 32px 130px; }
  .timeline-line { left: 10px; }
  .moment { margin-left: 28px; }
  .moment-dot { left: -26px; }
  .cover-title { font-size: clamp(32px, 10vw, 42px); }
  .cover-lead { font-size: 15px; }
  .stats { gap: 12px 24px; }
  .stat strong { font-size: 26px; }
  .kicker { font-size: 31px; }
  .filters { flex-direction: column; flex-wrap: nowrap; align-items: stretch; }
  .chip-row { flex-wrap: nowrap; justify-content: flex-start; margin-inline: -20px; padding: 2px 20px; overflow-x: auto; scrollbar-width: none; }
  .chip-row::-webkit-scrollbar { display: none; }
  .person-filter { justify-content: center; }
  .card-body { padding: 20px 20px 22px; }
  .card-title { font-size: 21px; }
  .next-chapter { gap: 16px; padding: 16px 16px 16px 14px; }
  .nc-photos { width: 84px; height: 76px; }
  .nc-photos img { width: 56px; height: 56px; border-width: 3px; }
  .nc-photos img:nth-child(2) { left: 14px; }
  .nc-photos img:nth-child(3) { left: 28px; }
  .nc-label { font-size: 10px; letter-spacing: .12em; white-space: nowrap; }
  .nc-year { font-size: 32px; }
  .nc-note { font-size: 22px; }
  .nc-arrow { width: 40px; height: 40px; }
  .to-top { right: 14px; bottom: 20px; width: 38px; height: 38px; }
  .lb-stage { padding: 64px 8px 8px; }
  .lb-caption { padding: 12px 72px 24px; }
  .lb-prev, .lb-next { top: auto; bottom: 16px; translate: none; }
}

@media (prefers-reduced-motion: reduce) {
  .moment { opacity: 1; translate: none; transition: none; }
  .moment.flash .card, .page-in, .page-in * { animation: none !important; }
}

/* ---------- Màu chi tiết (Admin → Giao diện → Màu chi tiết) ----------
   Mỗi biến --c-* chỉ có khi người dùng chọn màu riêng; không có thì dùng màu của bộ màu như cũ. */
.brand-name, .cover-title, .page-title, .year-num, .card-title, .member-name, .nc-year,
.stat strong, .otd-text strong { color: var(--c-title, inherit); }
.kicker, .otd-label, .nc-note, .the-end, .year-note, .ribbon { color: var(--c-hand, var(--accent)); }
.page-nav a { color: var(--c-tab, var(--muted)); }
.page-nav a:hover { color: var(--c-tab-hover, var(--ink)); }
.page-nav a.is-active { background: var(--c-tab-active, var(--accent)); color: var(--c-tab-active-ink, var(--accent-ink)); }
.brand-mark { background: var(--c-icon, var(--accent)); color: var(--c-icon-ink, var(--accent-ink)); }
.flipbar > button, .to-top { color: var(--c-icon, var(--muted)); }
.flipbar > button:hover:not(:disabled) { color: var(--c-icon, var(--accent)); }
.tick.on::before { background: var(--c-icon, var(--accent)); }
.knob::after { background: var(--c-icon, var(--accent)); box-shadow: 0 0 6px var(--c-icon, var(--accent)); }
.nc-arrow, .otd-arrow { color: var(--c-icon, var(--accent)); }
.card-place svg { color: var(--c-icon, var(--cat)); }

/* ---------- Xem trước bản nháp (/admin/xem-truoc, chỉ người biên tập) ---------- */
.preview-bar {
  position: fixed; top: var(--bar-h); left: 0; right: 0; z-index: 39;
  padding: 7px 16px; text-align: center; font-size: 13px;
  background: color-mix(in srgb, var(--accent) 16%, var(--paper)); border-bottom: 1px solid var(--line);
}
.preview-bar a { color: var(--accent); font-weight: 600; }
body.is-preview { padding-top: calc(var(--bar-h) + 34px); }
.moment.is-draft .card { outline: 2px dashed color-mix(in srgb, var(--muted) 70%, transparent); outline-offset: 4px; }
.badge-draft { background: transparent; border: 1px dashed var(--muted); color: var(--muted); }
