/* ── 8.3 Million — data film. Twilight palette, midnight stage. ────────── */

:root {
  /* Stage & ink */
  --stage:        #141126;   /* film background */
  --stage-raise:  #1F1B3A;   /* panels over the stage */
  --ink:          #FAF6EE;   /* primary text on stage */
  --ink-soft:     #C9C3DC;   /* secondary text */
  --ink-mute:     #8B84A8;   /* tertiary / chrome */

  /* L1 cause groups — dark-mode steps of the story ramp,
     validated (OKLCH band, chroma, CVD, contrast) against the stage. */
  --l1-cmnn:      #E0685A;   /* communicable, maternal, perinatal, nutritional */
  --l1-ncd:       #9C86CC;   /* non-communicable */
  --l1-injury:    #C08430;   /* injuries */

  --gold:         #F4D58D;   /* accent: highlights, the "attention" color */
  --neutral-dot:  #B9B3CE;   /* dots when no group identity is on stage */

  --font-serif: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans:  "Inter", system-ui, -apple-system, sans-serif;
}

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

html, body { height: 100%; }

body {
  background: var(--stage);
  color: var(--ink);
  font-family: var(--font-sans);
  overflow: hidden;
}

#film { position: fixed; inset: 0; }

#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ── Title screen ──────────────────────────────────────────────────────── */

#titleScreen {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #1F1B3A 0%, #141126 70%);
  text-align: center;
  transition: opacity 1.2s ease;
}
#titleScreen.leaving { opacity: 0; pointer-events: none; }

.title-inner { max-width: 34rem; padding: 2rem; }

.title-kicker {
  font-family: var(--font-sans);
  font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 1.2rem;
}

#titleScreen h1 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(3rem, 9vw, 5.5rem);
  color: var(--gold);
  margin-bottom: 0.8rem;
}

.title-dek {
  font-family: var(--font-serif);
  font-size: 1.15rem; line-height: 1.5;
  color: var(--ink-soft);
  margin-bottom: 2rem;
}

#beginBtn {
  font-family: var(--font-sans); font-weight: 600; font-size: 1rem;
  color: var(--stage); background: var(--gold);
  border: none; border-radius: 999px;
  padding: 0.8rem 2.2rem; cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#beginBtn:hover { transform: scale(1.04); box-shadow: 0 4px 30px rgba(244, 213, 141, 0.35); }

.title-note {
  font-size: 0.8rem; line-height: 1.5; color: var(--ink-mute);
  margin-top: 1.6rem;
}

.title-links { font-size: 0.8rem; color: var(--ink-mute); margin-top: 0.8rem; }
.title-links a, .end-links a { color: var(--ink-soft); }

/* ── End card ──────────────────────────────────────────────────────────── */

#endCard {
  position: absolute; inset: 0; z-index: 25;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  background: rgba(20, 17, 38, 0.82);
  opacity: 0; transition: opacity 1.5s ease;
}
#endCard.visible { opacity: 1; }
#endCard[hidden] { display: none; }

.end-inner { max-width: 38rem; padding: 2rem; }

#endCard h2 {
  font-family: var(--font-serif); font-weight: 500;
  font-size: clamp(1.4rem, 3.5vw, 2.1rem); line-height: 1.35;
  margin: 1rem 0 1.6rem;
}
#endCard h2 em { color: var(--gold); font-style: italic; }

.end-credits { font-size: 0.82rem; line-height: 1.6; color: var(--ink-soft); margin-bottom: 1rem; }
.end-links { font-size: 0.85rem; margin-bottom: 2rem; }

#replayBtn {
  font-family: var(--font-sans); font-weight: 600; font-size: 0.9rem;
  color: var(--ink); background: transparent;
  border: 1px solid var(--ink-mute); border-radius: 999px;
  padding: 0.6rem 1.6rem; cursor: pointer;
}
#replayBtn:hover { border-color: var(--ink); }

/* ── HUD ───────────────────────────────────────────────────────────────── */

#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }

#chapterTag {
  position: absolute; top: 1.1rem; left: 1.4rem;
  font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-mute);
  opacity: 0; transition: opacity 0.8s ease;
}
#chapterTag.visible { opacity: 1; }

#keyTag {
  position: absolute; top: 1.05rem; right: 1.4rem;
  font-size: 0.72rem; color: var(--ink-mute);
  opacity: 0; transition: opacity 0.8s ease;
}
#keyTag.visible { opacity: 1; }
#keyTag[hidden] { display: none; }
.key-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--neutral-dot); vertical-align: 0;
}

#hintTag {
  position: absolute; right: 1.4rem; bottom: 4.6rem;
  max-width: 17rem;
  font-size: 0.75rem; line-height: 1.5; color: var(--ink-soft);
  background: rgba(31, 27, 58, 0.9);
  border: 1px solid rgba(139, 132, 168, 0.35);
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  opacity: 0; transition: opacity 0.8s ease;
}
#hintTag.visible { opacity: 1; }
#hintTag[hidden] { display: none; }

/* Narration captions — lower third */
#caption {
  position: absolute; left: 50%; bottom: 5.2rem;
  transform: translateX(-50%);
  width: min(44rem, calc(100vw - 3rem));
  text-align: center;
  font-family: var(--font-serif);
  font-size: clamp(1.02rem, 2.1vw, 1.3rem);
  line-height: 1.5;
  color: var(--ink);
  text-shadow: 0 1px 12px rgba(20, 17, 38, 0.9);
  opacity: 0; transition: opacity 0.55s ease;
}
#caption.visible { opacity: 1; }
#caption strong { color: var(--gold); font-weight: 600; }
#caption .cap-note { display: block; font-size: 0.78em; color: var(--ink-soft); margin-top: 0.35em; }

/* Big centered lines (title cards inside the film) */
#caption.center {
  bottom: auto; top: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(1.5rem, 3.6vw, 2.4rem);
  font-weight: 500;
}

/* Explore pause panel */
#explorePanel {
  position: absolute; left: 50%; bottom: 4.6rem;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 1rem;
  background: rgba(31, 27, 58, 0.92);
  border: 1px solid rgba(139, 132, 168, 0.4);
  border-radius: 999px;
  padding: 0.55rem 0.6rem 0.55rem 1.2rem;
  font-size: 0.85rem; color: var(--ink-soft);
  pointer-events: auto;
  opacity: 0; transition: opacity 0.5s ease;
}
#explorePanel.visible { opacity: 1; }
#explorePanel[hidden] { display: none; }

#continueBtn {
  font-family: var(--font-sans); font-weight: 600; font-size: 0.85rem;
  color: var(--stage); background: var(--gold);
  border: none; border-radius: 999px;
  padding: 0.5rem 1.2rem; cursor: pointer;
}

/* Tooltip */
#tooltip {
  position: absolute;
  background: rgba(31, 27, 58, 0.96);
  border: 1px solid rgba(139, 132, 168, 0.45);
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  font-size: 0.78rem; line-height: 1.45; color: var(--ink);
  max-width: 16rem;
  pointer-events: none;
  z-index: 20;
}
#tooltip .tt-name { font-weight: 600; }
#tooltip .tt-val { color: var(--gold); font-weight: 600; }
#tooltip .tt-sub { color: var(--ink-soft); }

/* ── Controls bar ──────────────────────────────────────────────────────── */

#controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 15;
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.6rem 1.2rem 0.7rem;
  background: linear-gradient(to top, rgba(20, 17, 38, 0.95), rgba(20, 17, 38, 0));
  font-size: 0.75rem; color: var(--ink-mute);
  opacity: 1; transition: opacity 0.4s ease;
}
#controls[hidden] { display: none; }
#controls.idle { opacity: 0.15; }
#controls:hover { opacity: 1; }

#playBtn, #muteBtn {
  background: none; border: none; cursor: pointer;
  color: var(--ink); font-size: 1rem; line-height: 1;
  padding: 0.3rem 0.4rem;
}
#muteBtn.muted { color: var(--ink-mute); text-decoration: line-through; }

#timeNow, #timeTotal { font-variant-numeric: tabular-nums; min-width: 2.6rem; }
#timeNow { text-align: right; }

#scrubber { position: relative; flex: 1; height: 22px; cursor: pointer; }

#scrubTrack {
  position: absolute; left: 0; right: 0; top: 50%;
  height: 4px; transform: translateY(-50%);
  background: rgba(139, 132, 168, 0.3); border-radius: 2px;
}
#scrubFill {
  height: 100%; width: 0%;
  background: var(--gold); border-radius: 2px;
}

#scrubChapters { position: absolute; inset: 0; }
.chap-tick {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--stage); border: 2px solid var(--ink-mute);
}
.chap-tick.done { border-color: var(--gold); }
.chap-tick:hover { border-color: var(--ink); }
.chap-tick .chap-label {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  white-space: nowrap;
  background: rgba(31, 27, 58, 0.95);
  padding: 0.25rem 0.6rem; border-radius: 6px;
  font-size: 0.7rem; color: var(--ink);
  opacity: 0; pointer-events: none; transition: opacity 0.15s ease;
}
.chap-tick:hover .chap-label { opacity: 1; }

/* ── Small screens ─────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  #caption { bottom: 4.4rem; font-size: 0.95rem; }
  #chapterTag { left: 1rem; }
  #keyTag { right: 1rem; }
  .chap-tick { width: 5px; height: 5px; }
}
