/* ==========================================================================
   THE LONG WAY ROUND — a history of Doctor Who
   Single-file static page. No external requests (Cloudflare Pages friendly).
   ========================================================================== */

/* --- 1. TOKENS ---------------------------------------------------------- */

:root {
  /* Dark is the default ground: the vortex is a dark place. */
  --void:      #06080E;
  --void-2:    #0A0E17;
  --panel:     #0C121C;
  --panel-2:   #111927;
  --hair:      #1D2735;
  --hair-soft: #161E2A;

  --ink:       #DFE6EF;
  --ink-dim:   #AEBBCA;
  --muted:     #7F8DA0;

  --tardis:    #3E86C8;   /* structural blue */
  --vortex:    #E9A13B;   /* the accent. Used sparingly. */
  --glass:     #9FD4EC;   /* TARDIS lamp */

  --era-mix:   #FFFFFF;   /* era hues lift toward white on dark ground */
  --era-amt:   14%;       /* markers: graphics, 3:1 */
  --era-ink:   34%;       /* small type: AA, so it mixes harder */

  --vfx-far:   #1E4E86;
  --vfx-near:  #E9A13B;
  --vfx-op:    0.55;
  --logo-glow: 1;
  --wash:      0.86;

  --shell:     min(1180px, 100% - 3rem);
  --gutter:    7.5rem;

  --f-display: "Futura", "Avenir Next", "Avenir", "Century Gothic",
               "Trebuchet MS", ui-sans-serif, system-ui, sans-serif;
  --f-body:    "Iowan Old Style", "Palatino Linotype", "Book Antiqua",
               Palatino, Georgia, ui-serif, serif;
  --f-data:    ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
               "Liberation Mono", monospace;

  --ease: cubic-bezier(.2, .7, .3, 1);
}

@media (prefers-color-scheme: light) {
  :root {
    --void:      #EEF2F7;
    --void-2:    #E6ECF3;
    --panel:     #FFFFFF;
    --panel-2:   #F5F8FC;
    --hair:      #CBD5E2;
    --hair-soft: #DDE5EF;

    --ink:       #101722;
    --ink-dim:   #33404F;
    --muted:     #5D6B7C;

    --tardis:    #1B5391;
    --vortex:    #8A5A11;
    --glass:     #1F6E8E;

    --era-mix:   #0B1018;
    --era-amt:   30%;
    --era-ink:   58%;

    --vfx-far:   #7FA5CC;
    --vfx-near:  #C9A063;
    --vfx-op:    0.30;
    --logo-glow: 0;
    --wash:      0.74;
  }
}

/* The viewer's own toggle stamps data-theme on <html>; it must win both ways. */
:root[data-theme="dark"] {
  --void:#06080E; --void-2:#0A0E17; --panel:#0C121C; --panel-2:#111927;
  --hair:#1D2735; --hair-soft:#161E2A;
  --ink:#DFE6EF; --ink-dim:#AEBBCA; --muted:#7F8DA0;
  --tardis:#3E86C8; --vortex:#E9A13B; --glass:#9FD4EC;
  --era-mix:#FFFFFF; --era-amt:14%; --era-ink:34%;
  --vfx-far:#1E4E86; --vfx-near:#E9A13B; --vfx-op:0.55; --logo-glow:1; --wash:0.86;
}
:root[data-theme="light"] {
  --void:#EEF2F7; --void-2:#E6ECF3; --panel:#FFFFFF; --panel-2:#F5F8FC;
  --hair:#CBD5E2; --hair-soft:#DDE5EF;
  --ink:#101722; --ink-dim:#33404F; --muted:#5D6B7C;
  --tardis:#1B5391; --vortex:#8A5A11; --glass:#1F6E8E;
  --era-mix:#0B1018; --era-amt:30%; --era-ink:58%;
  --vfx-far:#7FA5CC; --vfx-near:#C9A063; --vfx-op:0.30; --logo-glow:0; --wash:0.74;
}

/* --- 2. BASE ------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

body {
  margin: 0;
  background: var(--void);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 17px;
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--f-display);
  font-weight: 600;
  text-wrap: balance;
  margin: 0;
}

p { margin: 0 0 .85em; }
p:last-child { margin-bottom: 0; }

a { color: var(--glass); }

:focus-visible {
  outline: 2px solid var(--vortex);
  outline-offset: 3px;
  border-radius: 2px;
}

.shell { width: var(--shell); margin-inline: auto; }

/* The vortex stays vivid behind the hero, but prose needs a quiet ground.
   A full-bleed wash scoped to the reading area only — it cannot sit behind
   .page itself, which is its own stacking context, so it lands above the
   canvas and below the text. */
main.shell { position: relative; }
main.shell::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset-block: -3rem 0;
  inset-inline: calc(50% - 50vw);
  background: var(--void);
  opacity: var(--wash);
  pointer-events: none;
}

/* --- 3. THE VORTEX ------------------------------------------------------ */

#vortex {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: var(--vfx-op);
  pointer-events: none;
}

/* A wash that keeps text off the brightest part of the tunnel. */
.veil {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% 42%, transparent 0%, var(--void) 72%);
}

/* The full-bleed washes size themselves with calc(50% - 50vw). `vw` counts
   the scrollbar, so they overrun the content box by half its width and the
   page scrolls ~8px sideways. `clip` trims that without creating a scroll
   container, so the sticky register still sticks to the viewport —
   `overflow: hidden` here would not be safe. */
.page {
  position: relative;
  z-index: 2;
  overflow-x: clip;
}

/* --- 4. HERO ------------------------------------------------------------ */

.hero {
  min-height: min(92svh, 780px);
  padding-block: clamp(4rem, 12vh, 7rem) 4rem;
  display: grid;
  place-items: center;
  text-align: center;
}

.hero-inner { position: relative; display: inline-block; padding: 1rem 2rem; }

/* The mark: logotype plus the 1973 diamond, which centres on the type
   rather than on the whole hero block. */
.mark {
  position: relative;
  display: grid;
  place-items: center;
  padding: clamp(3rem, 9vw, 6rem) clamp(2rem, 8vw, 6rem);
}

.diamond {
  position: absolute;
  inset: 50% auto auto 50%;
  width: min(21rem, 56vw);
  aspect-ratio: 1;
  translate: -50% -50%;
  rotate: 45deg;
  border: 1px solid color-mix(in oklab, var(--tardis) 60%, transparent);
  pointer-events: none;
}
.diamond::before {
  content: "";
  position: absolute;
  inset: .9rem;
  border: 1px solid color-mix(in oklab, var(--tardis) 24%, transparent);
}

.logotype {
  position: relative;
  grid-area: 1 / 1;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(3rem, 13vw, 8.5rem);
  line-height: .82;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink);
  transform: perspective(900px) rotateY(-9deg) skewX(-7deg);
  text-shadow: 0 0 40px color-mix(in oklab, var(--tardis)
                 calc(45% * var(--logo-glow)), transparent);
}
.logotype span { display: block; }
.logotype .who {
  color: var(--glass);
  letter-spacing: .16em;
  text-shadow: 0 0 34px color-mix(in oklab, var(--glass)
                 calc(30% * var(--logo-glow)), transparent);
}

.hero-kicker {
  font-family: var(--f-data);
  font-size: .7rem;
  letter-spacing: .42em;
  text-transform: uppercase;
  color: var(--vortex);
  margin-bottom: 0;
}

.hero-sub {
  position: relative;
  margin: 2.6rem auto 0;
  max-width: 46ch;
  font-size: 1.06rem;
  color: var(--ink-dim);
  text-wrap: pretty;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 2.75rem;
  margin-top: 2.75rem;
  font-family: var(--f-data);
  font-size: .72rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.hero-stats b {
  display: block;
  font-size: 1.5rem;
  letter-spacing: .02em;
  color: var(--ink);
  font-weight: 600;
}

/* --- 5. STICKY REGISTER ------------------------------------------------- */

.register {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in oklab, var(--void) 88%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  border-block: 1px solid var(--hair);
}

.register-in {
  width: var(--shell);
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-height: 3.5rem;
}

.readout {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: .6rem;
  font-family: var(--f-data);
  font-variant-numeric: tabular-nums;
}
.readout-year {
  font-size: 1.1rem;
  color: var(--vortex);
  letter-spacing: .04em;
}
.readout-era {
  font-size: .66rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

/* Fades at both ends so a clipped chip reads as "scrolls" and not "broken". */
.chips {
  display: flex;
  gap: .35rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding: .5rem 0;
  margin-left: auto;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 1.5rem,
                                             #000 calc(100% - 1.5rem), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 1.5rem,
                                     #000 calc(100% - 1.5rem), transparent);
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  font-family: var(--f-data);
  font-size: .63rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding: .4rem .6rem;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: color .18s var(--ease), border-color .18s var(--ease);
}
.chip:hover { color: var(--ink); }
.chip[aria-current="true"] {
  color: var(--ink);
  border-color: color-mix(in oklab, var(--vortex) 60%, transparent);
}

/* --- 6. ERAS ------------------------------------------------------------ */

.era {
  --era-c:   color-mix(in oklab, var(--era) calc(100% - var(--era-amt)), var(--era-mix));
  --era-txt: color-mix(in oklab, var(--era) calc(100% - var(--era-ink)), var(--era-mix));
  padding-top: 4.5rem;
  scroll-margin-top: 4rem;
}

/* Recomputed here so a standalone head (the roster) gets an era colour too. */
.era-head {
  --era-c:   color-mix(in oklab, var(--era, var(--vortex))
               calc(100% - var(--era-amt)), var(--era-mix));
  --era-txt: color-mix(in oklab, var(--era, var(--vortex))
               calc(100% - var(--era-ink)), var(--era-mix));
  display: grid;
  grid-template-columns: var(--gutter) 1fr;
  gap: 0 2rem;
  align-items: end;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--hair);
  margin-bottom: .5rem;
}

.era-span {
  font-family: var(--f-data);
  font-size: .74rem;
  letter-spacing: .1em;
  color: var(--era-txt);
  font-variant-numeric: tabular-nums;
  padding-bottom: .35rem;
}

.era-title {
  font-size: clamp(1.6rem, 4.4vw, 2.5rem);
  letter-spacing: .04em;
  text-transform: uppercase;
  line-height: 1.05;
}

.era-who {
  display: block;
  font-family: var(--f-data);
  font-size: .68rem;
  font-weight: 400;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: .7rem;
}

/* --- 7. EVENTS: the spine ----------------------------------------------- */

.ev {
  --era-c:   color-mix(in oklab, var(--era) calc(100% - var(--era-amt)), var(--era-mix));
  --era-txt: color-mix(in oklab, var(--era) calc(100% - var(--era-ink)), var(--era-mix));
  display: grid;
  grid-template-columns: var(--gutter) 1fr;
  gap: 0 2rem;
  position: relative;
}

.ev-date {
  text-align: right;
  padding: 1.9rem 0 0;
  font-family: var(--f-data);
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}
.ev-year {
  display: block;
  font-size: .96rem;
  color: var(--ink-dim);
  letter-spacing: .02em;
}
.ev-day {
  display: block;
  font-size: .64rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.ev-body {
  position: relative;
  border-left: 1px solid var(--hair);
  padding: 1.75rem 0 1.75rem 2.25rem;
}

/* The node: a diamond, per the logo. */
.ev-body::before {
  content: "";
  position: absolute;
  left: 0;
  top: 2.15rem;
  width: 9px;
  height: 9px;
  translate: -50% 0;
  rotate: 45deg;
  background: var(--void);
  border: 1px solid var(--era-c);
  transition: background-color .2s var(--ease);
}
.ev:hover .ev-body::before { background: var(--era-c); }

.ev.is-major .ev-body::before {
  width: 13px;
  height: 13px;
  top: 2rem;
  background: var(--era-c);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--era-c) 18%, transparent);
}

.ev-title {
  font-size: 1.16rem;
  letter-spacing: .012em;
  color: var(--ink);
  margin-bottom: .5rem;
}
.ev.is-major .ev-title { font-size: 1.4rem; }

.ev-tag {
  display: inline-block;
  font-family: var(--f-data);
  font-size: .6rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--era-txt);
  margin-bottom: .55rem;
}

.ev-body p { color: var(--ink-dim); max-width: 68ch; }

/* The mono footnote — a hard number, a record, a piece of trivia. */
.ev-note {
  font-family: var(--f-data);
  font-size: .74rem;
  line-height: 1.6;
  letter-spacing: .01em;
  color: var(--muted);
  border-left: 2px solid color-mix(in oklab, var(--era-c) 45%, transparent);
  padding-left: .8rem;
  margin-top: .9rem;
  max-width: 62ch;
  font-variant-numeric: tabular-nums;
}
.ev-note b { color: var(--ink-dim); font-weight: 400; }

/* --- 8. INTERLUDE PANELS ------------------------------------------------ */

.interlude {
  margin: 5rem 0 1rem;
  padding: 2.5rem clamp(1.5rem, 4vw, 3rem);
  background: var(--panel);
  border: 1px solid var(--hair);
  position: relative;
  overflow: hidden;
  text-align: center;
}

/* TARDIS-interior roundels, very faint. */
.interlude::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .5;
  background-image: radial-gradient(
    circle at center,
    transparent 0 12px,
    color-mix(in oklab, var(--tardis) 16%, transparent) 12px 13px,
    transparent 13px
  );
  background-size: 46px 46px;
  -webkit-mask-image: linear-gradient(90deg, #000, transparent 34%,
                                              transparent 66%, #000);
  mask-image: linear-gradient(90deg, #000, transparent 34%,
                                     transparent 66%, #000);
}

.interlude > * { position: relative; z-index: 1; }

.interlude h2 {
  font-size: 1.35rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}
.interlude p {
  color: var(--ink-dim);
  max-width: 62ch;
  margin-inline: auto;
}

.interlude .lede {
  font-family: var(--f-data);
  font-size: .64rem;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--vortex);
  margin-bottom: .9rem;
}

/* --- 9. ROSTER ---------------------------------------------------------- */

.roster {
  padding-top: 5.5rem;
  scroll-margin-top: 4rem;
}

.roster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1px;
  background: var(--hair-soft);
  border: 1px solid var(--hair-soft);
  margin-top: 2rem;
}

.doc {
  --doc-c: color-mix(in oklab, var(--era) calc(100% - var(--era-ink)), var(--era-mix));
  background: var(--panel);
  padding: 1.4rem 1.35rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
  transition: background-color .2s var(--ease);
}
.doc:hover { background: var(--panel-2); }

.doc-n {
  font-family: var(--f-data);
  font-size: .62rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--doc-c);
}
.doc-actor {
  font-family: var(--f-display);
  font-size: 1.1rem;
  letter-spacing: .02em;
  color: var(--ink);
}
.doc-years {
  font-family: var(--f-data);
  font-size: .74rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.doc-note {
  font-size: .87rem;
  line-height: 1.5;
  color: var(--ink-dim);
  margin-top: .5rem;
}

/* --- 10. FOOTER --------------------------------------------------------- */

.foot {
  position: relative;
  width: var(--shell);
  margin: 6rem auto 0;
  border-top: 1px solid var(--hair);
  padding: 3rem 0 4.5rem;
  color: var(--muted);
  font-size: .9rem;
  text-align: center;
}

/* Same full-bleed wash main gets, extended up through the 6rem margin so
   the vortex does not reappear in the gap between them. */
.foot::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset-block: -6rem 0;
  inset-inline: calc(50% - 50vw);
  background: var(--void);
  opacity: var(--wash);
  pointer-events: none;
}

.foot p {
  max-width: 70ch;
  margin-inline: auto;
}
.foot .sig {
  font-family: var(--f-data);
  font-size: .64rem;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--vortex);
  margin-bottom: 1rem;
}

/* --- 11. NARROW --------------------------------------------------------- */

@media (max-width: 760px) {
  :root { --shell: min(1180px, 100% - 2rem); --gutter: 0; }
  body { font-size: 16px; }

  .era-head,
  .ev { grid-template-columns: 1fr; gap: 0; }

  .era-head { padding-left: 1.5rem; }
  .era-span { text-align: left; padding-bottom: .5rem; }

  .ev-date {
    text-align: left;
    padding: 1.6rem 0 0 1.5rem;
    border-left: 1px solid var(--hair);
    display: flex;
    align-items: baseline;
    gap: .6rem;
  }
  .ev-year, .ev-day { display: inline; }

  .ev-body {
    padding: .35rem 0 1.6rem 1.5rem;
  }
  .ev-body::before { top: -1.5rem; }
  .ev.is-major .ev-body::before { top: -1.65rem; }

  .register-in { gap: .85rem; min-height: 3.1rem; }
  .readout-era { display: none; }
  .hero { min-height: auto; padding-block: 2.5rem 2.5rem; }
  .hero-inner { padding: 0 .5rem; }
  .mark { padding: 2rem .5rem 1.5rem; }

  /* The diamond can't win here: sized to clear the viewport top it ends up
     narrower than the word it is supposed to frame. The logotype over the
     vortex carries the hero on its own. */
  .diamond { display: none; }
  .hero-stats { gap: 1.25rem 1.75rem; }
}

/* --- 12. SITE NAV — three timelines, one shell ------------------------- */

.sitenav {
  position: relative;
  z-index: 3;
  border-bottom: 1px solid var(--hair-soft);
}

.sitenav-in {
  width: var(--shell);
  margin-inline: auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .25rem 1.5rem;
  min-height: 3.25rem;
  padding-block: .5rem;
}

.sitemark {
  font-family: var(--f-display);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.sitemark span { color: var(--glass); }

.sitenav-links {
  display: flex;
  gap: .25rem;
  margin-left: auto;
  flex-wrap: wrap;
}

.sitenav-links a {
  font-family: var(--f-data);
  font-size: .66rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding: .45rem .7rem;
  border-bottom: 2px solid transparent;
  transition: color .18s var(--ease), border-color .18s var(--ease);
}
.sitenav-links a:hover { color: var(--ink); }
.sitenav-links a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--vortex);
}

/* --- 13. SUB-PAGE HERO ------------------------------------------------- */
/* The full-bleed logotype belongs to the front page only. A sibling
   timeline opens on its title and a standfirst, over the same vortex. */

.subhero {
  padding: clamp(3.5rem, 10vh, 6rem) 0 clamp(2.5rem, 6vh, 4rem);
}

.subhero-in {
  width: var(--shell);
  margin-inline: auto;
  text-align: center;
}

.subhero .hero-kicker { margin-bottom: 1.1rem; }

.subhero h1 {
  font-size: clamp(2.4rem, 8vw, 5rem);
  line-height: .95;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink);
  max-width: 16ch;
  margin-inline: auto;
}
.subhero h1 em {
  font-style: normal;
  color: var(--glass);
  display: block;
}

.subhero .standfirst {
  margin: 1.75rem auto 0;
  max-width: 58ch;
  font-size: 1.06rem;
  color: var(--ink-dim);
  text-wrap: pretty;
}

/* --- 14. LEGEND -------------------------------------------------------- */
/* On the adversaries timeline the axis is time and the colour is lineage,
   so the colour needs a key. */

.legendbox {
  width: var(--shell);
  margin-inline: auto;
}

.legend {
  padding: 1.5rem 0 .25rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem 1.75rem;
}

.legend-item {
  --key-c: color-mix(in oklab, var(--era) calc(100% - var(--era-ink)), var(--era-mix));
  display: flex;
  align-items: center;
  gap: .55rem;
  font-family: var(--f-data);
  font-size: .66rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--key-c);
}

.legend-item::before {
  content: "";
  width: 9px;
  height: 9px;
  rotate: 45deg;
  flex: none;
  background: color-mix(in oklab, var(--era) calc(100% - var(--era-amt)), var(--era-mix));
}

.legend-note {
  margin: .5rem auto 0;
  font-size: .9rem;
  color: var(--muted);
  max-width: 70ch;
  text-align: center;
}

/* --- 15. FOOTER NAV ---------------------------------------------------- */

.foot-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .75rem 2rem;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--hair-soft);
}

.foot-nav a {
  font-family: var(--f-data);
  font-size: .7rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in oklab, var(--glass) 40%, transparent);
  padding-bottom: .2rem;
  transition: color .18s var(--ease), border-color .18s var(--ease);
}
.foot-nav a:hover {
  color: var(--glass);
  border-bottom-color: var(--glass);
}

@media (max-width: 760px) {
  /* Narrow viewports concentrate the tunnel into the same column the text
     occupies, so the rings get damped rather than the type getting a box. */
  :root { --vfx-op: 0.34; }
  @media (prefers-color-scheme: light) { :root { --vfx-op: 0.18; } }
  :root[data-theme="dark"]  { --vfx-op: 0.34; }
  :root[data-theme="light"] { --vfx-op: 0.18; }

  .sitenav-links { margin-left: 0; }
  .subhero { padding-top: 2.5rem; }
  .legend { gap: .4rem 1.25rem; }
}

/* --- 16. FIGURES ------------------------------------------------------- */
/* Charts sit in the timeline as evidence, not decoration, so they carry the
   same gutter/spine geometry as an entry and state their own provenance. */

.figure {
  display: grid;
  grid-template-columns: var(--gutter) 1fr;
  gap: 0 2rem;
  margin: 1rem 0 2.5rem;
}

.figure-kicker {
  text-align: right;
  padding-top: 1.9rem;
  font-family: var(--f-data);
  font-size: .64rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.figure-body {
  border-left: 1px solid var(--hair);
  padding: 1.75rem 0 0 2.25rem;
  min-width: 0;
}

.figure-title {
  font-size: 1.16rem;
  letter-spacing: .012em;
  color: var(--ink);
  margin-bottom: .4rem;
}

.figure-lede {
  font-size: .95rem;
  color: var(--ink-dim);
  max-width: 62ch;
  margin-bottom: 1.25rem;
}

/* Wide graphics scroll inside their own box; the page never does. */
.figure-scroll {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding-bottom: .5rem;
}

.figure-note {
  font-family: var(--f-data);
  font-size: .68rem;
  line-height: 1.65;
  color: var(--muted);
  border-left: 2px solid color-mix(in oklab, var(--vortex) 40%, transparent);
  padding-left: .8rem;
  margin-top: 1.1rem;
  max-width: 62ch;
  font-variant-numeric: tabular-nums;
}

.figure-key {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem 1.5rem;
  margin-top: .9rem;
  font-family: var(--f-data);
  font-size: .64rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.figure-key span { display: flex; align-items: center; gap: .5rem; }
.figure-key i {
  width: 22px; height: 3px; flex: none; border-radius: 2px;
  background: var(--glass); font-style: normal;
}
.figure-key i.dot {
  width: 9px; height: 9px; rotate: 45deg; border-radius: 0;
  background: var(--vortex);
}
/* These two key the episode grid, so they take the cell's shape rather than
   the line-chart bar's. The surviving colour is dark by design, so the swatch
   needs an outline to be visible at this size. */
.figure-key i.gone,
.figure-key i.kept {
  width: 9px;
  height: 15px;
  border-radius: 1px;
}
.figure-key i.gone { background: color-mix(in oklab, var(--vortex) 85%, var(--ink)); }
.figure-key i.kept {
  background: var(--hair);
  outline: 1px solid color-mix(in oklab, var(--ink) 22%, transparent);
  outline-offset: -1px;
}

/* --- 17. THE AUDIENCE CHART -------------------------------------------- */

.chart { display: block; width: 100%; min-width: 660px; height: auto; }

.chart .grid      { stroke: var(--hair); stroke-width: 1; }
.chart .axis      { fill: var(--muted); font-family: var(--f-data); font-size: 11px; }
.chart .axis-lo   { fill: var(--muted); font-family: var(--f-data); font-size: 10px; letter-spacing: .08em; }
.chart .area      { fill: color-mix(in oklab, var(--glass) 16%, transparent); }
.chart .line      { fill: none; stroke: var(--glass); stroke-width: 2; stroke-linejoin: round; }
.chart .peak      { fill: var(--vortex); }
.chart .peak-lab  { fill: var(--ink-dim); font-family: var(--f-data); font-size: 10.5px; }
.chart .gap-band  { fill: color-mix(in oklab, var(--ink) 6%, transparent); }
.chart .gap-lab   { fill: var(--muted); font-family: var(--f-data); font-size: 11px; letter-spacing: .14em; }
.chart .rule      { stroke: color-mix(in oklab, var(--vortex) 55%, transparent); stroke-width: 1; stroke-dasharray: 3 3; }

/* --- 18. MISSING EPISODES ---------------------------------------------- */

.epgrid { display: flex; flex-direction: column; gap: .55rem; min-width: 560px; }

.eprow { display: grid; grid-template-columns: 8.5rem 1fr auto; gap: 0 .9rem; align-items: center; }

.eprow-label {
  font-family: var(--f-data);
  font-size: .66rem;
  letter-spacing: .06em;
  color: var(--ink-dim);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Gap between serials is wider than between episodes, so whole lost serials
   read as blocks rather than scattered cells. */
.eprow-cells { display: flex; gap: 7px; flex-wrap: nowrap; }
.epserial { display: flex; gap: 2px; }

.eprow-cells b {
  width: 9px; height: 16px; flex: none; border-radius: 1px;
  background: var(--hair);
}
.eprow-cells b.gone {
  background: color-mix(in oklab, var(--vortex) 85%, var(--ink));
}

.eprow-count {
  font-family: var(--f-data);
  font-size: .66rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.eprow-count b { color: var(--vortex); font-weight: 400; }

/* --- 19. TENURE BARS ---------------------------------------------------- */

.tenure { display: flex; flex-direction: column; gap: .4rem; margin-top: 2rem; }

.tenure-row {
  --bar: color-mix(in oklab, var(--era) calc(100% - var(--era-amt)), var(--era-mix));
  display: grid;
  grid-template-columns: 11rem 1fr 4.5rem;
  gap: 0 1rem;
  align-items: center;
}

.tenure-name {
  font-family: var(--f-data);
  font-size: .68rem;
  letter-spacing: .06em;
  color: var(--ink-dim);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* .tenure-track is blockified as a grid item, but .tenure-fill is a span in
   a non-flex parent — left inline, a percentage width does nothing. */
.tenure-track {
  display: block;
  height: 14px;
  background: color-mix(in oklab, var(--hair) 55%, transparent);
}
.tenure-fill {
  display: block;
  height: 100%;
  background: var(--bar);
}

.tenure-fig {
  font-family: var(--f-data);
  font-size: .66rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* --- 20. PULL QUOTES ---------------------------------------------------- */
/* Breaks the column without inventing content: every one is a line already
   argued in the surrounding entries. */

.pull {
  grid-column: 1 / -1;
  margin: 2.25rem 0 2.5rem;
  padding: 0 clamp(1rem, 6vw, 5rem);
  text-align: center;
}

.pull q {
  quotes: none;
  display: block;
  font-family: var(--f-display);
  font-size: clamp(1.3rem, 2.7vw, 1.9rem);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: .01em;
  color: var(--ink);
  text-wrap: balance;
}

.pull cite {
  display: block;
  margin-top: .9rem;
  font-family: var(--f-data);
  font-style: normal;
  font-size: .64rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--vortex);
}

@media (max-width: 760px) {
  .figure { grid-template-columns: 1fr; gap: 0; }
  .figure-kicker { text-align: left; padding: 1.6rem 0 0 1.5rem; border-left: 1px solid var(--hair); }
  .figure-body { padding: .35rem 0 0 1.5rem; }
  .tenure-row { grid-template-columns: 7rem 1fr 3.6rem; }
  .pull { padding: 0; }
}
