/* ==========================================================================
   SmogSense landing page — layout
   Three acts: vertical  ->  pinned horizontal rail  ->  vertical.
   ========================================================================== */

/* ==========================================================================
   0. Intro — the word stack that rises, then lifts away into the hero
   ========================================================================== */
.intro {
  position: fixed;
  inset: 0;
  z-index: var(--z-intro);
  display: grid;
  place-items: center;
  background: var(--ink);
}
.intro__stack {
  display: grid;
  gap: 0.1em;
  text-align: center;
}
.intro__word {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: var(--t-xl);
  line-height: 1;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}
/* Each word is the only child of its own .mask-line, so the nth-child has
   to be counted on the masks, not on the words. */
.intro__stack > :nth-child(1) .intro__word { color: var(--brand-bright); }
.intro__stack > :nth-child(2) .intro__word { color: var(--brand-amber); }
.intro__stack > :nth-child(3) .intro__word { color: var(--brand-bright); }

/* Hidden until JS decides it is needed, so a no-JS visitor is never
   trapped behind a black overlay. */
html:not(.js-ready) .intro { display: none; }

/* ==========================================================================
   1. Hero — poster still, logo in front, tagline under it
   ========================================================================== */
.hero {
  position: relative;
  height: 100svh;
  min-height: 34rem;
  display: grid;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
}
.hero__media,
.hero__media img,
.hero__media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* The overscale that hides the parallax edges is applied to the <img> by
   act1.js, not here, so nothing fights over the wrapper's transform. */
.hero__media { z-index: -2; }

.hero__scrim {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60% 55% at 50% 45%, rgba(11,13,16,0.25), rgba(11,13,16,0.72) 100%),
    linear-gradient(180deg, rgba(11,13,16,0.55) 0%, rgba(11,13,16,0.2) 35%, rgba(11,13,16,0.9) 100%);
}

.hero__inner {
  display: grid;
  justify-items: center;
  gap: 1.6rem;
  padding: 0 var(--gutter);
  text-align: center;
}
.hero__logo {
  width: clamp(15rem, 38vw, 34rem);
  filter: drop-shadow(0 0.5rem 2.5rem rgba(0,0,0,0.55));
}
.hero__tagline {
  font-size: var(--t-md);
  letter-spacing: 0.02em;
  max-width: 46ch;
  opacity: 0.92;
}
.hero__question {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: var(--t-lg);
  letter-spacing: -0.03em;
  text-transform: uppercase;
}
.hero__question em { font-style: normal; color: var(--alert); }

/* ==========================================================================
   Shared chapter scaffold (Act I and Act III)
   ========================================================================== */
.chapter {
  position: relative;
  min-height: 100svh;
  display: grid;
  align-content: center;
  padding: clamp(5rem, 12vh, 9rem) var(--gutter);
  overflow: hidden;
}
.chapter--paper { background: var(--paper); color: var(--ink); }
.chapter__grid {
  position: relative;
  z-index: 1;
  display: grid;
  gap: clamp(2rem, 5vw, 5rem);
  align-items: center;
  grid-template-columns: 1fr;
  max-width: 82rem;
  margin-inline: auto;
  width: 100%;
}
@media (min-width: 901px) {
  .chapter__grid--split { grid-template-columns: 1.05fr 0.95fr; }
}

/* --- Scroll cue ----------------------------------------------------------- */
.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: 2.2rem;
  translate: -50% 0;
  display: grid;
  justify-items: center;
  gap: 0.5rem;
  font-size: var(--t-small);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0.55;
  z-index: 3;
}
.scroll-cue svg { width: 1rem; animation: nudge 2.4s var(--ease-out) infinite; }
@keyframes nudge {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50%      { transform: translateY(0.4rem); opacity: 1; }
}

/* ==========================================================================
   2. Delhi stat — smog haze layers + a scrubbed count-up
   ========================================================================== */
.stat-hero { position: relative; text-align: left; }
.stat-hero__number {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: var(--t-mega);
  line-height: 0.85;
  letter-spacing: -0.05em;
  color: var(--alarm-soft);
  font-variant-numeric: tabular-nums;
}
.stat-hero__line { font-size: var(--t-xl); }

/* Three drifting haze bands, each on its own ScrollSmoother data-speed. */
.haze {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.haze span {
  position: absolute;
  left: -20%;
  width: 140%;
  height: 38%;
  border-radius: 50%;
  filter: blur(60px);
  background: radial-gradient(closest-side, rgba(138,144,155,0.55), transparent);
}
.haze span:nth-child(1) { top: 4%;  opacity: 0.55; }
.haze span:nth-child(2) { top: 38%; opacity: 0.40; height: 46%; }
.haze span:nth-child(3) { top: 66%; opacity: 0.50; }

/* ==========================================================================
   3. One in five — stick figures
   ========================================================================== */
.figures {
  display: flex;
  gap: clamp(0.6rem, 2vw, 1.6rem);
  align-items: flex-end;
  flex-wrap: wrap;
}
.figures svg { width: clamp(3.2rem, 8vw, 7rem); height: auto; overflow: visible; }
.figure-stroke {
  fill: none;
  stroke: var(--smog-500);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.figure-head { fill: none; stroke: var(--smog-500); stroke-width: 6; }

/* ==========================================================================
   ACT II — the pinned horizontal rail
   ========================================================================== */
.rail-outer {
  position: relative;
  height: 100svh;
  overflow: hidden;
  background: var(--ink);
  /* the camera-turn on panel 1 swings in 3D against this */
  perspective: 1500px;
  perspective-origin: 50% 50%;
}
.rail {
  display: flex;
  height: 100%;
  width: max-content;
  will-change: transform;
}
.panel {
  position: relative;
  width: 100vw;
  height: 100%;
  flex: 0 0 100vw;
  overflow: hidden;
  display: grid;
  align-content: center;
  padding: clamp(3rem, 8vh, 6rem) var(--gutter);
}
.panel--paper { background: var(--paper); color: var(--ink); }
.panel__inner {
  position: relative;
  z-index: 2;
  display: grid;
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: center;
  grid-template-columns: 1fr;
  max-width: 84rem;
  margin-inline: auto;
  width: 100%;
}
@media (min-width: 901px) {
  .panel__inner--split   { grid-template-columns: 0.9fr 1.1fr; }
  .panel__inner--split-r { grid-template-columns: 1.1fr 0.9fr; }
}
/* The exhaust scene is a wide cinematic strip, so it reads better stacked
   under its copy than squeezed into a column. Both have to fit one
   viewport, hence the tighter gap and the capped scene height. */
.panel__inner--stack { gap: clamp(1rem, 2.5vh, 2.2rem); }
.panel__inner--stack .panel__copy { max-width: 56ch; }
.panel__inner--stack .panel__title { margin-bottom: 0.4em; }
.panel__inner--stack .panel__stage svg { max-height: 44svh; }
.panel__copy { max-width: var(--measure); }
.panel__title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: var(--t-lg);
  line-height: 0.98;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  margin-bottom: 0.7em;
  text-wrap: balance;
}
.panel__title em { font-style: normal; color: var(--alarm); }
.panel__stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
}
.panel__stage svg { width: 100%; height: auto; max-height: 66svh; overflow: visible; }

/* --- Rail HUD: progress bar + the cue that rotates from down to right ----- */
.rail__hud {
  position: absolute;
  z-index: var(--z-hud);
  left: var(--gutter);
  right: var(--gutter);
  bottom: 1.8rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  pointer-events: none;
  mix-blend-mode: difference;
  color: #fff;
}
.rail__track {
  position: relative;
  flex: 1;
  height: 2px;
  background: rgba(255,255,255,0.22);
}
.rail__bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  background: #fff;
  transform-origin: left center;
  transform: scaleX(0);
}
.rail__count {
  font-size: var(--t-small);
  letter-spacing: 0.18em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.rail__cue {
  position: absolute;
  z-index: var(--z-cue);
  left: 50%;
  bottom: 4.6rem;
  translate: -50% 0;
  width: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 50%;
  mix-blend-mode: difference;
  color: #fff;
}
.rail__cue svg { width: 0.9rem; }

/* A full-viewport wash used only during the turn. It is a sibling of the
   rail, never an ancestor, so it cannot disturb containerAnimation
   measurements inside the panels. */
.rail__flash {
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(120% 90% at 100% 50%, rgba(11,13,16,0.7), transparent 68%),
    linear-gradient(90deg, transparent 45%, rgba(11,13,16,0.45) 100%);
}

/* ==========================================================================
   Panel 1 — exhaust
   ========================================================================== */
.panel--exhaust { background: var(--ink); }
.panel--exhaust .panel__inner { transform-style: preserve-3d; }

.city-stroke { fill: none; stroke: var(--smog-500); stroke-width: 3; stroke-linejoin: round; }
.city-fill   { fill: #161a20; }
.plume       { fill: var(--smog-500); opacity: 0.5; }

/* The magnifier that grows out of the plume and hands over to the rail.
   Its transform-origin is set by GSAP in user units, so none is declared
   here — a CSS one would just be overwritten and confuse the next reader. */
.magnifier circle { fill: rgba(11,13,16,0.65); stroke: var(--paper); stroke-width: 2.4; }

/* ==========================================================================
   Panels 2-6 — PM2.5, nose, lungs, macrophage, chronic
   ========================================================================== */
.pm-body  { fill: var(--smog-500); }
.pm-inner { fill: var(--smog-300); }
.pm-puff  { fill: var(--smog-300); }
.pm-face  { stroke: var(--ink); fill: none; stroke-linecap: round; stroke-linejoin: round; }

.line-art {
  fill: none;
  stroke: var(--ink);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.line-art--thin { stroke-width: 3.2; }
.line-art--hair { stroke-width: 2; }
.panel--exhaust .line-art { stroke: var(--paper); }

.macro-body    { fill: var(--macro-fill); stroke: var(--macro-line); stroke-width: 3; }
.macro-nucleus { fill: var(--macro-nucleus); }
.macro-granule { fill: var(--macro-line); opacity: 0.4; }
.cytokine      { fill: var(--cytokine); }

/* The inflammation wash on panel 6 — faded up by JS on scrub. */
.inflame {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(62% 62% at 50% 55%, rgba(201,42,42,0.42), transparent 72%);
}

.callout-ring { fill: none; stroke: var(--ink); stroke-width: 2.4; }
.callout-lead { fill: none; stroke: var(--ink); stroke-width: 2; }

/* Stat chips used across panels */
.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem;
  border: 1.5px solid currentColor;
  border-radius: 999px;
  font-size: var(--t-small);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.8;
}
.chip--alarm { color: var(--alarm); opacity: 1; }

/* ==========================================================================
   ACT III
   ========================================================================== */
.presents { text-align: center; }
.presents .chapter__grid { justify-items: center; gap: 1.6rem; }
.presents__lead { font-size: var(--t-lg); opacity: 0.7; }
.presents__mark {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: var(--t-mega);
  line-height: 0.85;
  letter-spacing: -0.05em;
  text-transform: uppercase;
  background: linear-gradient(100deg, var(--brand-bright), #eaf6ff 45%, var(--brand-amber));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.presents__logo { width: clamp(14rem, 30vw, 26rem); margin-inline: auto; }

.pillars {
  display: grid;
  gap: clamp(1rem, 2.5vw, 2rem);
  grid-template-columns: 1fr;
  max-width: 76rem;
  margin-inline: auto;
  width: 100%;
}
@media (min-width: 761px) { .pillars { grid-template-columns: repeat(3, 1fr); } }
.pillar {
  padding: clamp(1.6rem, 3vw, 2.6rem);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 1.1rem;
  background: linear-gradient(160deg, rgba(56,142,187,0.1), rgba(255,255,255,0.02));
  display: grid;
  gap: 0.8rem;
  align-content: start;
}
.pillar__k {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: var(--t-lg);
  letter-spacing: -0.03em;
  text-transform: uppercase;
  color: var(--brand-bright);
}
.pillar:nth-child(2) .pillar__k { color: var(--brand-amber); }
.pillar p { opacity: 0.72; font-size: var(--t-body); }

.closing { text-align: center; }
.closing__box {
  border: 1.5px solid rgba(255,255,255,0.18);
  border-radius: 1.2rem;
  padding: clamp(2.5rem, 7vw, 6rem) clamp(1.5rem, 5vw, 4rem);
  max-width: 54rem;
  margin-inline: auto;
  display: grid;
  gap: 1.4rem;
  justify-items: center;
}
.closing__box .display { font-size: var(--t-xl); }

/* ==========================================================================
   Mobile / tablet: the rail stops being a rail.
   The six panels stack and read as ordinary vertical sections. JS rebinds
   their animations to vertical triggers at the same breakpoint.
   ========================================================================== */
@media (max-width: 900px) {
  .rail-outer { height: auto; overflow: visible; perspective: none; }
  .rail { display: block; width: 100%; transform: none !important; }
  .panel {
    width: 100%;
    flex: none;
    height: auto;
    min-height: 100svh;
  }
  .rail__hud, .rail__cue, .rail__flash { display: none; }
  .panel__stage svg { max-height: 50svh; }
  .stat-hero { text-align: left; }
}
