/* ===== [1] TOKENS ===== */
/* Theme A — the briefing: ink on paper. Theme B — the child's world: chalk on swept
   earth at dawn, the kolam's own inversion of the document. The seal-red is reserved
   for the Kural thread alone, the way Kural numbers are printed red in Tamil editions. */
:root {
  --paper: #FBFAF6;
  --ink: #191A1F;
  --ink-soft: #5A5B60;
  --rule: #DAD7CD;
  --seal: #A3271C;

  --earth: #241C16;
  --earth-warm: #33261A;
  --dawn: #232838;
  --chalk: #F4EDDD;
  --chalk-soft: #C9C0AC;
  --turmeric: #E0A33C;
  --lamp: #FFB566;

  --ta-display: 'Anek Tamil', 'Hind Madurai', sans-serif;
  --body: 'Hind Madurai', 'Anek Tamil', sans-serif;

  --wrap: 34rem;
  --pad: clamp(1.35rem, 5vw, 2rem);
}

/* ===== [2] BASE ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: auto; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.05rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
::selection { background: var(--ink); color: var(--paper); }
a { color: inherit; text-decoration-color: var(--rule); text-underline-offset: 3px; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--seal); outline-offset: 3px; }
[lang="ta"] { font-family: var(--ta-display); }
img { max-width: 100%; height: auto; display: block; }

.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: var(--pad); width: 100%; }
.wrap--center { text-align: center; }

/* ===== [3] MASTHEAD ===== */
.masthead { padding: 1.1rem var(--pad) 0; text-align: center; }
.masthead__line {
  font-family: var(--ta-display);
  font-size: 0.92rem;
  font-weight: 560;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
}
.masthead__en { font-weight: 420; }

/* ===== [4] SCENES — document by default, sticky stage when JS accepts the job ===== */
.scene { position: relative; }
.scene__pin {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-block: clamp(1.4rem, 4vh, 3rem);
}
/* [1] Scroll runway exists only with JS + motion allowed; document stays flat otherwise.
   HARD RULE from the real-phone pass: one screen, one comfortable swipe. A phone swipe
   covers roughly 100-120vh, so no pin may hold longer than ~one viewport of runway. */
.js .scene--paper .scene__pin, .js .scene--earth .scene__pin { position: sticky; top: 0; min-height: 100svh; }
.js #s1  { height: 165vh; }
.js #s2  { height: 155vh; }
.js #s3b { height: 165vh; }
.js #s3c { height: 185vh; }
.js #s4  { height: 200vh; }
/* [3] S3a, S5 and S7 stay in flow: set type reveals as it arrives, the ladder is taller
   than a viewport by design, and the threshold must not trap the scroll while he taps */
.js #s3a .scene__pin, .js #s5 .scene__pin, .js #s7 .scene__pin { position: relative; }
.scene--flow .scene__pin { min-height: 0; }
.scene--flow { padding-block: clamp(4rem, 14vh, 7rem); }

/* [2] Crossing into the child's world: the page darkens like the hour before light.
   The band at each edge is the threshold — deliberate, legible, felt. */
.scene--earth {
  background:
    linear-gradient(180deg, var(--dawn) 0%, var(--earth) 9%, var(--earth) 91%, var(--dawn) 100%);
  color: var(--chalk);
}
.scene--earth ::selection { background: var(--chalk); color: var(--earth); }

/* ===== [5] EYEBROWS, RULES ===== */
.eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-top: 1px solid var(--rule);
  padding-top: 0.85rem;
  margin-bottom: clamp(1.8rem, 6vh, 3rem);
}
.eyebrow [lang="ta"] { letter-spacing: 0.02em; font-size: 0.9rem; font-weight: 500; }
.eyebrow__sep { color: var(--rule); padding-inline: 0.35em; }
.eyebrow--earth { color: var(--chalk-soft); border-top-color: rgba(244, 237, 221, 0.22); margin-bottom: clamp(1.1rem, 3.5vh, 1.8rem); }

/* ===== [6] S1 — FIGURES ===== */
/* [1] The whole screen — figures, statement, planted couplet — composes as ONE
   viewport so the couplet can never read as a separate screen */
#s1 .eyebrow { margin-bottom: 1.2rem; }
#s1 .figure { margin-bottom: 1.15rem; }
#s1 .figure__value { font-size: clamp(2.9rem, 15vw, 4.2rem); }
#s1 .statement { margin-top: 1.1rem; }
#s1 .statement [lang="ta"] { font-size: 1.03rem; line-height: 1.7; }
#s1 .statement__en { font-size: 0.92rem; }
#s1 .kural--planted { margin-top: 1.5rem; }
.figure { margin-bottom: clamp(1.6rem, 5vh, 2.6rem); }
.figure__label {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink-soft);
  margin-bottom: 0.2rem;
}
.figure__label [lang="ta"] { display: block; font-weight: 560; color: var(--ink); font-size: 1.02rem; }
.figure__label-en { display: block; }
.figure__value {
  font-family: var(--ta-display);
  font-weight: 640;
  font-size: clamp(3.2rem, 18vw, 5rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.figure__unit { font-size: 0.98rem; font-weight: 480; color: var(--ink-soft); letter-spacing: 0; }
.figure__dir { font-family: var(--body); padding-left: 0.1em; }
.figure__range {
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.9rem;
}

/* ===== [7] STATEMENTS — the load-bearing lines ===== */
.statement { margin-top: clamp(1.4rem, 4vh, 2.2rem); }
.statement [lang="ta"] {
  font-size: 1.13rem;
  font-weight: 560;
  line-height: 1.85;
}
.statement__en { color: var(--ink-soft); font-size: 0.97rem; margin-top: 0.55rem; }
.statement--tight { margin-top: 1rem; }
.statement--earth { margin-top: 1rem; }
.statement--earth [lang="ta"] { color: var(--chalk); font-size: 1.02rem; line-height: 1.7; }
.statement--earth .statement__en { color: var(--chalk-soft); font-size: 0.92rem; }
.statement--after { padding-block: clamp(3rem, 12vh, 5rem); }

/* ===== [8] THE KURAL THREAD — seal-red, four appearances, nothing else red ===== */
.kural {
  font-family: var(--ta-display);
  color: var(--seal);
  line-height: 2;
  margin-top: clamp(2.2rem, 7vh, 3.6rem);
}
.kural--planted { font-size: 0.95rem; font-weight: 500; opacity: 0.92; }
.kural--open { font-size: clamp(1.2rem, 5vw, 1.45rem); font-weight: 560; margin-top: 0; }
.kural--resolved { font-size: clamp(1.05rem, 4.4vw, 1.45rem); font-weight: 560; text-align: center; }
.kural__word { font-weight: 720; border-bottom: 2px solid currentColor; }

/* ===== [9] S2 — BARS ===== */
.bars { margin-block: clamp(1rem, 3vh, 1.6rem) 0; }
.bar { display: grid; grid-template-columns: 6.4rem 1fr 3.2rem; align-items: center; gap: 0.8rem; margin-bottom: 1.15rem; }
.bar__label { font-size: 0.92rem; color: var(--ink-soft); line-height: 1.35; }
.bar__label [lang="ta"] { display: block; color: var(--ink); font-weight: 560; font-size: 1rem; }
.bar__track { background: #EFEDE5; height: 16px; overflow: hidden; }
.bar__fill { background: var(--ink); height: 100%; transform-origin: left center; }
.bar__fill[data-pct="76"] { width: 76%; }
.bar__fill[data-pct="51"] { width: 51%; }
.bar__fill--low { background: var(--ink-soft); }
.bar__pct { font-family: var(--ta-display); font-weight: 620; font-variant-numeric: tabular-nums; text-align: right; }

/* ===== [10] S3 — THE PATTERN-BREAK ===== */
.scene--quiet .scene__pin { justify-content: center; }
.clock {
  font-family: var(--ta-display);
  font-size: clamp(1.5rem, 7vw, 2.1rem);
  font-weight: 620;
  line-height: 1.6;
  margin-bottom: 1.2rem;
}
.claim { margin-top: clamp(2rem, 6vh, 3rem); border-left: 2px solid var(--ink); padding-left: 1.1rem; }
.claim [lang="ta"] { font-family: var(--ta-display); font-size: 1.22rem; font-weight: 600; line-height: 1.85; }
.claim__en { color: var(--ink-soft); font-size: 0.98rem; margin-top: 0.6rem; }

.twin { display: flex; align-items: center; justify-content: center; gap: clamp(0.8rem, 4vw, 1.4rem); margin-top: 1rem; }
.twin__letter {
  font-family: var(--ta-display);
  font-size: clamp(5.2rem, 28vw, 8.5rem);
  font-weight: 620;
  line-height: 1;
}
.twin__link { width: clamp(2.6rem, 10vw, 3.8rem); color: var(--ink-soft); flex: none; }
.twin__caption { margin-top: 1.4rem; font-size: 0.95rem; color: var(--ink-soft); }
.twin__caption [lang="ta"] { display: block; color: var(--ink); font-weight: 560; font-size: 1.05rem; }
.twin__same { margin-top: 1.3rem; font-family: var(--ta-display); font-size: 1.18rem; font-weight: 600; }
.twin__same-en { display: block; font-family: var(--body); font-weight: 400; color: var(--ink-soft); font-size: 0.95rem; margin-top: 0.25rem; }
.twin__years { margin-top: 1.1rem; font-family: var(--ta-display); font-size: 1.05rem; font-weight: 520; }

.meanings { margin-top: clamp(1.6rem, 5vh, 2.4rem); text-align: left; border-top: 1px solid var(--rule); padding-top: 1.4rem; }
.meanings__ta { font-family: var(--ta-display); font-weight: 540; font-size: 1.06rem; line-height: 1.95; }
.meanings__en { color: var(--ink-soft); font-size: 0.97rem; margin-top: 0.9rem; }
.attrib { margin-top: 1.6rem; font-size: 0.82rem; color: var(--ink-soft); }
.attrib [lang="ta"] { display: block; font-size: 0.88rem; }
.attrib__en { display: block; margin-top: 0.15rem; }

/* ===== [11] S4 — THE LESSON (Theme B) ===== */
.kolam { width: min(46vw, 205px); margin: 0 auto; color: var(--chalk); display: block; }
.kolam__dots circle { fill: var(--chalk); }
.lesson { margin-top: clamp(0.9rem, 3vh, 1.5rem); }
.lesson__note { font-size: 0.95rem; color: var(--chalk-soft); }
.lesson__note [lang="ta"] { display: block; font-size: 1.08rem; font-weight: 560; color: var(--chalk); }
.lesson__note em { font-style: normal; color: var(--turmeric); }
.lesson__note-en { display: block; margin-top: 0.2rem; }
.word {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  margin-top: clamp(0.9rem, 3vh, 1.4rem);
}
.word__ta { font-family: var(--ta-display); font-size: clamp(2.2rem, 11vw, 3rem); font-weight: 640; color: var(--chalk); line-height: 1.15; }
.word__sound { font-size: 0.95rem; color: var(--turmeric); letter-spacing: 0.04em; }
.word__link { width: 2.6rem; color: var(--turmeric); flex: none; }
.word__en { font-size: 1.12rem; font-weight: 600; color: var(--chalk); }

/* ===== [12] S5 — THE LADDER ===== */
.ladder { list-style: none; position: relative; padding-left: 2.6rem; }
.ladder::before {
  content: '';
  position: absolute; left: 0.78rem; top: 0.4rem; bottom: 0.4rem;
  width: 2px; background: var(--ink);
  transform-origin: top center;
  /* [1] Driven by GSAP via --spine-scale on .ladder; falls back to fully drawn without JS */
  transform: scaleY(var(--spine-scale, 1));
}
.rung { position: relative; padding-bottom: clamp(1.3rem, 4vh, 2rem); }
.rung:last-child { padding-bottom: 0; }
.rung__grade {
  position: absolute; left: -2.6rem; top: 0.05rem;
  width: 1.7rem; height: 1.7rem;
  display: grid; place-items: center;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  font-family: var(--ta-display);
  font-weight: 640;
  font-size: 0.9rem;
}
.rung__body [lang="ta"] { font-weight: 560; line-height: 1.8; font-size: 1.03rem; }
.rung__en { color: var(--ink-soft); font-size: 0.92rem; margin-top: 0.25rem; line-height: 1.6; }
.rung--goal .rung__grade { background: var(--ink); color: var(--paper); }
.rung--goal .rung__body [lang="ta"] { font-weight: 620; }

/* ===== [13] S6 — PROSE ===== */
.prose { margin-bottom: 1.4rem; }
.prose [lang="ta"] { font-weight: 540; }
.prose--anchor {
  border-left: 2px solid var(--ink);
  padding-left: 1.1rem;
  font-size: 0.98rem;
}

/* ===== [14] S7 — THE THRESHOLD ===== */
.scene--threshold .scene__pin { padding-block: clamp(2rem, 6vh, 3.4rem); justify-content: flex-start; }
.kicker { text-align: center; margin-bottom: 1.2rem; padding-inline: var(--pad); }
.kicker [lang="ta"] { display: block; font-family: var(--ta-display); font-size: 1.12rem; font-weight: 560; color: var(--chalk); }
.kicker__en { font-size: 0.88rem; color: var(--chalk-soft); }
.threshold {
  position: relative;
  width: min(100%, 640px);
  margin-inline: auto;
  aspect-ratio: 4 / 5;
  max-height: 74svh;
  overflow: hidden;
  touch-action: manipulation;
}
@media (min-width: 700px) {
  .threshold { aspect-ratio: 4 / 3; max-height: 64svh; }
}
.threshold__still { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.threshold--live .threshold__still { display: none; }
.threshold canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 1; }
.threshold__labels { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
/* [1] The taught word: it ARRIVES — large, Tamil first, spoken — and the English
   lands onto the same block. A lesson happening, not a tooltip firing. */
.teach {
  position: absolute;
  transform: translate(-50%, -100%);
  text-align: center;
  line-height: 1.15;
  text-shadow: 0 2px 16px rgba(12, 9, 6, 0.85);
  white-space: nowrap;
  pointer-events: none;
}
.teach__ta {
  display: block;
  font-family: var(--ta-display);
  font-weight: 640;
  font-size: clamp(2.3rem, 10.5vw, 3.1rem);
  color: var(--chalk);
}
.teach__sound { display: block; font-size: 0.88rem; letter-spacing: 0.08em; color: var(--turmeric); margin-top: 0.1rem; }
.teach__en { display: block; font-size: 1.2rem; font-weight: 600; color: var(--chalk); margin-top: 0.2rem; }
.threshold__words {
  text-align: center;
  margin-top: 1.1rem;
  font-size: 0.95rem;
  color: var(--chalk-soft);
}
.threshold__words [lang="ta"] { font-weight: 600; color: var(--chalk); font-size: 1.05rem; }

/* ===== [15] S8 — THE ASK ===== */
.ask { font-family: var(--ta-display); font-size: clamp(1.6rem, 7.4vw, 2.2rem); font-weight: 640; line-height: 1.5; margin-bottom: 1.4rem; }
.ask__en { font-family: var(--body); font-size: 1rem; font-weight: 400; color: var(--ink-soft); display: block; margin-top: 0.3rem; line-height: 1.65; }
.contact {
  margin-top: clamp(2rem, 6vh, 3rem);
  border-top: 1px solid var(--rule);
  padding-top: 1.3rem;
  font-family: var(--ta-display);
  font-weight: 600;
  font-size: 1.15rem;
  line-height: 1.9;
}
.contact a { font-family: var(--body); font-weight: 400; font-size: 0.98rem; }
.finale { text-align: center; margin-top: clamp(2.4rem, 8vh, 4rem); padding-bottom: 1rem; }
.finale [lang="ta"] { font-family: var(--ta-display); font-size: 1.22rem; font-weight: 620; line-height: 1.9; }
.finale__en { color: var(--ink-soft); font-size: 0.98rem; margin-top: 0.7rem; }

/* ===== [16] FOOTER ===== */
.foot { padding: 2.2rem var(--pad) calc(2.2rem + env(safe-area-inset-bottom)); text-align: center; }
.foot p { font-size: 0.78rem; color: var(--ink-soft); letter-spacing: 0.04em; }

/* ===== [17] SHORT VIEWPORTS — pinned scenes must fit with every beat revealed ===== */
@media (max-height: 760px) {
  .figure__value { font-size: clamp(2.6rem, 14vw, 3.8rem); }
  .figure { margin-bottom: 1.2rem; }
  .figure__range { padding-bottom: 0.55rem; }
  .statement { margin-top: 1.1rem; }
  .statement [lang="ta"] { font-size: 1.05rem; line-height: 1.7; }
  .kural { margin-top: 1.4rem; }
  .eyebrow { margin-bottom: 1.2rem; }
  .twin__letter { font-size: clamp(4rem, 22vw, 6.5rem); }
  .meanings { padding-top: 1rem; margin-top: 1.2rem; }
  .meanings__ta { font-size: 0.98rem; line-height: 1.8; }
  .kolam { width: min(44vw, 190px); }
  .rung { padding-bottom: 1rem; }
}

/* ===== [18] REDUCED MOTION — belt and braces; the .js gate already holds ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
