/* BOYHOOD DAYS — memoir reader */
/* Adapted from THEBOOK style, retuned for a single-author family chronicle. */

:root {
  --bg: #f4ecdc;
  --bg-2: #ebe1cc;
  --paper: #faf3e3;
  --ink: #1d160c;
  --ink-soft: #4a3a26;
  --ink-mute: #7a6a52;
  --rule: rgba(29, 22, 12, 0.16);
  --accent: #8a3d18;       /* sun-faded barn red */
  --accent-soft: #c47a48;
  --gold: #a47830;         /* prairie gold */
  --shadow: 0 30px 80px -40px rgba(60, 35, 12, 0.35);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --serif: "Cormorant Garamond", "Iowan Old Style", Garamond, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
html[data-theme="dark"] {
  --bg: #0e0a06;
  --bg-2: #16100a;
  --paper: #1c150e;
  --ink: #ece1c8;
  --ink-soft: #c3b18d;
  --ink-mute: #847358;
  --rule: rgba(236, 225, 200, 0.13);
  --accent: #ff8a4c;
  --accent-soft: #ffb487;
  --gold: #d8b76a;
  --shadow: 0 30px 80px -40px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.62;
  letter-spacing: 0.005em;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.5s ease, color 0.5s ease;
}
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  background:
    radial-gradient(1200px 800px at 70% -10%, var(--bg-2), transparent 60%),
    radial-gradient(900px 700px at -10% 110%, var(--bg-2), transparent 55%);
  opacity: 0.9;
}

/* TOP BAR */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: calc(10px + var(--safe-top)) 18px 10px;
  background: color-mix(in oklab, var(--bg) 78%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--rule);
}
.brand {
  justify-self: center;
  display: inline-flex; align-items: baseline; gap: 8px;
  color: var(--ink); text-decoration: none;
  font-family: var(--serif);
}
.brand-mark { color: var(--accent); font-size: 1.05em; }
.brand-name {
  font-weight: 600;
  letter-spacing: 0.08em;
  font-size: 0.92em;
  text-transform: uppercase;
}
.iconbtn {
  height: 40px; width: 40px;
  display: grid; place-items: center;
  background: transparent; border: 1px solid transparent;
  color: var(--ink); cursor: pointer; border-radius: 999px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.iconbtn:hover { background: color-mix(in oklab, var(--ink) 6%, transparent); }
.iconbtn svg { width: 22px; height: 22px; }

/* Progress bar */
.progress {
  position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; background: transparent;
}
.progress > span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 0.15s ease-out;
}

/* NAV DRAWER */
.nav {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: min(320px, 86vw);
  background: var(--paper);
  z-index: 40;
  transform: translateX(-100%);
  transition: transform 0.28s ease;
  border-right: 1px solid var(--rule);
  overflow-y: auto;
}
.nav.open { transform: translateX(0); }
.nav-inner { padding: 24px 22px calc(28px + var(--safe-bot)); }
.nav-eyebrow {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 8px 0 18px;
}
.nav-section {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 22px 0 8px;
}
.chapters {
  list-style: none; padding: 0; margin: 0;
}
.chapters li { margin: 2px 0; }
.chapters a {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 6px 6px;
  color: var(--ink-soft);
  text-decoration: none;
  border-radius: 6px;
  font-size: 16px;
  line-height: 1.35;
}
.chapters a:hover { background: color-mix(in oklab, var(--accent) 8%, transparent); color: var(--ink); }
.chapters a .num {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.scrim {
  position: fixed; inset: 0; background: rgba(20, 14, 6, 0.42);
  z-index: 35; opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease;
}
.scrim.show { opacity: 1; pointer-events: auto; }

/* VIEW */
.view {
  position: relative; z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 22px 140px;
}
body[data-loading="true"] .view { opacity: 0; transform: translateY(8px); }

/* HOME */
.hero {
  text-align: center;
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--rule);
}
.hero-mark {
  display: inline-block;
  width: 56px; height: 56px;
  border: 1px solid var(--gold);
  border-radius: 999px;
  display: grid; place-items: center;
  color: var(--gold);
  margin: 0 auto 22px;
  font-size: 1.4rem;
}
.hero h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.2rem, 6.5vw, 3.4rem);
  line-height: 1.06;
  margin: 0 0 14px;
  letter-spacing: -0.005em;
}
.hero .by {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.22em;
  color: var(--ink-mute);
  text-transform: uppercase;
}
.hero .dates {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-mute);
  margin-top: 4px;
}
.hero .blurb {
  margin: 26px auto 0;
  max-width: 56ch;
  color: var(--ink-soft);
  font-size: 1.05em;
  font-style: italic;
}
.hero .dedication {
  margin: 22px auto 0;
  max-width: 50ch;
  color: var(--ink-mute);
  font-size: 0.95em;
  font-style: italic;
  border-top: 1px dashed var(--rule);
  padding-top: 14px;
}

.toc {
  list-style: none;
  padding: 0;
  margin: 30px 0 0;
}
.toc-item {
  display: block;
  padding: 22px 6px 22px;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
  text-decoration: none;
  position: relative;
}
.toc-item:hover {
  background: color-mix(in oklab, var(--accent) 5%, transparent);
}
.toc-item .num {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--accent);
  text-transform: uppercase;
  display: block;
  margin-bottom: 6px;
}
.toc-item .ti {
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 500;
  line-height: 1.2;
  margin: 0;
}
.toc-item .era {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--gold);
  letter-spacing: 0.06em;
  margin-top: 6px;
}
.toc-item .blurb {
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-style: italic;
  line-height: 1.5;
}

/* CHAPTER */
.chapter-head {
  position: relative;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: linear-gradient(180deg, color-mix(in oklab, var(--paper) 70%, transparent), transparent 80%);
  padding: 22px 22px 24px;
  margin-bottom: 28px;
  box-shadow: 0 6px 14px -10px rgba(40, 25, 8, 0.22);
}
.chapter-head::after {
  /* Subtle gold underline that mirrors the divider between the chapter
     metadata and the first paragraph. */
  content: "";
  position: absolute;
  left: 22px; right: 22px; bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--gold) 45%, transparent), transparent);
}
@media (max-width: 600px) {
  .chapter-head { padding: 18px 16px 20px; }
  .chapter-head::after { left: 16px; right: 16px; }
}

/* Chapter hero — wet-plate/albumen banner. The img is the still poster; on
   hover (or tap on mobile) a looped .mp4 fades in over it. The music button
   in the corner toggles the chapter's ambient music track. */
.chapter-hero {
  position: relative;
  width: 100%;
  margin: 0 0 22px;
  aspect-ratio: 21 / 9;
  overflow: hidden;
  border-radius: 4px;
  background: var(--bg-2);
  box-shadow: 0 18px 42px -22px rgba(60, 35, 12, 0.45);
}
.chapter-hero.no-hero {
  display: none;
}
.chapter-hero-img,
.chapter-hero-loop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: sepia(0.12) contrast(1.02);
}
.chapter-hero-loop {
  opacity: 0;
  transition: opacity 480ms ease;
  z-index: 1;
}
.chapter-hero:hover .chapter-hero-loop,
.chapter-hero:focus-within .chapter-hero-loop {
  opacity: 1;
}
/* subtle bottom-vignette so chapter title underneath has breathing room */
.chapter-hero::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0; height: 40%;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.18));
  pointer-events: none;
  z-index: 2;
}
.chapter-music-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 3;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.32);
  background: rgba(20, 14, 6, 0.55);
  color: rgba(255, 244, 220, 0.78);
  font-family: var(--serif);
  font-size: 1.15rem;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 200ms ease, color 200ms ease, transform 160ms ease;
  display: grid;
  place-items: center;
}
.chapter-music-btn .cmb-on  { display: none; }
.chapter-music-btn .cmb-off { display: inline; opacity: 0.7; }
.chapter-music-btn:hover { transform: scale(1.06); color: #fff; }
.chapter-music-btn.is-on {
  background: rgba(212, 175, 55, 0.85);
  color: #14110a;
  border-color: rgba(212, 175, 55, 0.95);
}
.chapter-music-btn.is-on .cmb-on  { display: inline; }
.chapter-music-btn.is-on .cmb-off { display: none; }

@media (max-width: 600px) {
  .chapter-hero { aspect-ratio: 16 / 9; }
  .chapter-music-btn { width: 34px; height: 34px; font-size: 1rem; }
}
.chapter-num {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--accent);
  text-transform: uppercase;
}
.chapter-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 5vw, 2.7rem);
  line-height: 1.1;
  margin: 8px 0 6px;
}
.chapter-era {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--gold);
}
.chapter-blurb {
  margin-top: 18px;
  color: var(--ink-soft);
  font-style: italic;
  font-size: 1.04em;
}

/* Paragraphs (selectable like verses) — subtle inset frames so each verse
   reads as a discrete element, echoing the chapter-head's framed look. */
.paragraphs { margin: 18px 0 60px; }
.p {
  position: relative;
  margin: 0 0 14px;
  padding: 14px 18px 14px 42px;
  border: 1px solid color-mix(in oklab, var(--rule) 60%, transparent);
  border-radius: 6px;
  background: color-mix(in oklab, var(--paper) 22%, transparent);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.p:hover {
  background: color-mix(in oklab, var(--accent) 4%, var(--paper) 30%);
  border-color: color-mix(in oklab, var(--accent) 18%, var(--rule));
}
.p.is-selected {
  background: color-mix(in oklab, var(--accent) 12%, transparent);
  border-color: color-mix(in oklab, var(--accent) 45%, transparent);
}
.p .pn {
  position: absolute;
  left: 14px; top: 16px;
  font-family: var(--sans);
  font-size: 10px;
  color: var(--ink-mute);
  letter-spacing: 0.06em;
  font-weight: 600;
}
@media (max-width: 600px) {
  .p { padding: 12px 14px 12px 36px; }
  .p .pn { left: 12px; top: 14px; }
}
.p[data-hl="amber"] { background: rgba(255, 196, 88, 0.28); }
.p[data-hl="rose"]  { background: rgba(214, 130, 112, 0.22); }
.p[data-hl="moss"]  { background: rgba(120, 158, 90, 0.22); }
.p[data-hl="sky"]   { background: rgba(120, 150, 196, 0.22); }
.p.poem .pt {
  white-space: pre-line;
  font-style: italic;
  display: block;
  padding-left: 16px;
  border-left: 2px solid var(--gold);
}

/* Context links inline under a paragraph */
/* Inline context-link pill row that sits under a paragraph — centered so
   it reads as a deliberate "jump out for context" beat rather than a left-
   margin afterthought. */
.p-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 6px 0 16px;
  font-family: var(--sans);
  font-size: 13px;
}
.p-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--gold);
  text-decoration: none;
  padding: 4px 12px;
  border: 1px dashed var(--gold);
  border-radius: 999px;
  font-size: 12.5px;
}
.p-link:hover { background: color-mix(in oklab, var(--gold) 10%, transparent); }
.p-link::before {
  content: "→";
  opacity: 0.65;
}
/* Cast-link variant — barn-red so reader can distinguish "go to context essay"
   from "go to person bio" at a glance. */
.p-link.p-link-cast {
  color: var(--accent);
  border-color: color-mix(in oklab, var(--accent) 70%, transparent);
}
.p-link.p-link-cast:hover {
  background: color-mix(in oklab, var(--accent) 10%, transparent);
}
.p-link.p-link-cast::before {
  content: "☉";
  opacity: 0.7;
}

/* Chapter footer nav */
.chap-foot {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 12px;
  border-top: 1px solid var(--rule);
  padding-top: 22px;
  margin-top: 28px;
}
.chap-foot a {
  flex: 1;
  text-decoration: none;
  color: var(--ink);
  padding: 14px 18px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-family: var(--serif);
}
.chap-foot a:hover { border-color: var(--accent); }
.chap-foot .dir {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--ink-mute);
  text-transform: uppercase;
  display: block;
}
.chap-foot .t {
  display: block;
  margin-top: 4px;
  font-size: 1.05em;
}
.chap-foot .next { text-align: right; }

/* CONTEXT HERO + AUDIO ============================================== */
.context-hero {
  position: relative;
  margin: 0 0 22px;
  width: 100%;
  aspect-ratio: 21 / 9;
  overflow: hidden;
  border-radius: 4px;
  background: var(--bg-2);
  box-shadow: 0 18px 42px -22px rgba(60, 35, 12, 0.45);
}
.context-hero.no-hero { display: none; }
.context-hero-img,
.context-hero-loop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: sepia(0.12) contrast(1.02);
}
.context-hero-loop {
  opacity: 0;
  transition: opacity 480ms ease;
  z-index: 1;
}
.context-hero:hover .context-hero-loop,
.context-hero:focus-within .context-hero-loop {
  opacity: 1;
}
.context-hero::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0; height: 40%;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.18));
  z-index: 2;
  pointer-events: none;
}
.context-audio {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}
.context-audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 12px;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}
.context-audio-btn .lab { letter-spacing: 0.02em; }
.context-audio-btn:hover { border-color: var(--accent); color: var(--ink); }
.context-audio-btn.is-on {
  background: var(--accent);
  color: var(--paper);
  border-color: var(--accent);
}

/* CONTEXT PAGES (essays) */
.context-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
  text-decoration: none;
  margin-bottom: 14px;
}
.context-back:hover { color: var(--accent); }
.context-head .kicker {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
}
.context-head h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 5vw, 2.6rem);
  line-height: 1.1;
  margin: 6px 0 4px;
}
.context-head .years {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-mute);
}
.prose {
  margin-top: 28px;
}
.prose h1, .prose h2, .prose h3 {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: -0.005em;
  margin-top: 1.6em;
  margin-bottom: 0.4em;
}
.prose h1 { font-size: 1.8em; }
.prose h2 { font-size: 1.45em; color: var(--accent); }
.prose h3 { font-size: 1.2em; color: var(--accent-soft); }
.prose p { margin: 0 0 1.05em; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1em; }
.prose li { margin: 0.25em 0; }
.prose em { color: var(--ink-soft); }
.prose strong { color: var(--ink); font-weight: 700; }
.prose blockquote {
  margin: 0 0 1em;
  padding: 8px 0 8px 16px;
  border-left: 2px solid var(--gold);
  color: var(--ink-soft);
  font-style: italic;
}
/* Cross-link footer — "Appears in", "Related context", "Linked from"
   sections at the bottom of bio / chapter / context pages. Each link is a
   small card-tile so the row reads as a cohesive grid instead of loose
   inline text. */
.context-related {
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 13px;
}
.context-related .lab {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  color: var(--ink-mute);
  margin-bottom: 10px;
  font-weight: 600;
}
.context-related .lab:not(:first-child) { margin-top: 18px; }
.context-related a {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  margin: 0 6px 6px 0;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  font-size: 12.5px;
  line-height: 1.25;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.context-related a:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 8px 18px -12px rgba(40, 25, 8, 0.28);
  text-decoration: none;
}
.context-related a::after {
  content: "→";
  margin-left: 8px;
  color: var(--accent);
  opacity: 0.7;
  transition: transform 0.16s ease, opacity 0.16s ease;
}
.context-related a:hover::after { transform: translateX(2px); opacity: 1; }

/* ABOUT / MEDIA */
.simple {
  max-width: 60ch;
}
.simple h2 {
  font-family: var(--serif);
  font-weight: 500;
  margin-top: 1.8em;
}
.simple ul li { margin: 6px 0; }

/* Toast */
.toast {
  position: fixed;
  left: 50%; bottom: calc(110px + var(--safe-bot));
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 18px;
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* To-top button */
.totop {
  position: fixed;
  right: 18px; bottom: calc(110px + var(--safe-bot));
  width: 44px; height: 44px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--paper);
  display: grid; place-items: center;
  cursor: pointer;
  z-index: 25;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.totop[aria-visible="true"] { opacity: 1; }
.totop svg { width: 20px; height: 20px; }

@media (max-width: 600px) {
  body { font-size: 18px; }
  .view { padding-left: 16px; padding-right: 16px; }
  .toc-item .ti { font-size: 1.3rem; }
  .nav {
    width: min(360px, 92vw);
  }
  .nav-inner {
    padding: 28px 24px calc(34px + var(--safe-bot));
  }
  .nav-eyebrow,
  .nav-section {
    font-size: 12px;
  }
  .nav-section {
    margin: 26px 0 10px;
  }
  .chapters li {
    margin: 5px 0;
  }
  .chapters a {
    grid-template-columns: 34px 1fr;
    gap: 12px;
    min-height: 46px;
    padding: 9px 10px;
    font-size: 18px;
    line-height: 1.32;
  }
  .chapters a .num {
    font-size: 12px;
  }
}

/* HOME HUB ============================================================ */
.home-hub {
  position: relative;
  margin: -40px -22px 26px;
  padding: 80px 22px 56px;
  isolation: isolate;
}
@media (max-width: 600px) {
  .home-hub { margin: -40px -16px 22px; padding: 60px 16px 44px; }
}

.hub-slideshow {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: -1;
}
.hub-slide {
  position: absolute;
  inset: 0;
  background-position: center;
  background-size: cover;
  opacity: 0;
  transform: scale(1.06);
  transition: opacity 1.8s ease-in-out, transform 7s ease-out;
  filter: sepia(0.18) contrast(1.04);
  overflow: hidden;
}
.hub-slide.is-active {
  opacity: 1;
  transform: scale(1);
}
.hub-slide-video video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.hub-slideshow-veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(14, 10, 4, 0.42) 0%, rgba(14, 10, 4, 0.78) 60%, var(--bg) 100%),
    radial-gradient(circle at 50% 38%, transparent 0%, rgba(14, 10, 4, 0.55) 70%);
}
html[data-theme="dark"] .hub-slideshow-veil {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.58) 0%, rgba(0, 0, 0, 0.85) 60%, var(--bg) 100%),
    radial-gradient(circle at 50% 38%, transparent 0%, rgba(0, 0, 0, 0.6) 70%);
}

.hub-hero {
  position: relative;
  text-align: center;
  color: #f4ecdc;
  max-width: 640px;
  margin: 0 auto;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.5);
}
.hub-hero .hero-mark {
  display: inline-grid; place-items: center;
  width: 56px; height: 56px;
  border: 1px solid rgba(212, 175, 55, 0.7);
  border-radius: 999px;
  color: #d4af37;
  margin: 0 auto 22px;
  font-size: 1.4rem;
  background: rgba(14, 10, 4, 0.32);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.hub-hero h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.2rem, 6.5vw, 3.6rem);
  line-height: 1.04;
  margin: 0 0 14px;
  color: #f7eed8;
}
.hub-hero .by {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(247, 238, 216, 0.8);
}
.hub-hero .dates {
  font-family: var(--sans);
  font-size: 12px;
  color: rgba(247, 238, 216, 0.62);
  margin-top: 4px;
}
.hub-hero .blurb {
  margin: 24px auto 0;
  max-width: 56ch;
  font-size: 1.05em;
  font-style: italic;
  color: rgba(247, 238, 216, 0.92);
}
.hub-hero .dedication {
  margin: 22px auto 0;
  max-width: 50ch;
  color: rgba(247, 238, 216, 0.7);
  font-size: 0.95em;
  font-style: italic;
  border-top: 1px dashed rgba(212, 175, 55, 0.32);
  padding-top: 14px;
}

.hub-cta-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  max-width: 680px;
  margin: 30px auto 0;
}
@media (max-width: 540px) {
  .hub-cta-row { grid-template-columns: 1fr; }
}
.hub-cta {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px 18px;
  border-radius: 8px;
  text-decoration: none;
  text-align: left;
  font-family: var(--sans);
  background: rgba(247, 238, 216, 0.06);
  border: 1px solid rgba(247, 238, 216, 0.18);
  color: #f4ecdc;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  cursor: pointer;
  font: inherit;
}
.hub-cta:hover {
  transform: translateY(-2px);
  background: rgba(247, 238, 216, 0.12);
  border-color: rgba(212, 175, 55, 0.6);
}
.hub-cta.primary {
  /* Same neutral card style as the rest — no orange flood. */
  background: rgba(247, 238, 216, 0.06);
  border-color: rgba(247, 238, 216, 0.22);
}
.hub-cta.primary:hover {
  background: rgba(247, 238, 216, 0.12);
  border-color: rgba(212, 175, 55, 0.6);
}
.hub-cta-icon {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid rgba(212, 175, 55, 0.35);
  color: #d4af37;
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0;
}
.hub-cta-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.hub-cta-label {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: 0.005em;
}
.hub-cta-sub {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(247, 238, 216, 0.68);
  margin-top: 2px;
}

/* Section cards under the hero */
.hub-sections {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin: 0 0 36px;
}
.hub-card {
  position: relative;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  text-align: left;
  font: inherit;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.hub-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 14px 32px -16px rgba(40, 25, 8, 0.34);
}
/* Subtle background media — image lives under the content via .hub-card-bg
   so legibility stays clean. Set per-card via inline --card-bg variable. */
.hub-card-bg {
  position: absolute; inset: 0;
  z-index: 0;
  background-image: var(--card-bg);
  background-size: cover;
  background-position: center;
  opacity: 0.18;
  filter: saturate(0.85) contrast(1.04) blur(0.4px);
  transition: opacity 0.18s ease;
}
.hub-card.has-bg::after {
  /* Paper-color veil so text reads, fading from heavier on the left
     (where the icon + title live) to lighter on the right. */
  content: "";
  position: absolute; inset: 0;
  z-index: 0;
  background: linear-gradient(105deg,
    color-mix(in oklab, var(--paper) 82%, transparent) 0%,
    color-mix(in oklab, var(--paper) 56%, transparent) 100%);
  pointer-events: none;
}
.hub-card:hover .hub-card-bg { opacity: 0.32; }
.hub-card > .hub-card-icon,
.hub-card > .hub-card-text,
.hub-card > .hub-card-arrow { position: relative; z-index: 1; }

/* Primary action cards (Begin reading, Auto-play STORY mode) — slightly
   accented border + brighter icon background so they read as primary. */
.hub-card.is-primary {
  border-color: color-mix(in oklab, var(--accent) 36%, var(--rule));
  background: color-mix(in oklab, var(--accent) 6%, var(--paper));
}
.hub-card.is-primary .hub-card-icon {
  background: var(--accent);
  color: var(--paper);
  border-color: var(--accent);
}
.hub-card-icon {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  background: color-mix(in oklab, var(--accent) 12%, transparent);
  color: var(--accent);
  border-radius: 999px;
  font-family: var(--serif);
  font-size: 1.5rem;
  border: 1px solid color-mix(in oklab, var(--accent) 25%, var(--rule));
}
.hub-card-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.hub-card-title {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--ink);
}
.hub-card-sub {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--gold);
}
.hub-card-blurb {
  font-size: 0.92em;
  color: var(--ink-soft);
  font-style: italic;
  line-height: 1.4;
  margin-top: 6px;
}
.hub-card-arrow {
  font-family: var(--sans);
  font-size: 18px;
  color: var(--accent);
  opacity: 0.7;
  transition: transform 0.18s ease;
}
.hub-card:hover .hub-card-arrow { transform: translateX(4px); opacity: 1; }

/* Chapter grid (the story hub) — same look as the home hub section cards */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin: 18px 0 36px;
}
.chapter-card {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 12px;
  padding: 0;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  overflow: hidden;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.chapter-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 14px 32px -16px rgba(40, 25, 8, 0.34);
}
.chapter-card-thumb {
  position: relative;
  margin: 0;
  width: 100px;
  background: var(--bg-2);
  overflow: hidden;
}
.chapter-card-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: sepia(0.14) contrast(1.02);
}
.chapter-card-num {
  position: absolute;
  bottom: 6px;
  left: 6px;
  z-index: 2;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #f4ecdc;
  background: rgba(20, 14, 6, 0.72);
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid rgba(247, 238, 216, 0.22);
  backdrop-filter: blur(4px);
}
.chapter-card-thumb.no-img {
  background:
    radial-gradient(circle at 30% 30%, color-mix(in oklab, var(--gold) 22%, var(--paper)), var(--bg-2));
}
.chapter-card-thumb.no-img::before {
  content: "✦";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 28px;
  color: var(--gold);
  opacity: 0.55;
}
.chapter-card-body {
  display: grid;
  gap: 3px;
  padding: 14px 16px 14px 4px;
  min-width: 0;
  align-content: center;
}
.chapter-card-kicker {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}
.chapter-card-title {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.15;
  color: var(--ink);
}
.chapter-card-era {
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--gold);
  margin-top: 1px;
}
.chapter-card-blurb {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.92em;
  color: var(--ink-soft);
  line-height: 1.42;
  margin-top: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 600px) {
  .chapter-card { grid-template-columns: 80px 1fr; }
  .chapter-card-thumb { width: 80px; }
}

/* Context essays hub grid */
.ctx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  margin: 0 0 36px;
}
.ctx-card {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.ctx-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 14px 32px -16px rgba(40, 25, 8, 0.34);
}
.ctx-card-years {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}
.ctx-card-title {
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 500;
  line-height: 1.18;
  margin-top: 2px;
}
.ctx-card-refs {
  font-family: var(--sans);
  font-size: 10px;
  color: var(--ink-mute);
  margin-top: 6px;
}

/* CAST HUB + BIO ==================================================== */
.cast-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 18px 0 22px;
  font-family: var(--sans);
}
.cast-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}
.cast-chip:hover {
  border-color: var(--accent);
  color: var(--ink);
}
.cast-chip.is-active {
  background: var(--accent);
  color: var(--paper);
  border-color: var(--accent);
}
.cast-chip .chip-count {
  font-size: 10px;
  opacity: 0.7;
  background: color-mix(in oklab, var(--ink) 8%, transparent);
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 600;
}
.cast-chip.is-active .chip-count {
  background: rgba(255, 255, 255, 0.18);
  color: var(--paper);
  opacity: 1;
}

/* Cast toolbar — chips on the left, view switch on the right. */
.cast-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 0 0 18px;
}
.cast-view-switch {
  display: inline-flex;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  flex: 0 0 auto;
}
.cast-view-btn {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: transparent;
  border: none;
  color: var(--ink-mute);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}
.cast-view-btn:hover { color: var(--ink); }
.cast-view-btn.is-active {
  background: color-mix(in oklab, var(--gold) 16%, var(--paper));
  color: var(--ink);
}

/* Grid view — square portrait tiles with name + one-liner under. */
.cast-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin: 0 0 32px;
}
.cast-tile {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.cast-tile:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 14px 30px -16px rgba(40, 25, 8, 0.34);
}
.cast-tile-img {
  position: relative;
  margin: 0;
  aspect-ratio: 1 / 1;
  background:
    radial-gradient(circle at 30% 30%, color-mix(in oklab, var(--gold) 50%, var(--paper)), color-mix(in oklab, var(--gold) 22%, var(--bg-2)));
  overflow: hidden;
}
.cast-tile-img img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  filter: saturate(0.92) contrast(1.02);
}
.cast-tile-fallback {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: 3rem;
  color: color-mix(in oklab, var(--ink) 35%, transparent);
}
.cast-tile-img:not(.no-img) .cast-tile-fallback { display: none; }
.cast-tile-text {
  padding: 10px 12px 14px;
  display: grid;
  gap: 3px;
}
.cast-tile .cast-name { font-size: 1.04rem; line-height: 1.18; }
.cast-tile .cast-one-liner {
  font-size: 12.5px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Round portrait image in the list-view cards (was initial-only before). */
.cast-medallion-img {
  position: relative;
  width: 56px; height: 56px;
  margin: 0;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid color-mix(in oklab, var(--gold) 60%, var(--ink));
  background:
    radial-gradient(circle at 30% 30%, color-mix(in oklab, var(--gold) 70%, var(--paper)), color-mix(in oklab, var(--gold) 40%, var(--bg-2)));
  flex: 0 0 auto;
}
.cast-medallion-img img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.cast-medallion-fallback {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--bg);
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.6rem;
}
.cast-medallion-img:not(.no-img) .cast-medallion-fallback { display: none; }

.cast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin: 0 0 32px;
}
.cast-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  padding: 14px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.cast-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px -16px rgba(40, 25, 8, 0.32);
}
.cast-medallion {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 30% 30%, color-mix(in oklab, var(--gold) 70%, var(--paper)), color-mix(in oklab, var(--gold) 40%, var(--bg-2))),
    var(--gold);
  color: var(--bg);
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.6rem;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--gold) 60%, var(--ink));
  box-shadow: inset -4px -4px 8px rgba(0, 0, 0, 0.12);
  flex: 0 0 auto;
}
.cast-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.cast-kicker {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}
.cast-name {
  font-family: var(--serif);
  font-size: 1.18rem;
  font-weight: 500;
  line-height: 1.15;
}
.cast-role {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.cast-one-liner {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.92rem;
  color: var(--ink-soft);
  line-height: 1.42;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Person bio page */
.person-head {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 22px;
  align-items: center;
  margin: 20px 0 26px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--rule);
}
.person-portrait {
  position: relative;
  margin: 0;
  width: 120px;
  height: 120px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--rule);
  background:
    radial-gradient(circle at 30% 30%, color-mix(in oklab, var(--gold) 70%, var(--paper)), color-mix(in oklab, var(--gold) 35%, var(--bg-2)));
  box-shadow: 0 12px 24px -12px rgba(40, 25, 8, 0.35);
}
.person-portrait img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: sepia(0.12) contrast(1.02);
}
.person-portrait-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 3rem;
  font-weight: 500;
  color: var(--bg);
}
.person-portrait.no-img .person-portrait-fallback {
  display: grid;
}
.person-text { min-width: 0; }
.person-text .kicker {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}
.person-text h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 5vw, 2.6rem);
  line-height: 1.08;
  margin: 4px 0 4px;
}
.person-role {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0.02em;
  margin: 0 0 2px;
}
.person-dates {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-mute);
  margin: 0 0 6px;
}
.person-one-liner {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-soft);
  margin: 6px 0 0;
}

.person-bio { margin-top: 18px; }

@media (max-width: 600px) {
  .person-head {
    grid-template-columns: 84px 1fr;
    gap: 14px;
  }
  .person-portrait {
    width: 84px;
    height: 84px;
  }
  .person-portrait-fallback { font-size: 2rem; }
  .cast-grid {
    grid-template-columns: 1fr;
  }
}

/* MAP — layout, theme, side menu, info panel ======================= */
.map-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 12px;
  margin: 18px 0 32px;
}
/* Map shell — two columns (map | info rail) on wide, single stack on phones.
   The timeline is a slide-out drawer at ALL widths so the map gets the
   horizontal real estate it deserves. */
.map-shell-3col {
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
}
@media (max-width: 1100px) {
  .map-shell-3col { grid-template-columns: minmax(0, 1fr) 300px; gap: 10px; }
}
@media (max-width: 820px) {
  .map-shell-3col { grid-template-columns: 1fr; }
}

/* Timeline is a slide-out drawer at all widths. The "☰ Timeline" button
   above the map opens it; backdrop closes it; tapping a year auto-closes. */
.map-side {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(86vw, 340px);
  max-height: 100vh;
  z-index: 90;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 0 8px 8px 0;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.26s ease;
  box-shadow: 0 0 32px rgba(0,0,0,0.4);
}
.map-shell-3col.tl-open .map-side {
  transform: translateX(0);
}
.map-side-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.42);
  z-index: 89;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.map-side-backdrop[hidden] { display: none; }
.map-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--rule);
}
.map-side-title {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
}
.map-side-controls {
  display: flex;
  gap: 4px;
}
.map-side-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  transition: background 0.16s ease, border-color 0.16s ease;
}
.map-side-btn:hover { background: color-mix(in oklab, var(--accent) 12%, transparent); border-color: var(--accent); }

.map-timeline {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  overflow-y: auto;
  flex: 1;
}
.map-tl-item {
  display: grid;
  grid-template-columns: 56px 16px 1fr;
  align-items: start;
  gap: 8px;
  padding: 10px 12px;
  border-left: 2px solid transparent;
  cursor: pointer;
  position: relative;
  font-family: var(--sans);
  transition: background 0.16s ease, border-color 0.16s ease;
}
.map-tl-item::before {
  content: "";
  position: absolute;
  left: 75px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: color-mix(in oklab, var(--ink-mute) 30%, transparent);
}
.map-tl-item:last-child::before { display: none; }
.map-tl-item:hover {
  background: color-mix(in oklab, var(--accent) 6%, transparent);
}
.map-tl-item.is-active {
  background: color-mix(in oklab, var(--accent) 12%, transparent);
  border-left-color: var(--accent);
}
.map-tl-year {
  font-size: 11px;
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: right;
  padding-top: 2px;
}
.map-tl-dot {
  width: 11px; height: 11px;
  border-radius: 999px;
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--rule);
  margin-top: 4px;
  justify-self: center;
  z-index: 1;
}
.map-tl-text {
  display: grid;
  gap: 1px;
  font-size: 12px;
  min-width: 0;
}
.map-tl-text strong {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.2;
}
.map-tl-place {
  color: var(--ink-mute);
  font-size: 10.5px;
}

.map-canvas {
  position: relative;
  height: 68vh;
  min-height: 460px;
  max-height: 760px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-2);
}
.map-leaf {
  position: absolute; inset: 0;
  /* Sepia tint to match site theme. Adjust if too strong. */
  filter: sepia(0.32) saturate(0.85) contrast(0.96);
}
html[data-theme="dark"] .map-leaf {
  filter: sepia(0.28) saturate(0.7) contrast(0.95) brightness(0.78);
}

/* Pin glow when active */
.boyhood-pin.is-active .bp-dot {
  transform: scale(1.35);
  box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.45), 0 4px 12px rgba(0, 0, 0, 0.45);
}
.boyhood-pin .bp-dot {
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}

/* Info panel — by default a sticky right rail (.map-info-rail) in the 3-col
   shell. On <1100px it spans full width below the map+timeline row. The
   panel hides until a pin is selected, then fades in. */
.map-info {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 18px 38px -16px rgba(40, 25, 8, 0.32);
  overflow: hidden;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.26s ease, transform 0.26s ease;
  pointer-events: none;
}
/* Sticky right rail — follows the map at all widths where it sits beside the
   map (>=701px). On phones it stacks below as a regular card. */
@media (min-width: 701px) {
  .map-info-rail {
    align-self: start;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
  }
  /* Stack image above body in the narrow rail (no side-by-side). */
  .map-info-rail .map-info-grid { grid-template-columns: 1fr; }
  .map-info-rail .map-info-img { min-height: 180px; max-height: 220px; }
}
.map-info.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.map-info-grid {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: 0;
}
@media (max-width: 760px) {
  .map-info-grid { grid-template-columns: 1fr; }
}
.map-info-close {
  position: absolute;
  top: 10px; right: 12px;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: transparent;
  color: var(--ink-mute);
  border: 1px solid var(--rule);
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  z-index: 5;
}
.map-info-close:hover { background: color-mix(in oklab, var(--ink) 6%, transparent); color: var(--ink); }
.map-info-img {
  margin: 0;
  position: relative;
  min-height: 220px;
  background: var(--bg-2);
  overflow: hidden;
}
.map-info-img img,
.map-info-img video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  filter: sepia(0.16) contrast(1.02);
  transition: opacity 0.6s ease;
}
.map-info-img video { z-index: 1; }
.map-info-fallback {
  display: none;
}
/* When the image failed to load, collapse the figure to a slim placeholder
   so the panel becomes a compact text card without a giant gold star. */
.map-info-img.no-img {
  min-height: 0;
  background: transparent;
}
.map-info-img.no-img img,
.map-info-img.no-img video {
  display: none;
}
@media (max-width: 760px) {
  .map-info-img { min-height: 180px; }
}

.map-info-body {
  position: relative;
  padding: 18px 22px 20px;
}
.map-info-narration {
  margin: 10px 0 14px;
  padding: 12px 14px;
  font-family: var(--serif);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink-soft);
  border-left: 2px solid color-mix(in oklab, var(--gold) 50%, transparent);
  background: color-mix(in oklab, var(--gold) 6%, transparent);
  border-radius: 0 4px 4px 0;
  display: none;
}
.map-info-narration.is-active {
  display: block;
  animation: narrationIn 0.36s ease;
}
/* When NATE is actively reading this pin, brighten the block + accent the rail
   so the user can follow along with the audio. */
.map-info-narration.is-playing {
  color: var(--ink);
  border-left-color: var(--accent);
  background: color-mix(in oklab, var(--accent) 9%, transparent);
}
@keyframes narrationIn {
  from { opacity: 0; transform: translateX(-4px); }
  to   { opacity: 1; transform: translateX(0); }
}
.map-info-kicker {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}
.map-info-title {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 500;
  margin: 4px 0 2px;
  line-height: 1.15;
}
.map-info-place {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--ink-mute);
  margin: 0 0 8px;
}
.map-info-note {
  font-family: var(--serif);
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 0 0 12px;
}
.map-info-open {
  display: inline-block;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 1px;
}

@media (max-width: 980px) {
  /* In the two-col band, give the map enough height to be useful but cap so
     the info rail beside it shows a full image + narration without scroll. */
  .map-canvas { height: 58vh; min-height: 380px; }
}
@media (max-width: 700px) {
  /* Mobile: timeline becomes a slide-out drawer, map stays prominent up top,
     and the info card uses the pin's media as a subtle ambient background
     (like the homepage slideshow) so the script + text can sit on top
     without consuming a separate image block of vertical space. */
  .map-canvas { height: 50vh; min-height: 320px; }

  .map-info-rail .map-info-grid {
    position: relative;
    grid-template-columns: 1fr;
    min-height: 320px;
  }
  /* Image becomes a low-opacity ambient bg layer behind the body text. */
  .map-info-rail .map-info-img {
    position: absolute;
    inset: 0;
    z-index: 0;
    min-height: 0;
    max-height: none;
    opacity: 0.22;
    filter: saturate(0.85) contrast(1.05) blur(0.5px);
    pointer-events: none;
  }
  .map-info-rail .map-info-img::after {
    /* Vertical fade so text is most legible toward the bottom. */
    content: "";
    position: absolute; inset: 0;
    background: linear-gradient(180deg,
      color-mix(in oklab, var(--paper) 30%, transparent) 0%,
      color-mix(in oklab, var(--paper) 70%, transparent) 60%,
      var(--paper) 100%);
  }
  .map-info-rail .map-info-body {
    position: relative;
    z-index: 1;
    padding: 18px 18px 20px;
  }
}

/* Toggle button — always visible above the map. */
.map-tl-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  padding: 8px 14px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}
.map-tl-toggle:hover {
  border-color: var(--accent);
  background: color-mix(in oklab, var(--accent) 8%, transparent);
}
.map-side-backdrop[hidden] { display: none; }

/* MAP pin (existing rules kept) */
.boyhood-pin .bp-dot {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  color: var(--paper);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  border: 2px solid var(--paper);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.18s ease;
}
.boyhood-pin:hover .bp-dot {
  transform: scale(1.18);
}
.leaflet-popup-content-wrapper {
  border-radius: 4px !important;
  background: var(--paper) !important;
  box-shadow: 0 12px 32px -10px rgba(40, 25, 8, 0.4) !important;
}
.leaflet-popup-tip {
  background: var(--paper) !important;
}

/* PARAGRAPH CONTEXT MENU — pops up on long-press / right-click. Floats
   anchored above (or below) the paragraph so it doesn't cover the reader bar. */
.ctxmenu {
  position: absolute;
  z-index: 55;
  min-width: 220px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 18px 42px -16px rgba(40, 25, 8, 0.4),
              0 2px 6px rgba(0, 0, 0, 0.18);
  font-family: var(--sans);
  font-size: 13px;
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  transform-origin: top center;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.ctxmenu.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.ctxmenu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 6px;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-mute);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.ctxmenu-close {
  background: transparent;
  border: 0;
  color: var(--ink-mute);
  cursor: pointer;
  font-size: 13px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
}
.ctxmenu-close:hover { background: color-mix(in oklab, var(--ink) 8%, transparent); }
.ctxmenu-row {
  display: flex;
  gap: 4px;
  padding: 4px;
}
.ctxmenu-btn {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  font: inherit;
}
.ctxmenu-btn:hover { background: color-mix(in oklab, var(--accent) 10%, transparent); }
.ctxmenu-btn .ctxi {
  color: var(--accent);
  font-size: 15px;
  display: inline-grid;
  place-items: center;
  width: 16px;
}
.ctxmenu-swatches {
  justify-content: space-between;
  padding: 6px 10px 8px;
}
.ctxmenu .swatch {
  width: 22px; height: 22px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}
.ctxmenu .swatch:hover {
  transform: scale(1.12);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}
.ctxmenu .sw-amber { background: rgba(255, 196, 88, 0.7); }
.ctxmenu .sw-rose  { background: rgba(214, 130, 112, 0.7); }
.ctxmenu .sw-moss  { background: rgba(120, 158, 90, 0.7); }
.ctxmenu .sw-sky   { background: rgba(120, 150, 196, 0.7); }
.ctxmenu .sw-clear { background: transparent; border: 1px dashed var(--ink-mute); }

/* STORY MODE OVERLAY ================================================= */
.story-overlay {
  position: fixed; inset: 0;
  z-index: 110;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  background: #0a0604;
  color: #f4ecdc;
  font-family: var(--serif);
  isolation: isolate;
  overflow: hidden;
}
.story-bg {
  position: absolute; inset: 0;
  z-index: -2;
}
.story-bg > div, .story-bg > video {
  animation: storySlideIn 1.6s ease;
}
@keyframes storySlideIn {
  from { opacity: 0; transform: scale(1.06); }
  to   { opacity: 1; transform: scale(1); }
}
.story-veil {
  position: absolute; inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 50% 30%, rgba(0,0,0,0.45), rgba(0,0,0,0.78) 70%),
    linear-gradient(180deg, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.85) 100%);
}
.story-head {
  text-align: center;
  padding: max(28px, env(safe-area-inset-top, 0px) + 18px) 24px 0;
}
.story-ch {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #d4af37;
}
.story-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  margin: 6px 0 0;
  color: #f7eed8;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.5);
}
.story-paragraph {
  max-width: 780px;
  margin: auto;
  padding: 30px 28px;
  font-family: var(--serif);
  font-size: clamp(1.3rem, 2.4vw, 1.9rem);
  line-height: 1.45;
  text-align: center;
  color: #fbf3dc;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.7);
}
.story-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 18px 16px max(22px, env(safe-area-inset-bottom, 0px));
  font-family: var(--sans);
  font-size: 13px;
  background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.45) 35%);
}
.story-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: rgba(20, 14, 6, 0.6);
  color: #f4ecdc;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 17px;
  transition: background 0.16s ease, transform 0.16s ease;
}
.story-btn:hover { background: rgba(255, 255, 255, 0.16); transform: translateY(-2px); }
.story-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  width: 52px; height: 52px;
  font-size: 14px;
}
.story-btn.primary:hover { background: var(--accent-soft); }
.story-music-toggle {
  width: auto;
  min-width: 104px;
  padding: 0 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.story-music-toggle.is-muted {
  color: #f4ecdc;
  background: rgba(120, 28, 28, 0.62);
  border-color: rgba(255, 210, 210, 0.32);
}
.story-btn.close { margin-left: auto; }
.story-meta {
  color: rgba(247, 238, 216, 0.74);
  font-size: 11px;
  letter-spacing: 0.06em;
  margin: 0 12px;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .story-controls {
    gap: 6px;
    padding-left: 10px;
    padding-right: 10px;
  }
  .story-music-toggle {
    min-width: 88px;
    padding: 0 10px;
    letter-spacing: 0.04em;
  }
  .story-meta {
    display: none;
  }
}

/* RSVP overlay — fully opaque so the chapter text behind doesn't bleed
   through. Higher z-index than the reader bar so nothing covers it. */
.rsvp {
  position: fixed; inset: 0;
  background: #0a0604;  /* fully opaque, no alpha */
  color: #f4ecdc;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  font-family: var(--serif);
  isolation: isolate;
}
.rsvp::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 50% 30%, rgba(212, 175, 55, 0.06), transparent 50%),
    linear-gradient(180deg, rgba(255,255,255,0.02), transparent 30%);
  pointer-events: none;
}
.rsvp.show { display: flex; }
.rsvp .ref {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.22em;
  color: #d4af37;
  text-transform: uppercase;
  margin-bottom: 32px;
  text-shadow: 0 0 18px rgba(212, 175, 55, 0.25);
}
.rsvp .word {
  position: relative;
  font-size: clamp(2.6rem, 9vw, 5.4rem);
  line-height: 1.18;
  text-align: center;
  font-weight: 400;
  letter-spacing: -0.005em;
  max-width: 92%;
  color: #fbf3dc;
  padding: 16px 8px;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.5);
}
.rsvp .word .orp {
  color: #ff9a55;
}
.rsvp .crosshair {
  position: absolute;
  top: 50%; left: 50%;
  width: 2px;
  height: 32px;
  background: linear-gradient(to bottom, transparent, #d4af37, transparent);
  transform: translate(-50%, -130%);
  opacity: 0.45;
  pointer-events: none;
}
.rsvp .controls {
  position: absolute;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  justify-content: center;
  font-family: var(--sans); font-size: 13px;
  max-width: calc(100vw - 24px);
  padding: 10px 14px;
  background: rgba(20, 14, 6, 0.7);
  border: 1px solid rgba(212, 175, 55, 0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 999px;
}
.rsvp .controls button {
  background: transparent;
  color: #f4ecdc;
  border: 1px solid rgba(255, 255, 255, 0.22);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
}
.rsvp .controls button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.rsvp .controls input[type="range"] { width: 120px; }
.rsvp .close {
  position: absolute;
  top: calc(18px + env(safe-area-inset-top, 0px));
  right: 18px;
  width: 42px; height: 42px;
  background: rgba(20, 14, 6, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #f4ecdc;
  border-radius: 999px;
  cursor: pointer;
  font-size: 18px;
  display: grid; place-items: center;
}
.rsvp .close:hover { background: rgba(255,255,255,0.12); }
@media (max-width: 600px) {
  .rsvp .controls input[type="range"] { width: 90px; }
  .rsvp .controls { gap: 5px; padding: 8px 10px; font-size: 12px; }
}

/* READ BAR (TTS + RSVP) */
/* On #/map and #/person/* the toolbar drives a route-specific narration
   (map autoplay / cast bio) instead of paragraph reading, so hide the
   Listen/Read/Story mode picker — only Prev/Play/Next/Stop apply. */
.readbar.is-map  .rb-mode,
.readbar.is-cast .rb-mode,
.readbar.is-home .rb-mode { display: none; }
.readbar.is-map  .now,
.readbar.is-cast .now,
.readbar.is-home .now { font-style: italic; }

.readbar {
  position: fixed;
  left: 50%; bottom: 18px;
  transform: translateX(-50%);
  display: flex; gap: 6px;
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 6px;
  box-shadow: var(--shadow);
  z-index: 24;
  font-family: var(--sans);
  font-size: 13px;
  max-width: calc(100vw - 32px);
}
.readbar button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit;
}
.readbar button.primary {
  /* Muted gold instead of flag-orange — matches the kicker / link palette,
     reads as the primary action without dominating the bar. */
  background: color-mix(in oklab, var(--gold) 90%, var(--ink));
  color: var(--paper);
  min-width: 38px;
  justify-content: center;
  border: 1px solid color-mix(in oklab, var(--gold) 70%, transparent);
}
.readbar button:hover { background: color-mix(in oklab, var(--ink) 8%, transparent); }
.readbar button.primary:hover {
  background: var(--gold);
  border-color: var(--gold);
}
.readbar .now {
  color: var(--ink-mute);
  padding: 0 8px;
  font-size: 12px;
  align-self: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 240px;
}

/* Two-segment mode switch — Listen | Read RSVP */
.rb-mode {
  display: inline-flex;
  background: color-mix(in oklab, var(--ink) 7%, transparent);
  border-radius: 999px;
  padding: 2px;
  margin: 0 4px;
}
.rb-mode-btn {
  background: transparent !important;
  color: var(--ink-mute) !important;
  border-radius: 999px !important;
  padding: 4px 12px !important;
  display: inline-flex !important;
  flex-direction: column;
  align-items: center;
  gap: 1px !important;
  line-height: 1.1;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}
.rb-mode-btn .rb-mode-title {
  font-size: 12px;
  font-weight: 600;
}
.rb-mode-btn .rb-mode-sub {
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-mute);
  opacity: 0.7;
}
.rb-mode-btn.is-active {
  /* Subtle ink-on-paper instead of orange. Reads as "selected" via contrast
     against the lighter sibling buttons, not via a colored flag. */
  background: color-mix(in oklab, var(--ink) 14%, transparent) !important;
  color: var(--ink) !important;
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--gold) 35%, transparent);
}
.rb-mode-btn.is-active .rb-mode-sub {
  color: var(--gold) !important;
  opacity: 0.95;
}

@media (max-width: 600px) {
  .readbar .now { display: none; }
  .rb-mode-btn { padding: 3px 10px !important; }
  .rb-mode-btn .rb-mode-sub { display: none; }
}
