:root {
  --bg: #05070d;
  --bg-soft: #0a0e18;
  --ink: #eef1f7;
  --ink-dim: #b7c0d2;
  --ink-read: #cfd6e4; /* long-form body text — brighter than ink-dim for sustained reading */
  --ink-faint: #76808f;
  --gold: #e8c66a;
  --gold-deep: #c89b3c;
  --line: rgba(255, 255, 255, 0.1);
  --serif: "Cormorant Garamond", "Hoefler Text", Garamond, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* Root size scales gently with the viewport so type doesn't feel small on big displays */
html { scroll-behavior: smooth; font-size: clamp(16px, 14.8px + 0.2vw, 19px); }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--gold); color: #000; }

/* ---------- Progress bar + timeline rail ---------- */
#progress {
  position: fixed; top: 0; left: 0; height: 2px; width: 0%;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold));
  z-index: 100; transition: width 0.1s linear;
}

#rail {
  position: fixed; right: 22px; top: 50%; transform: translateY(-50%);
  z-index: 90; display: flex; flex-direction: column; gap: 14px;
  opacity: 0; transition: opacity 0.6s ease; pointer-events: none;
}
#rail.visible { opacity: 1; pointer-events: auto; }
.rail-dot {
  width: 9px; height: 9px; border-radius: 50%; padding: 0;
  appearance: none; -webkit-appearance: none;
  background: rgba(255,255,255,0.18); cursor: pointer; position: relative;
  transition: all 0.3s ease; border: 1px solid transparent;
}
.rail-dot:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.rail-dot:hover { background: rgba(255,255,255,0.5); transform: scale(1.3); }
.rail-dot.active { background: var(--gold); box-shadow: 0 0 12px var(--gold); }
.rail-dot .rail-label {
  position: absolute; right: 20px; top: 50%; transform: translateY(-50%);
  white-space: nowrap; font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-dim);
  background: rgba(5,7,13,0.85); padding: 4px 10px; border-radius: 4px;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.rail-dot:hover .rail-label { opacity: 1; }

/* ---------- Hero ---------- */
#hero {
  position: relative; height: 100vh; min-height: 640px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; overflow: hidden;
}
#hero video, .clip-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; z-index: 0;
}
#hero .veil {
  position: absolute; inset: 0; z-index: 1;
  background: radial-gradient(ellipse at center, rgba(5,7,13,0.35) 0%, rgba(5,7,13,0.78) 70%, var(--bg) 100%);
}
.hero-inner { position: relative; z-index: 2; padding: 0 24px; }
.hero-kicker {
  font-size: 13px; letter-spacing: 0.45em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 28px; padding-left: 0.45em;
}
.hero-title {
  font-family: var(--serif); font-weight: 300;
  font-size: clamp(3.4rem, 12vw, 9rem); line-height: 0.95;
  letter-spacing: 0.02em;
}
.hero-title .comma { color: var(--gold); }
.hero-sub {
  font-family: var(--serif); font-style: italic; font-weight: 300;
  font-size: clamp(1.1rem, 3vw, 1.7rem); color: var(--ink-dim);
  margin-top: 22px; letter-spacing: 0.02em;
}
.hero-meta {
  margin-top: 40px; font-size: 13px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--ink-faint);
}
.scroll-cue {
  position: absolute; bottom: 32px; left: 50%; transform: translateX(-50%);
  z-index: 2; color: var(--ink-faint); font-size: 11px; letter-spacing: 0.3em;
  text-transform: uppercase; animation: bob 2.4s ease-in-out infinite;
  transition: opacity 0.6s ease;
}
.scroll-cue.hidden { opacity: 0; }
@keyframes bob { 0%,100% { transform: translate(-50%,0); } 50% { transform: translate(-50%,8px); } }

/* ---------- Thesis band ---------- */
.thesis {
  max-width: 760px; margin: 0 auto; padding: 14vh 24px 12vh;
  text-align: center;
}
.thesis p {
  font-family: var(--serif); font-weight: 300;
  font-size: clamp(1.5rem, 3.6vw, 2.4rem); line-height: 1.45;
  color: var(--ink); letter-spacing: 0.01em;
}
.thesis .small {
  font-family: var(--sans); font-size: 1.05rem; line-height: 1.75;
  color: var(--ink-dim); margin-top: 32px; letter-spacing: 0;
}
.thesis a, .watch-link a {
  color: var(--gold); text-decoration: none;
  border-bottom: 1px solid rgba(232, 198, 106, 0.4);
}
.thesis a:hover, .watch-link a:hover { border-bottom-color: var(--gold); }
.watch-link { margin-top: 22px; font-size: 0.9rem; letter-spacing: 0.12em; text-transform: uppercase; }

/* ---------- Chapters ---------- */
.chapter { position: relative; }
.chapter-stage {
  position: relative; height: 100vh; min-height: 600px;
  display: flex; align-items: flex-end; overflow: hidden;
}
.chapter-stage .veil {
  position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(180deg, rgba(5,7,13,0.55) 0%, rgba(5,7,13,0.15) 40%, rgba(5,7,13,0.85) 100%);
}
.stage-content {
  position: relative; z-index: 2; padding: 0 clamp(24px, 7vw, 110px) clamp(48px, 9vh, 96px);
  max-width: 1000px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.55), 0 2px 24px rgba(0,0,0,0.5);
}
.chapter-num {
  font-family: var(--serif); font-size: 1rem; letter-spacing: 0.3em;
  color: color-mix(in srgb, var(--accent, var(--gold)) 70%, #fff 30%);
  margin-bottom: 14px;
}
.chapter-num::before { content: ""; display: inline-block; width: 38px; height: 1px;
  background: var(--accent, var(--gold)); vertical-align: middle; margin-right: 14px; }
.chapter-title {
  font-family: var(--serif); font-weight: 300;
  font-size: clamp(2.6rem, 7vw, 5.5rem); line-height: 1; letter-spacing: 0.01em;
}
.chapter-era {
  font-size: 13px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-dim); margin-top: 18px;
}
.chapter-span {
  display: inline-block; margin-top: 10px; font-family: var(--serif);
  font-style: italic; font-size: 1.25rem; color: var(--gold);
}
.chapter-tagline {
  font-family: var(--serif); font-style: italic; font-weight: 300;
  font-size: clamp(1.2rem, 2.6vw, 1.7rem); color: var(--ink);
  margin-top: 20px; max-width: 620px;
}

/* reveal animation */
.reveal { opacity: 0; transform: translateY(28px); transition: opacity 1s ease, transform 1s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Chapter body / deep dive ---------- */
.chapter-body {
  background: var(--bg);
  padding: clamp(56px, 9vh, 110px) clamp(24px, 7vw, 110px);
  border-top: 1px solid var(--line);
}
.body-grid { max-width: 1180px; margin: 0 auto; display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr); gap: clamp(32px, 6vw, 80px); }
.cinematic-note {
  position: sticky; top: 80px; align-self: start;
}
.cinematic-note h4 {
  font-size: 11px; letter-spacing: 0.25em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 16px; font-weight: 600;
}
.cinematic-note p {
  font-family: var(--serif); font-size: clamp(1.3rem, 1.15rem + 0.45vw, 1.65rem); font-weight: 400;
  line-height: 1.6; color: var(--ink-read); font-style: italic;
}
.panels h4 {
  font-size: 11px; letter-spacing: 0.25em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: 28px; font-weight: 600;
}
.panel {
  border-top: 1px solid var(--line); padding: 26px 0;
  display: grid; grid-template-columns: 130px 1fr; gap: 24px;
}
.panel:last-child { border-bottom: 1px solid var(--line); }
.panel-date {
  font-family: var(--serif); font-size: 1.05rem; color: var(--gold);
  letter-spacing: 0.02em; padding-top: 2px;
}
.panel-name {
  font-family: var(--serif); font-size: clamp(1.5rem, 1.4rem + 0.3vw, 1.75rem); font-weight: 500;
  color: var(--ink); margin-bottom: 8px; line-height: 1.1;
}
.panel-body { color: var(--ink-read); font-size: clamp(1rem, 0.94rem + 0.2vw, 1.16rem); line-height: 1.75; max-width: 64ch; }

/* ---------- Deep-time scale section ---------- */
.scale-section {
  padding: clamp(64px, 12vh, 140px) clamp(24px, 7vw, 110px);
  background: linear-gradient(180deg, var(--bg) 0%, #070b16 100%);
  text-align: center;
}
.scale-section h2 {
  font-family: var(--serif); font-weight: 300; font-size: clamp(2rem, 5vw, 3.4rem);
  margin-bottom: 16px;
}
.scale-section .lede { max-width: 660px; margin: 0 auto 64px; color: var(--ink-dim); }
.scale-stack { max-width: 1100px; margin: 0 auto; text-align: left; }
.scale-row-head {
  display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px;
}
.scale-row-title {
  font-size: 11px; letter-spacing: 0.25em; text-transform: uppercase;
  color: var(--ink-dim); font-weight: 600;
}
.scale-row-zoom {
  font-family: var(--serif); font-style: italic; font-size: 1.05rem; color: var(--gold);
}
.scalebar {
  display: flex; height: 58px;
  border-radius: 8px; overflow: hidden; border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.07), 0 14px 40px rgba(0,0,0,0.45);
}
.scaleseg { position: relative; display: flex; align-items: center; justify-content: center;
  font-size: 11px; letter-spacing: 0.12em; color: rgba(255,255,255,0.88);
  text-transform: uppercase; overflow: hidden; white-space: nowrap;
  transition: filter 0.3s ease; }
.scaleseg:hover { filter: brightness(1.25); }
.scaleseg span { padding: 0 10px; text-shadow: 0 1px 3px rgba(0,0,0,0.7); }
.seg-cosmic { background: linear-gradient(90deg, #0e2342 0%, #1d4474 100%); }
.seg-earth  { background: linear-gradient(90deg, #1a5048 0%, #2a7c6d 100%); }
.seg-life, .seg-paleo { background: linear-gradient(90deg, #375f2d 0%, #4d823c 100%); }
.seg-meso   { background: linear-gradient(90deg, #6e3520 0%, #8f4c2f 100%); }
.seg-ceno   { background: linear-gradient(90deg, #7c5f26 0%, #9d7c36 100%); }
.seg-human, .seg-record {
  background: linear-gradient(90deg, var(--gold-deep) 0%, var(--gold) 100%);
  box-shadow: 0 0 16px rgba(232, 198, 106, 0.55);
}
.seg-forage { background: linear-gradient(90deg, #6e5524 0%, #8a6b2e 100%); }
.seg-farm   { background: linear-gradient(90deg, #a07c33 0%, #b8923f 100%); }
.scale-cap { margin: 12px 0 0; display: flex; justify-content: space-between; gap: 16px;
  font-size: 12px; color: var(--ink-faint); letter-spacing: 0.05em; }
.scale-cap span:last-child { white-space: nowrap; }
/* funnels — the last sliver of one line opens into the whole of the next */
.scale-funnel { height: 56px; margin: 10px 0; }
.funnel-life {
  clip-path: polygon(96.1% 0, 100% 0, 100% 100%, 0 100%);
  background: linear-gradient(180deg, rgba(77, 130, 60, 0.45), rgba(77, 130, 60, 0.05));
}
.funnel-human {
  clip-path: polygon(99.4% 0, 100% 0, 100% 100%, 0 100%);
  background: linear-gradient(180deg, rgba(232, 198, 106, 0.4), rgba(232, 198, 106, 0.04));
}
.scale-note { max-width: 720px; margin: 56px auto 0; font-family: var(--serif);
  font-style: italic; font-size: 1.25rem; color: var(--ink-dim); text-align: center; }

/* ---------- Infographic explorer ---------- */
.info-section {
  padding: clamp(64px, 12vh, 140px) clamp(24px, 7vw, 80px);
  background: #070b16; text-align: center;
}
.info-section h2 {
  font-family: var(--serif); font-weight: 300; font-size: clamp(2rem, 5vw, 3.4rem);
  margin-bottom: 14px;
}
.info-section .lede { max-width: 640px; margin: 0 auto 44px; color: var(--ink-dim); }
.info-frame {
  max-width: 760px; margin: 0 auto; border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; cursor: zoom-in;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6); position: relative;
}
.info-frame img { width: 100%; display: block; }
.info-frame .hint {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
  background: rgba(5,7,13,0.8); padding: 6px 14px; border-radius: 20px; color: var(--ink-dim);
}

/* lightbox */
#lightbox {
  position: fixed; inset: 0; z-index: 200; background: rgba(2,3,7,0.96);
  display: none; align-items: center; justify-content: center; cursor: zoom-out;
  padding: 20px; overflow: auto;
}
#lightbox.open { display: flex; }
body.lightbox-open { overflow: hidden; }
#lightbox img { max-width: none; width: min(1400px, 180vw); height: auto; border-radius: 4px; }

/* ---------- Watch / film section ---------- */
.watch-section {
  padding: clamp(64px, 12vh, 140px) clamp(24px, 7vw, 110px);
  text-align: center; background: var(--bg);
}
.watch-section h2 { font-family: var(--serif); font-weight: 300; font-size: clamp(2rem,5vw,3.4rem); margin-bottom: 14px; }
.watch-section .lede { max-width: 620px; margin: 0 auto 44px; color: var(--ink-dim); }
.video-wrap {
  max-width: 900px; margin: 0 auto; aspect-ratio: 16/9; border-radius: 10px;
  overflow: hidden; border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(0,0,0,0.6);
}
.video-wrap iframe { width: 100%; height: 100%; border: 0; }

/* ---------- Closing ---------- */
.closing { position: relative; height: 100vh; min-height: 600px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; text-align: center; }
.closing .veil { position: absolute; inset: 0; z-index: 1;
  background: radial-gradient(ellipse at center, rgba(5,7,13,0.2), rgba(5,7,13,0.85)); }
.closing-inner { position: relative; z-index: 2; padding: 0 24px; margin-bottom: 30vh; }
.closing-motto { text-shadow: 0 2px 30px rgba(0,0,0,0.85); }
.closing-motto {
  font-family: var(--serif); font-weight: 300; font-style: italic;
  font-size: clamp(1.6rem, 4.5vw, 3rem); line-height: 1.4; letter-spacing: 0.01em;
}
.closing-studio { margin-top: 48px; font-size: 12px; letter-spacing: 0.4em;
  text-transform: uppercase; color: var(--gold); }
.colophon {
  background: var(--bg); padding: 64px 24px 80px; text-align: center;
  border-top: 1px solid var(--line); color: var(--ink-faint); font-size: 13px; line-height: 1.8;
}
.colophon a { color: var(--ink-dim); text-decoration: none; border-bottom: 1px solid var(--line); }
.colophon a:hover { color: var(--gold); }

/* ---------- Responsive ---------- */
@media (min-width: 1500px) {
  .body-grid { max-width: 1320px; }
  .panel { grid-template-columns: 150px 1fr; }
}
@media (max-width: 820px) {
  .body-grid { grid-template-columns: 1fr; gap: 36px; }
  .cinematic-note { position: static; }
  .panel { grid-template-columns: 90px 1fr; gap: 14px; }
  #rail { display: none; }
  .scalebar { height: 44px; }
  .scaleseg span { display: none; }
  .scale-funnel { height: 40px; }
  .scale-cap { font-size: 10.5px; }
  .scale-row-zoom { font-size: 0.95rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { transition: none; opacity: 1; transform: none; }
  .scroll-cue { animation: none; }
}
