/* ------------------------------------------------------------------
   60 năm — same paper-and-ink family as house / grandpa-story.
   Navigation on the right; the film or the reading pane fills the rest.
------------------------------------------------------------------- */

:root {
  --paper: #f6f1e6;
  --paper-2: #efe7d6;
  --paper-3: #e6dcc7;
  --ink: #2e2923;
  --ink-soft: #6a6056;
  --ink-faint: #9b9184;
  --line: #d9cdb6;
  --terracotta: #a8583c;
  --verm: #b8432f;
  --moss: #5f6d4d;
  --cinema: #1e1814;
  --shadow: 0 18px 50px -24px rgba(60, 40, 20, 0.45);
  --radius: 16px;
  --side-w: 340px;
  --display: "Cormorant Garamond", "Times New Roman", serif;
  --body: "EB Garamond", Georgia, "Times New Roman", serif;
  --hand: "Patrick Hand", "Comic Sans MS", cursive;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--body); font-size: 17px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; overscroll-behavior: none;
}
a { color: var(--terracotta); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button { font-family: inherit; }

/* ------------------------------ shell ------------------------------ */

.shell { height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) var(--side-w); }
.stage-col { position: relative; min-width: 0; min-height: 0; }
.pane { position: absolute; inset: 0; display: none; }
.pane.on { display: block; }
.pane.page { overflow-y: auto; background: var(--paper); }

/* ------------------------------ film ------------------------------ */

#pane-phim { background: radial-gradient(120% 100% at 50% 30%, #2c241d 0%, var(--cinema) 70%); }
.cinema { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 2rem 1rem; gap: 0.8rem; }
.film {
  position: relative; width: min(100%, calc((100vh - 6rem) * 16 / 9)); aspect-ratio: 16 / 9;
  background: #efe7d6; border-radius: 6px; overflow: hidden;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 240, 220, 0.06);
}
.film canvas { display: block; width: 100%; height: 100%; cursor: pointer; }
.film:fullscreen { width: 100vw; height: 100vh; border-radius: 0; background: #000; }
.film:fullscreen canvas { object-fit: contain; }
.film-note { margin: 0; color: rgba(240, 228, 208, 0.55); font-size: 0.88rem; text-align: center; }

.bigplay {
  position: absolute; inset: 0; border: 0; cursor: pointer; color: #fbf6ea;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 0.35rem; padding-bottom: 9%;
  background: linear-gradient(180deg, rgba(30, 20, 12, 0) 45%, rgba(30, 20, 12, 0.55) 100%);
  transition: opacity 0.5s ease;
}
.bigplay.gone { opacity: 0; pointer-events: none; }
.bigplay .ring {
  width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center;
  background: var(--verm); box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.6), 0 0 0 6px rgba(251, 246, 234, 0.25);
  transition: transform 0.25s ease;
}
.bigplay:hover .ring { transform: scale(1.06); }
.bigplay svg { width: 38px; height: 38px; fill: #fbf6ea; margin-left: 5px; }
.bigplay .bp-t { font-family: var(--display); font-weight: 600; font-size: 1.7rem; letter-spacing: 0.02em; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); }
.bigplay .bp-s { font-style: italic; font-size: 0.95rem; opacity: 0.85; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); }
.film:not(.ready) .ring { opacity: 0.5; }

.bar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 0.6rem;
  padding: 1.4rem 0.9rem 0.6rem; color: #fbf6ea;
  background: linear-gradient(180deg, rgba(20, 14, 8, 0) 0%, rgba(20, 14, 8, 0.7) 100%);
  opacity: 0; transition: opacity 0.35s ease; pointer-events: none;
}
.film.playing.ui .bar, .film.ready:not(.playing) .bigplay.gone ~ .bar { opacity: 1; pointer-events: auto; }
.ctl { appearance: none; border: 0; background: transparent; color: inherit; cursor: pointer; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; padding: 0; }
.ctl:hover { background: rgba(255, 255, 255, 0.12); }
.ctl svg { width: 22px; height: 22px; fill: currentColor; }
.ctl.txt { width: auto; padding: 0 0.5rem; font-size: 0.82rem; letter-spacing: 0.08em; font-weight: 500; border: 1px solid rgba(251, 246, 234, 0.35); height: 26px; }
.ctl.txt.off { opacity: 0.45; text-decoration: line-through; }
.tm { font-variant-numeric: tabular-nums; font-size: 0.85rem; min-width: 2.6rem; text-align: center; opacity: 0.9; }
#scrub { flex: 1; accent-color: var(--verm); height: 4px; cursor: pointer; }

/* ------------------------------ reading panes ------------------------------ */

.doc { max-width: 760px; margin: 0 auto; padding: 3rem 2.6rem 4rem; }
.doc.wide { max-width: 1080px; }
.eyebrow { margin: 0 0 0.5rem; font-size: 0.74rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--terracotta); }
h1 { margin: 0; font-family: var(--display); font-weight: 500; font-size: clamp(2.1rem, 3.6vw, 3.1rem); line-height: 1.08; }
.subtitle { margin: 0.4rem 0 1.6rem; font-family: var(--display); font-style: italic; font-size: 1.3rem; color: var(--ink-soft); }
.doc-lede { color: var(--ink-soft); font-size: 1.05rem; border-left: 2px solid var(--terracotta); padding-left: 0.9rem; }

.memoir .para { margin: 1.6rem 0; }
.memoir .vi, .coda .vi { margin: 0; font-size: 1.14rem; line-height: 1.65; }
.memoir .en, .coda .en { margin: 0.45rem 0 0; font-style: italic; color: var(--ink-soft); font-size: 1rem; }
.memoir .para:first-child .vi::first-letter { font-family: "Dancing Script", var(--display); font-weight: 700; font-size: 3.4rem; float: left; line-height: 0.9; padding: 0.3rem 0.5rem 0 0; color: var(--verm); }
.coda { margin: 2.6rem 0 0; padding: 1.6rem 1.8rem; background: #fbf7ee; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); transform: rotate(-0.4deg); }
.coda .vi { font-family: "Dancing Script", var(--display); font-weight: 700; font-size: 1.7rem; line-height: 1.35; color: #27456b; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 1.4rem; border-left: 2px dotted var(--verm); }
.timeline li { position: relative; display: grid; grid-template-columns: 9.5rem 1fr; gap: 1rem; margin: 0 0 1.8rem; }
.timeline li::before { content: ""; position: absolute; left: calc(-1.4rem - 7px); top: 0.45rem; width: 12px; height: 12px; border-radius: 50%; background: var(--paper); border: 2px solid var(--verm); }
.timeline .d { font-family: "Xanh Mono", monospace; color: var(--verm); font-size: 1rem; padding-top: 0.15rem; }
.timeline h3 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 1.35rem; line-height: 1.2; }
.timeline p { margin: 0.2rem 0 0; color: var(--ink-soft); font-style: italic; }

.frags { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.4rem; }
.frag {
  appearance: none; border: 0; cursor: pointer; text-align: left; font: inherit; color: var(--ink);
  background: #fbf7ee; padding: 0.8rem 0.8rem 1rem; box-shadow: var(--shadow); border-radius: 4px;
  display: flex; flex-direction: column; gap: 0.6rem; transition: transform 0.25s ease;
}
.frag:nth-child(odd) { transform: rotate(-1deg); }
.frag:nth-child(even) { transform: rotate(0.8deg); }
.frag:hover { transform: rotate(0) translateY(-4px); }
.frag .art { height: 190px; display: grid; place-items: center; background: var(--paper-3) url("../assets/img/bg_paper.webp") center/cover; border-radius: 2px; overflow: hidden; }
.frag img { max-width: 88%; max-height: 170px; filter: drop-shadow(3px 6px 6px rgba(45, 28, 12, 0.35)); }
.frag .cap b { display: block; font-family: var(--hand); font-weight: 400; font-size: 1.35rem; line-height: 1.15; }
.frag .cap i { display: block; color: var(--ink-soft); font-size: 0.95rem; line-height: 1.4; margin-top: 0.2rem; }

.reflect .pull { margin: 0 0 2rem; padding: 1.5rem 1.7rem; border-left: 3px solid var(--verm); background: #fbf7ee; border-radius: 0 var(--radius) var(--radius) 0; }
.reflect .pull.soft { border-left-color: var(--moss); }
.reflect .pull .vi { margin: 0; font-family: var(--display); font-size: 1.45rem; line-height: 1.4; }
.reflect .pull .en { margin: 0.6rem 0 0; font-style: italic; color: var(--ink-soft); }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; margin: 0 0 2rem; }
.three > div { padding: 1.1rem 1.1rem 1.2rem; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255, 255, 255, 0.4); }
.three .n { font-family: var(--display); font-weight: 600; color: var(--verm); }
.three h3 { margin: 0.2rem 0 0.3rem; font-family: var(--display); font-weight: 600; font-size: 1.3rem; }
.three p { margin: 0; color: var(--ink-soft); font-size: 0.96rem; font-style: italic; }
.closing { font-size: 1.12rem; text-align: center; margin: 2.4rem auto 0; max-width: 34rem; }
.closing i { color: var(--ink-soft); }

.credits { width: 100%; border-collapse: collapse; margin: 1.4rem 0; font-size: 0.97rem; }
.credits td { padding: 0.55rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.credits td:first-child { color: var(--ink-soft); width: 42%; padding-right: 1rem; }
.note { font-size: 0.9rem; color: var(--ink-soft); border-left: 2px solid var(--terracotta); padding-left: 0.7rem; }

/* ------------------------------ sidebar ------------------------------ */

.side {
  background: var(--paper-2); border-left: 1px solid var(--line); overflow-y: auto;
  padding: 1.8rem 1.5rem 2rem; display: flex; flex-direction: column; gap: 1.5rem;
}
.brand { color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-vi { display: block; font-family: "Dancing Script", var(--display); font-weight: 700; font-size: 2.3rem; line-height: 1; color: var(--verm); }
.brand-en { display: block; margin-top: 0.35rem; font-style: italic; color: var(--ink-soft); font-size: 0.95rem; }
.brand-rule { display: block; width: 42px; height: 2px; background: var(--terracotta); margin-top: 0.9rem; border-radius: 2px; }
.side h2 { margin: 0 0 0.5rem; font-weight: 500; font-size: 0.7rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-faint); }
.side section { display: flex; flex-direction: column; }
.film-only { display: none !important; }
body.on-film .film-only { display: flex !important; }

.nav-link {
  display: grid; grid-template-columns: 1.5rem 1fr; gap: 0.5rem; align-items: start;
  padding: 0.5rem 0.65rem; margin: 0 -0.65rem; border-radius: 10px; color: var(--ink); transition: background 0.2s ease;
}
.nav-link:hover { background: rgba(168, 88, 60, 0.07); text-decoration: none; }
.nav-link.active { background: rgba(168, 88, 60, 0.11); }
.nav-link.active .num { color: var(--terracotta); }
.nav-link .num, .views .num { font-family: var(--display); font-weight: 600; color: var(--ink-faint); }
.nav-link .vi, .views .vi { display: block; line-height: 1.2; }
.nav-link .en, .views .en { display: block; font-style: italic; font-size: 0.88rem; color: var(--ink-soft); }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem; }
.seg button, .chip {
  appearance: none; cursor: pointer; font: inherit; color: var(--ink);
  background: rgba(255, 255, 255, 0.45); border: 1px solid var(--line); border-radius: 10px;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.seg button { padding: 0.45rem 0.7rem; font-size: 0.95rem; }
.seg button[aria-pressed="true"], .chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.chip { padding: 0.35rem 0.75rem; border-radius: 999px; font-size: 0.9rem; }
a.chip { color: var(--ink); text-decoration: none; }
a.chip:hover { background: rgba(168, 88, 60, 0.1); }
.views { display: flex; flex-direction: column; gap: 1px; }
.views button {
  appearance: none; cursor: pointer; font: inherit; color: var(--ink); background: transparent; border: 0; border-radius: 10px; text-align: left;
  display: grid; grid-template-columns: 1.5rem 1fr; gap: 0.5rem; padding: 0.32rem 0.65rem; margin: 0 -0.65rem; transition: background 0.2s ease;
}
.views button:hover { background: rgba(168, 88, 60, 0.07); }
.views button[aria-pressed="true"] { background: rgba(168, 88, 60, 0.12); }
.views button[aria-pressed="true"] .num { color: var(--terracotta); }
.views .en { font-size: 0.84rem; }

.side-foot { margin-top: auto; padding-top: 1rem; display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.9rem; }
.side-foot a { color: var(--ink-soft); }

/* ------------------------------ responsive ------------------------------ */

@media (max-width: 900px) {
  html, body { height: auto; }
  .shell { display: flex; flex-direction: column; height: auto; }
  .stage-col { min-height: 0; }
  .pane { position: relative; inset: auto; }
  #pane-phim .cinema { position: relative; padding: 0.8rem 0.6rem; }
  .film { width: 100%; }
  .doc { padding: 2rem 1.2rem 3rem; }
  .three { grid-template-columns: 1fr; }
  .timeline li { grid-template-columns: 1fr; gap: 0.2rem; }
  .side { border-left: 0; border-top: 1px solid var(--line); padding: 1.4rem 1.2rem 2rem; gap: 1.2rem; }
  .bar { opacity: 1; pointer-events: auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ------------------------------ chapter extras ------------------------------ */

.lang-pick { grid-template-columns: repeat(3, auto); justify-content: start; margin: 1.4rem 0 0; }
.memoir[data-read="vi"] .en, .memoir[data-read="en"] .vi { display: none; }
.memoir[data-read="en"] .en { font-style: normal; color: var(--ink); font-size: 1.1rem; margin: 0; }
.memoir .para { text-align: justify; hyphens: auto; }

.tree { margin: 0 0 2.6rem; padding: 1.6rem 1.2rem; background: #fbf7ee; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); text-align: center; }
.tree .gen { display: flex; justify-content: center; gap: 1.2rem; position: relative; padding: 0 0 1.2rem; }
.tree .gen + .gen::before, .tree .dots + .gen::before { content: ""; position: absolute; top: -1.2rem; left: 50%; height: 1.2rem; border-left: 2px solid var(--line); }
.tree .gen.three { align-items: flex-start; border-top: 2px solid var(--line); padding-top: 1.2rem; margin: 0 12%; }
.tree .gen.three::before { display: none; }
.tree .branch { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }
.tree .node { display: inline-flex; flex-direction: column; padding: 0.5rem 0.9rem; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; }
.tree .node b { font-family: var(--display); font-weight: 600; font-size: 1.2rem; line-height: 1.15; }
.tree .node i { font-size: 0.85rem; color: var(--ink-soft); }
.tree .node.old { border-style: dashed; }
.tree .branch.main > .node { border-color: var(--terracotta); }
.tree .node.sm b { font-size: 1.02rem; }
.tree .node.me { border-color: var(--verm); background: #fff4ea; }
.tree .wives { display: flex; flex-direction: column; font-size: 0.85rem; color: var(--ink-soft); font-style: italic; }
.tree .kids { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem; }
.tree .dots { color: var(--ink-faint); font-style: italic; font-size: 0.9rem; padding: 0 0 1.2rem; }
.tree-note { margin: 0.4rem 0 0; font-size: 0.9rem; color: var(--ink-soft); font-style: italic; }
.frags.people .frag { cursor: default; }
.frag .cap em { font-style: normal; color: var(--terracotta); }
@media (max-width: 900px) { .tree .gen.three { flex-direction: column; margin: 0; } }
