/* ============================================================
   Ghost Highway — a scroll-driven night drive
   ============================================================ */

:root {
  --ink:     #070b14;   /* deep night                            */
  --dusk:    #0b111d;   /* wet asphalt blue                      */
  --tunnel:  #1a1108;   /* tunnel umber                          */
  --predawn: #12283c;   /* clearing sky                          */
  --dawn:    #b96a4a;   /* coral sunrise                         */
  --sodium:  #ffb24d;   /* streetlight amber                     */
  --coral:   #ff6a4d;   /* tail-light coral                      */
  --mist:    #e7edf2;   /* headlight white                       */

  --font-display: "Michroma", sans-serif;
  --font-body:    "Space Grotesk", sans-serif;
  --font-mono:    "IBM Plex Mono", monospace;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--ink);
  color: var(--mist);
  font-family: var(--font-body);
  font-size: 1.15rem;
  font-weight: 300;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ---------- fixed WebGL canvas ---------- */

#world {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
}

/* ---------- progress bar ---------- */

.progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 40;
  background: rgba(231, 237, 242, 0.07);
}
.progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--sodium), var(--coral));
}

/* ---------- odometer ---------- */

.odometer {
  position: fixed;
  left: 1.4rem;
  bottom: 1.2rem;
  z-index: 40;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(231, 237, 242, 0.55);
}
.odometer #odo { color: var(--sodium); }

@media (max-width: 700px) { .odometer { display: none; } }

/* ---------- sound toggle ---------- */

.sound {
  position: fixed;
  right: 1.4rem;
  bottom: 1.2rem;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.8rem;
  background: rgba(7, 11, 20, 0.55);
  border: 1px solid rgba(231, 237, 242, 0.16);
  border-radius: 999px;
  color: rgba(231, 237, 242, 0.6);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s;
}
.sound:hover { color: var(--mist); border-color: rgba(231, 237, 242, 0.35); }
.sound.on { color: var(--sodium); border-color: rgba(255, 178, 77, 0.45); }
.sound__bars { display: flex; align-items: flex-end; gap: 2px; height: 10px; }
.sound__bars i {
  width: 2px;
  height: 3px;
  background: currentColor;
  border-radius: 1px;
}
.sound.on .sound__bars i { animation: eq 1.1s ease-in-out infinite; }
.sound.on .sound__bars i:nth-child(2) { animation-delay: 0.18s; }
.sound.on .sound__bars i:nth-child(3) { animation-delay: 0.36s; }
.sound.on .sound__bars i:nth-child(4) { animation-delay: 0.54s; }
@keyframes eq {
  0%, 100% { height: 3px; }
  50% { height: 10px; }
}

/* ---------- chapter nav ---------- */

.chapter-nav {
  position: fixed;
  right: 1.4rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.chapter-nav a {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--mist);
}
.chapter-nav i {
  width: 8px; height: 8px;
  border-radius: 50%;
  border: 1px solid var(--sodium);
  background: transparent;
  transition: background 0.3s, transform 0.3s;
  flex: none;
}
.chapter-nav em {
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0;
  transform: translateX(6px);
  transition: opacity 0.25s, transform 0.25s;
  white-space: nowrap;
}
.chapter-nav a:hover em,
.chapter-nav a.active em { opacity: 0.9; transform: none; }
.chapter-nav a.active i { background: var(--sodium); transform: scale(1.35); }

@media (max-width: 900px) { .chapter-nav { display: none; } }

/* ---------- chapters ---------- */

main { position: relative; z-index: 10; }

.chapter { position: relative; }
.chapter--hero      { min-height: 100vh; min-height: 100dvh; }
.chapter--sodium    { min-height: 200vh; }
.chapter--tunnel    { min-height: 170vh; }
.chapter--guardrail { min-height: 180vh; }
.chapter--dawn      { min-height: 190vh; }

.copy-wrap {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  padding: 0 clamp(1.4rem, 6vw, 6rem);
}

.copy {
  max-width: 32rem;
  text-shadow: 0 2px 26px rgba(2, 4, 10, 0.9), 0 1px 3px rgba(2, 4, 10, 0.95);
}
.copy--left   { margin-right: auto; }
.copy--right  { margin-left: auto; text-align: right; padding-right: 3rem; }
.copy--center { margin: 0 auto; text-align: center; max-width: 46rem; }

/* soft scrim so copy stays readable against the bright dawn sky */
.chapter--dawn .copy {
  background: radial-gradient(ellipse at center, rgba(7, 11, 20, 0.42) 0%, rgba(7, 11, 20, 0) 70%);
  padding: 3rem 3.5rem;
}

/* reveal */
.copy > * {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.9s ease, transform 0.9s ease;
}
.copy > *:nth-child(2) { transition-delay: 0.12s; }
.copy > *:nth-child(3) { transition-delay: 0.24s; }
.copy > *:nth-child(4) { transition-delay: 0.36s; }
.is-inview .copy > * { opacity: 1; transform: none; }

/* type */
.kicker {
  font-family: var(--font-mono);
  font-size: clamp(0.68rem, 1.1vw, 0.82rem);
  font-weight: 500;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--sodium);
  margin-bottom: 1.2rem;
}
.brand {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.5rem, 9.5vw, 7rem);
  line-height: 1.04;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 1.6rem;
}
.copy h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.4rem, 3.4vw, 2.4rem);
  line-height: 1.22;
  letter-spacing: 0.02em;
  margin-bottom: 1.1rem;
}
.lede {
  font-size: clamp(1.02rem, 1.55vw, 1.22rem);
  opacity: 0.92;
}
.lede em { color: var(--sodium); font-style: normal; }

.cta-row { margin-top: 2.4rem; }
.cta {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--mist);
  text-decoration: none;
  border: 1px solid var(--sodium);
  padding: 0.9rem 2.1rem;
  transition: background 0.3s, color 0.3s;
}
.cta:hover { background: var(--sodium); color: var(--ink); }

/* ---------- no-WebGL fallback ---------- */

body.no-webgl #world { display: none; }
body.no-webgl .chapter--hero      { background: linear-gradient(180deg, #04070d 0%, #0b111d 55%, #241a10 100%); }
body.no-webgl .chapter--sodium    { background: linear-gradient(180deg, #05080f 0%, #12100c 60%, #2a1c0c 100%); }
body.no-webgl .chapter--tunnel    { background: linear-gradient(180deg, #120b05 0%, #1a1108 50%, #2e1c0a 100%); }
body.no-webgl .chapter--guardrail { background: linear-gradient(180deg, #081120 0%, #12283c 65%, #2d4254 100%); }
body.no-webgl .chapter--dawn      { background: linear-gradient(180deg, #1c3a5c 0%, #7a5648 62%, #d99a64 100%); }

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .copy > * { transition: none; opacity: 1; transform: none; }
  .sound.on .sound__bars i { animation: none; height: 7px; }
}
