/* =====================================================================
   Lineage V2  ·  Stylesheet
   --------------------------------------------------------------------
   Dark vintage idiom. Full-palette color strategy (four named lineage
   roles plus gold). Per-frame motion lives in JS; CSS transitions are
   reserved for discrete state changes (active node, map-inset slide).
   ===================================================================== */

/* =========================== 1. Tokens ============================== */
:root {
  /* Dark grounds — warm tint, never #000 */
  --bg-0:  oklch(15% 0.012 65);
  --bg-1:  oklch(19% 0.014 65);
  --bg-2:  oklch(24% 0.016 65);
  --bg-3:  oklch(30% 0.018 65);

  /* Paper tints — never #fff */
  --paper:      oklch(92% 0.024 80);
  --paper-soft: oklch(78% 0.020 78);
  --faint:      oklch(58% 0.018 75);

  /* Lineage roles (full palette) */
  --c-barbeau:  oklch(64% 0.105 145);
  --c-mongeau:  oklch(55% 0.090 320);
  --c-betourne: oklch(70% 0.130  65);
  --c-heppell:  oklch(63% 0.085 240);

  /* Gold accent — convergence, anchor, ruler accent, world events */
  --c-gold:      oklch(74% 0.130 80);
  --c-gold-soft: oklch(64% 0.080 80);
  /* World events — cool silver, deliberately NOT a warm family hue */
  --c-world:      oklch(83% 0.030 235);
  --c-world-soft: oklch(68% 0.026 235);

  /* Geometry */
  --pad:      24px;
  --pad-tight: 14px;
  --pad-loose: 36px;
  --radius:    4px;
  --radius-lg: 10px;

  /* Type */
  --serif: 'Georgia', 'Iowan Old Style', 'Cambria', serif;
  --sans:  -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', system-ui, sans-serif;
  --mono:  'JetBrains Mono', 'SF Mono', Menlo, monospace;

  /* Motion (only CSS transitions live here; per-frame JS doesn't read these) */
  --easing-out: cubic-bezier(0.16, 1, 0.30, 1);
  --easing-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 240ms;
  --dur-med:  420ms;
  --dur-slow: 700ms;
}

/* ========================== 2. Reset / base ========================= */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--paper);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

a {
  color: var(--c-gold);
  text-decoration: none;
  border-bottom: 1px solid rgba(212, 160, 74, 0.35);
  transition: border-color var(--dur-fast) var(--easing-out);
}

a:hover, a:focus-visible {
  border-bottom-color: var(--c-gold);
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: none;
  border: 0;
}

/* ========================== 3. Page shell ===========================
   Two-column grid: sidebar fixed-width on the left, content stack on
   the right. This keeps the SVG canvas and the stage frame sharing a
   visual centre, so focused content lands in the middle of the frame. */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "sidebar topbar"
    "sidebar stage"
    "sidebar transport";
  height: 100vh;
  width: 100vw;
}
.topbar    { grid-area: topbar; }
.stage     { grid-area: stage; }
.transport { grid-area: transport; }
.sidebar   { grid-area: sidebar; }

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: var(--pad-tight) var(--pad);
  border-bottom: 1px solid rgba(243, 231, 204, 0.08);
  background: rgba(34, 29, 20, 0.92);
}

.topbar .brand {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--paper);
}

.topbar .brand em { font-style: italic; color: var(--c-gold-soft); }

.topbar .legend {
  display: flex;
  gap: 18px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--paper-soft);
}

.topbar .legend .swatch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.topbar .legend .swatch::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--c, var(--paper-soft));
}

.stage {
  position: relative;
  overflow: hidden;
  background: var(--bg-0);
}

/* ============================ 4. Tree ============================== */
.tree-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.tree-ground {
  fill: #1a160f;          /* hex fallback for browsers that drop oklch() in SVG fill */
  fill: #1a160f;
  fill: var(--bg-0);
}

.tree-frame-outer,
.tree-frame-inner {
  stroke: rgba(170, 133, 74, 0.28);
  stroke-width: 1;
}

.tree-flourish {
  stroke: rgba(155, 168, 190, 0.5);
  stroke-width: 1;
}

/* Line headers */
.tree-header {
  pointer-events: none;
}

.tree-header-rule {
  stroke: #c6b694;
 stroke: var(--lc, var(--paper-soft));
  stroke-width: 1;
  opacity: 0.7;
}

.tree-header-name {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  font-weight: 500;
  fill: #f3e7cc;
  fill: var(--paper);
  letter-spacing: 0.01em;
}

.tree-header-origin {
  font-family: var(--sans);
  font-size: 10.5px;
  fill: #c6b694;
  fill: var(--paper-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Edges — drawn via stroke-dashoffset from JS each frame.
   NEVER put a transition on stroke-dashoffset; it would freeze. */
.tree-edge {
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  opacity: 0;
}

.tree-edge-candidate {
  stroke-dasharray: 6 5;   /* dashed style for candidate links */
  stroke-width: 1.25;
  opacity: 0;
  /* NOTE: JS overrides stroke-dasharray with the path length to drive
     the draw animation. The dashed effect is achieved by the
     candidate-edge styling carrying lighter color via the opacity rule
     below in .tree-edge-candidate */
}

/* lighter color for candidate edges, since the dash pattern is taken
   over by the draw animation */
.tree-edge-candidate {
  filter: opacity(0.55);
}

/* Nodes */
.tree-node { pointer-events: none; }

.tree-node-halo {
  fill: #d4a04a;
 fill: var(--lc, var(--c-gold));
  filter: blur(8px);
  opacity: 0;        /* JS drives the pulse */
}

.tree-node-card {
  fill: #2c251a;
  fill: var(--bg-2);
  stroke: #c6b694;
 stroke: var(--lc, var(--paper-soft));
  stroke-width: 1;
  filter: url(#t-shadow);
  /* Discrete state change only: when active, lift to bg-3 */
  transition: fill var(--dur-fast) var(--easing-out);
}

.tree-node.is-active .tree-node-card {
  fill: #3a3122;
  fill: var(--bg-3);
  stroke: #d4a04a;
  stroke: var(--c-gold);
  stroke-width: 1.5;
}

.tree-node-dot {
  fill: #f3e7cc;
 fill: var(--lc, var(--paper));
}

.tree-node-name {
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 500;
  fill: #f3e7cc;
  fill: var(--paper);
  letter-spacing: 0.005em;
}

.tree-node-sub {
  font-family: var(--sans);
  font-size: 10.5px;
  fill: #c6b694;
  fill: var(--paper-soft);
  letter-spacing: 0.02em;
}

.tree-node-star {
  font-family: var(--sans);
  font-size: 14px;
  fill: #d4a04a;
  fill: var(--c-gold);
  font-weight: 700;
}

.tree-node-secondary {
  fill: #aa854a;
  fill: var(--c-gold-soft);
}

/* Candidate person (dashed border) */
.tree-node.is-candidate .tree-node-card {
  stroke-dasharray: 4 4;
  stroke: color-mix(in oklch, var(--lc) 60%, transparent);
}

.tree-node.is-candidate .tree-node-name,
.tree-node.is-candidate .tree-node-sub {
  fill: #c6b694;
  fill: var(--paper-soft);
  font-style: italic;
}

/* Anchor halo accent */
.tree-node.is-anchor .tree-node-halo {
  fill: #d4a04a;
  fill: var(--c-gold);
}

/* Union nodes */
.tree-union-ring {
  fill: #2c251a;
  fill: var(--bg-2);
  stroke: #d4a04a;
  stroke: var(--c-gold);
  stroke-width: 1.5;
}

.tree-union-glyph {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 400;
  fill: #d4a04a;
  fill: var(--c-gold);
}

.tree-node[data-id='UN-FINAL'] .tree-union-ring {
  stroke-width: 2;
}

.tree-node[data-id='UN-FINAL'] .tree-union-glyph {
  font-size: 30px;
  fill: #d4a04a;
  fill: var(--c-gold);
}

.tree-union-label {
  font-family: var(--sans);
  font-size: 10.5px;
  fill: #c6b694;
  fill: var(--paper-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Spouses — smaller, lighter */
.tree-node-spouse .tree-node-card {
  fill: color-mix(in oklch, var(--bg-2) 88%, transparent);
  stroke-opacity: 0.6;
}

.tree-node-spouse .tree-node-name { font-size: 13px; font-style: italic; }
.tree-node-spouse .tree-node-sub  { font-size: 10.5px; }

/* GEN1 special — dimmed until lit, then full */
.tree-node.is-gen1 .tree-node-card { stroke: var(--c-gold); }
.tree-node.is-gen1 .tree-node-name { fill: var(--paper); }

/* Branch highlight — the closing Barbeau-line emphasis (beat at t=930) */
.tree-node.is-highlighted .tree-node-card {
  stroke: #d4a04a;
  stroke: var(--c-gold);
  stroke-width: 1.75;
}
.tree-node.is-highlighted .tree-node-halo {
  opacity: 0.45;
  fill: #d4a04a;
  fill: var(--c-gold);
}

/* ============================ 5. Ruler ============================= */
.tree-ruler { opacity: 0; }    /* JS reveals over rulerStart..rulerDur */

.tree-ruler-line {
  stroke: rgba(170, 133, 74, 0.60);
  stroke-width: 1.25;
}

.tree-ruler-tick {
  stroke: rgba(198, 182, 148, 0.35);
  stroke-width: 1;
}

.tree-ruler-tick.is-major {
  stroke: #aa854a;
  stroke: var(--c-gold-soft);
  stroke-width: 1.25;
}

.tree-ruler-year {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  fill: #c6b694;
  fill: var(--paper-soft);
  letter-spacing: 0.08em;
}

/* World annotations — appear once, hold. JS drives opacity+translate. */
.tree-world {
  opacity: 0;
}

.tree-world-guide {
  stroke: rgba(170, 133, 74, 0.55);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.tree-world-dot {
  fill: #c6cfda;
  fill: var(--c-world);
}

.tree-world-label {
  font-family: var(--serif);
  font-size: 11.5px;
  font-style: italic;
  fill: #f3e7cc;
  fill: var(--paper);
}

.tree-world-band {
  fill: #9aa6b4;
  fill: var(--c-world-soft);
  opacity: 0.55;
}

/* World-event SPROUT hero — big + readable on the left axis, then JS glides it
   down and shrinks it onto its ruler dot. Year/plate fade out as it settles. */
.tree-world-hero { opacity: 0; }
.tree-world-hero-plate {
  fill: rgba(18, 15, 10, 0.84);
  stroke: #c6cfda;
  stroke: var(--c-world);
  stroke-width: 1.5;
  filter: url(#t-shadow);
}
.tree-world-hero-year {
  font-family: var(--serif);
  font-size: 96px;
  font-weight: 600;
  fill: #c6cfda;
  fill: var(--c-world);
  letter-spacing: 0.01em;
}
.tree-world-hero-label {
  font-family: var(--serif);
  font-size: 52px;
  font-style: italic;
  fill: #f3e7cc;
  fill: var(--paper);
}

/* World-event IMAGE inset — public-domain artwork shown while an event is
   narrated. Top-right so it never collides with the bottom-right map. */
.event-inset {
  position: absolute;
  right: 24px;
  /* Temporary placeholders: fill the right column from under the topbar
     down to just above the map (map = bottom 92 + height 360 = 452; 468
     leaves a ~16px gap). Fluid height so the image is never cropped. */
  top: 92px;
  bottom: 468px;
  width: 480px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-1);
  border: 1px solid rgba(170, 133, 74, 0.28);
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.65);
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.1s ease-in-out;
  z-index: 30;
}
.event-inset.is-visible { opacity: 1; }
.event-inset img {
  width: 100%;
  height: 100%;
  object-fit: contain;   /* show the whole image, never crop */
  display: block;
  filter: sepia(0.16) saturate(0.94) brightness(0.95) contrast(1.02);
}
.event-inset-label {
  position: absolute;
  top: 8px;
  left: 12px;
  z-index: 5;
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--paper);
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.85);
}
.event-inset-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  padding: 14px 12px 7px;
  font-family: var(--serif);
  font-size: 10.5px;
  font-style: italic;
  color: var(--paper-soft);
  background: linear-gradient(to top, rgba(0,0,0,0.74), transparent);
}

/* ========================= 6. Caption layer ========================
   Sits at the TOP of the stage (just under the topbar) so it never
   covers the tree node the camera is focused on. */
.caption {
  position: absolute;
  left: 50%;
  top: 24px;
  transform: translateX(-50%);
  max-width: 68ch;
  padding: 14px 22px;
  text-align: center;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.4;
  color: var(--paper);
  background: rgba(34, 29, 20, 0.70);
  border: 1px solid rgba(170, 133, 74, 0.18);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(4px);   /* purposeful, not decorative */
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
  /* Discrete state change: appear/fade between beats */
  transition: opacity var(--dur-med) var(--easing-out),
              transform var(--dur-med) var(--easing-out);
  opacity: 0;
}

.caption.is-visible {
  opacity: 1;
}

/* ========================= 7. Map inset ============================ */
.map-inset {
  position: absolute;
  right: 24px;
  bottom: 84px;
  width: 380px;
  height: 300px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-1);
  border: 1px solid rgba(170, 133, 74, 0.24);
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.65);
  /* Hidden by default — fades in when surfaced */
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.2s ease-in-out;
}

.map-inset.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.map-inset .leaflet-container {
  width: 100%;
  height: 100%;
  background: var(--bg-2);
}

/* CartoDB Voyager tile filter — keep color and borders visible, sit
   comfortably against the dark UI without going pure sepia. */
.map-inset .leaflet-tile-pane {
  filter: saturate(0.88) contrast(1.04) brightness(0.94);
}

.map-inset-label {
  position: absolute;
  top: 8px;
  left: 12px;
  z-index: 500;
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--paper);
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.map-inset-caption {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  z-index: 500;
  font-family: var(--serif);
  font-size: 11.5px;
  font-style: italic;
  color: var(--paper);
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.85);
  pointer-events: none;
}

/* ========================= 8. Transport ============================ */
.transport {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: var(--pad-tight) var(--pad);
  border-top: 1px solid rgba(243, 231, 204, 0.08);
  background: rgba(34, 29, 20, 0.92);
}

.transport button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-2);
  color: var(--paper);
  border: 1px solid rgba(243, 231, 204, 0.14);
  transition:
    background var(--dur-fast) var(--easing-out),
    border-color var(--dur-fast) var(--easing-out);
}

.transport button:hover,
.transport button:focus-visible {
  background: var(--bg-3);
  border-color: var(--c-gold);
  outline: none;
}

.transport .play-btn { width: 44px; height: 44px; }

.transport .scrub {
  flex: 1;
  height: 4px;
  background: rgba(243, 231, 204, 0.08);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
}

.transport .scrub-fill {
  position: absolute;
  inset: 0;
  width: 0;
  background: var(--c-gold);
  border-radius: 2px;
  pointer-events: none;
}

.transport .meta {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--paper-soft);
  font-variant-numeric: tabular-nums;
  min-width: 110px;
  text-align: right;
}

.transport .act-readout {
  font-family: var(--serif);
  font-size: 13px;
  font-style: italic;
  color: var(--paper);
  min-width: 220px;
}

/* Focus rings (a11y) */
:focus-visible {
  outline: 2px solid var(--c-gold);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ====================== 9. Reduced motion ========================== */
@media (prefers-reduced-motion: reduce) {
  .map-inset {
    transition: opacity var(--dur-fast) linear;
    transform: translate3d(0, 0, 0);  /* don't slide; cut in/out */
  }
  .caption {
    transition: opacity var(--dur-fast) linear;
  }
  .tree-node-card,
  .transport button {
    transition: none;
  }
}

/* ====================== 10. Responsive ============================ */
@media (max-width: 900px) {
  .topbar .legend { display: none; }
  .map-inset { width: 280px; height: 220px; bottom: 96px; right: 14px; }
  .caption { font-size: 15px; max-width: calc(100vw - 32px); }
  .transport .act-readout { display: none; }
}


/* =========== 11. Intro card (opening title overlay) ============== */
.intro-card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(
    180deg,
    rgba(26, 22, 15, 0)   0%,
    rgba(26, 22, 15, 0.4) 30%,
    rgba(26, 22, 15, 0.4) 70%,
    rgba(26, 22, 15, 0)  100%
  );
}

.intro-eyebrow {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.32em;
  color: #aa854a;
  text-transform: uppercase;
  margin-bottom: 22px;
}

.intro-title {
  font-family: var(--serif);
  font-size: clamp(64px, 9vw, 124px);
  font-weight: 500;
  letter-spacing: 0.04em;
  color: #fbf3df;
  margin: 0;
  line-height: 1;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.85),
               0 0 34px rgba(212, 160, 74, 0.45),
               0 0 80px rgba(212, 160, 74, 0.22);
}

.intro-subtitle {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(18px, 2vw, 26px);
  font-weight: 400;
  color: #f3e7cc;
  margin: 18px 0 0 0;
  letter-spacing: 0.02em;
}

.intro-rule {
  width: 80px;
  height: 1px;
  background: #d4a04a;
  margin: 28px 0 24px 0;
  opacity: 0.7;
}

.intro-tagline {
  font-family: var(--sans);
  font-size: clamp(12px, 1.1vw, 14px);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #c6b694;
  margin: 0;
}

.intro-bullet {
  color: #d4a04a;
  margin: 0 6px;
}

@media (prefers-reduced-motion: reduce) {
  .intro-card { transition: opacity 0.3s linear; }
}

/* =========== 12. Map inset upgrades (bigger + more readable) ====== */
.map-inset {
  width: 480px;
  height: 360px;
  bottom: 92px;
}

.map-inset .leaflet-tile-pane {
  /* Voyager already has soft borders and labels — light touch only */
  filter: saturate(0.90) contrast(1.08) brightness(0.97);
}

.map-inset-label {
  font-size: 11.5px;
  letter-spacing: 0.10em;
  background: rgba(26, 22, 15, 0.62);
  padding: 4px 8px;
  border-radius: 3px;
  color: #f3e7cc;
}

.map-inset-caption {
  font-size: 13px;
  background: rgba(26, 22, 15, 0.78);
  padding: 6px 10px;
  border-radius: 4px;
  text-shadow: none;
}

/* Larger leaflet markers for readability */
.map-inset .leaflet-interactive {
  stroke-width: 2.5px !important;
}

@media (max-width: 900px) {
  .map-inset { width: 320px; height: 240px; bottom: 96px; right: 14px; }
}

/* ========================= 12. Act title (topbar) ============================ */
.act-title {
  flex: 1;
  text-align: center;
  font-family: var(--serif);
  font-size: 14px;
  font-style: italic;
  color: var(--paper-soft);
  letter-spacing: 0.03em;
  padding: 0 24px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.5s ease;
}

/* ========================= 13. Left Sidebar (v=38) ==========================
   Fixed left column showing a vertical year axis, world-event dots, and a
   playhead chevron that tracks the audio. Lives outside the SVG so it
   stays put while the canvas zooms and pans. Restrained color strategy:
   tinted neutral background, gold for the playhead, line colors only on
   the small line-stripe column. */
.sidebar {
  /* Grid-positioned (column 1, rows 1-3) — no fixed positioning. */
  position: relative;
  background: linear-gradient(180deg,
    oklch(17% 0.012 65) 0%,
    oklch(15% 0.012 65) 100%);
  border-right: 1px solid rgba(243, 231, 204, 0.08);
  font-family: var(--sans);
  color: var(--paper-soft);
  overflow: hidden;
  padding: 18px 14px 22px 18px;
  display: flex;
  flex-direction: column;
  z-index: 5;
}

.sidebar-eyebrow {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 14px;
}

.year-axis {
  position: relative;
  flex: 1;
  margin-left: 38px;    /* leave room for year labels on the right of ticks */
  border-left: 1px solid rgba(243, 231, 204, 0.10);
}

.year-tick {
  position: absolute;
  left: 0;
  height: 1px;
  pointer-events: none;
}

.year-tick-minor {
  width: 6px;
  background: rgba(243, 231, 204, 0.18);
}

.year-tick-major {
  width: 12px;
  background: rgba(243, 231, 204, 0.45);
}

.year-tick-major .year-label {
  position: absolute;
  left: 18px;
  top: -7px;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--paper-soft);
  white-space: nowrap;
}

/* World event dots — a narrow column to the LEFT of the year axis */
.world-dots {
  position: absolute;
  left: 18px;
  top: 32px;            /* clears the eyebrow */
  bottom: 22px;
  width: 12px;
  pointer-events: none;
}

.world-dot {
  position: absolute;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--c-world);
  opacity: 0.55;
  box-shadow: 0 0 0 2px oklch(15% 0.012 65);
  transition: opacity var(--dur-fast) var(--easing-out),
              transform var(--dur-fast) var(--easing-out);
}

.world-dot:hover {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.4);
}

/* Playhead chevron — slides smoothly via JS (top: %). The chevron points
   right, label sits beside it. */
.playhead {
  position: absolute;
  left: 50px;
  top: 0;
  height: 0;
  width: calc(100% - 60px);
  pointer-events: none;
  transition: top 240ms cubic-bezier(0.16, 1, 0.30, 1);
  z-index: 5;
}

.playhead::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 50%;
  width: calc(100% - 24px);
  height: 1px;
  background: linear-gradient(90deg,
    var(--c-gold) 0%,
    rgba(212, 160, 74, 0.35) 70%,
    transparent 100%);
  transform: translateY(-50%);
}

.playhead-arrow {
  position: absolute;
  left: 0;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 8px solid var(--c-gold);
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  transform: translateY(-50%);
  filter: drop-shadow(0 0 6px rgba(212, 160, 74, 0.55));
}

.playhead-label {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(15, 12, 8, 0.85);
  color: var(--c-gold);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid rgba(212, 160, 74, 0.35);
}

/* Sidebar lives in column 1 of the .app grid; no padding push needed
   on .stage now that the grid handles the layout. */

@media (max-width: 1100px) {
  .app { grid-template-columns: 180px 1fr; }
  .year-tick-major .year-label { font-size: 9.5px; }
}

@media (max-width: 800px) {
  /* On narrow viewports collapse the sidebar to a thin year strip */
  .app { grid-template-columns: 56px 1fr; }
  .sidebar { padding: 14px 6px 18px 6px; }
  .sidebar-eyebrow { display: none; }
  .year-axis { margin-left: 14px; }
  .year-tick-major .year-label { display: none; }
  .world-dots { left: 4px; }
  .playhead { left: 18px; width: calc(100% - 22px); }
  .playhead-label { font-size: 9.5px; padding: 1px 4px; }
}

/* ========================= 14. Map dot breathing (E4) ====================== */
@keyframes dot-breathe {
  0%, 100% { opacity: 1.0;  transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(1.45); }
}

.leaflet-overlay-pane svg .breathing-dot {
  transform-origin: center;
  transform-box: fill-box;
  animation: dot-breathe 2.4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .leaflet-overlay-pane svg .breathing-dot { animation: none; }
}

/* ========================= 15. Focused-node ring (E3) ====================== */
/* Subtle gold ring around the node the current beat is focused on. The pulse
   itself is JS-driven; this is the static affordance underneath. */
.tree-node.is-focused .node-card,
.tree-node.is-focused rect:first-of-type {
  stroke-width: 2.2px;
  filter: drop-shadow(0 0 8px rgba(212, 160, 74, 0.32));
}

/* ========================= 16. Per-act background tint (E7) ================
   Very low-chroma OKLCH shifts. Each Act gets a hue that nudges the bg-0
   colour by a degree or two — enough to feel a chapter change, not enough
   to be loud. Transitions over 3.6s so the shift is barely perceptible. */
body[data-act="opening"]  { --bg-0: oklch(15.0% 0.012 65); }
body[data-act="act-one"]  { --bg-0: oklch(15.5% 0.014 78); }
body[data-act="act-two"]  { --bg-0: oklch(15.5% 0.014 50); }
body[data-act="act-three"]{ --bg-0: oklch(15.0% 0.013 38); }
body[data-act="act-four"] { --bg-0: oklch(15.0% 0.014 92); }
body[data-act="act-five"] { --bg-0: oklch(15.5% 0.014 120); }
body[data-act="closing"]  { --bg-0: oklch(16.0% 0.014 80); }

html, body {
  transition: background 3.6s ease;
}
.stage {
  transition: background 3.6s ease;
}
