/* =============================================================================
   How Life Works — glossy CGI-on-white design system
   ========================================================================== */

:root {
  --white: #ffffff;
  --paper: #fbfcfe;
  --ink: #10141c;
  --ink-soft: #3c4658;
  --muted: #5d6579; /* darkened to clear WCAG AA (~5:1) on white for small text */
  --hair: #e7ebf3;
  --hair-strong: #d7dde9;

  --cyan: #16a6c6;
  --teal: #12a189;
  --coral: #f8604f;
  --violet: #6f52f4;
  --gold: #e79a1f;
  --rose: #f6478a;
  --sky: #3d7bff;
  --green: #23b978;

  --shadow-soft: 0 30px 60px -30px rgba(24, 39, 75, 0.28);
  --shadow-card: 0 2px 4px rgba(16, 20, 28, 0.03), 0 18px 40px -24px rgba(24, 39, 75, 0.22);

  --maxw: 1180px;
  --measure: 46ch;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --font: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", "Roboto Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--white);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* very soft cool vignette so pure-white objects have a hair of context */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(120% 80% at 50% -10%, #ffffff 0%, #f6f8fc 55%, #eef2f9 100%);
  pointer-events: none;
}

/* The shared WebGL canvas is injected by common.js as #gl (position fixed). */

a { color: inherit; text-decoration: none; }

/* ------------------------------------------------------------------ nav ---- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px clamp(18px, 4vw, 40px);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(1.6) blur(18px);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  border-bottom: 1px solid var(--hair);
}
.nav__brand {
  display: flex; align-items: center; gap: 11px;
  font-weight: 650; letter-spacing: -0.01em; font-size: 15px;
}
.nav__brand .dot {
  width: 22px; height: 22px; border-radius: 50%;
  background: conic-gradient(from 120deg, var(--cyan), var(--violet), var(--coral), var(--gold), var(--cyan));
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.85), 0 2px 6px rgba(24,39,75,0.25);
}
.nav__brand small { color: var(--muted); font-weight: 500; }
.nav__links { display: flex; gap: 4px; align-items: center; }
.nav__links a {
  font-size: 13px; color: var(--ink-soft); font-weight: 500;
  padding: 7px 12px; border-radius: 999px; transition: background .2s, color .2s;
}
.nav__links a:hover { background: var(--paper); color: var(--ink); }
.nav__links a.active { color: var(--ink); background: var(--paper); }
.nav__links a.active::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--cyan); margin-right: 7px; vertical-align: middle;
  background: linear-gradient(120deg, var(--cyan), var(--violet));
}
.nav__cta {
  font-size: 13px; font-weight: 600; padding: 8px 16px; border-radius: 999px;
  background: var(--ink); color: #fff !important;
}
@media (max-width: 820px) { .nav__links { display: none; } }

/* progress bar under nav */
.progress {
  position: fixed; top: 0; left: 0; height: 3px; z-index: 60;
  width: var(--p, 0%);
  background: linear-gradient(90deg, var(--cyan), var(--violet), var(--coral));
  transition: width .1s linear;
}

/* --------------------------------------------------------------- layout ---- */
main { position: relative; z-index: 1; }

.figure { position: relative; }
/* Contact shadow that grounds glossy objects on the white page. */
.figure::after {
  content: "";
  position: absolute;
  left: 50%; bottom: 8%;
  width: 62%; height: 10%;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(24,39,75,0.22), rgba(24,39,75,0.0) 72%);
  filter: blur(6px);
  z-index: -1;
  pointer-events: none;
}

/* ----------------------------------------------------------------- hero ---- */
.hero {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 96px 20px 40px;
  overflow: hidden;
}
.hero .figure--hero {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
}
.hero .figure--hero::after { display: none; }
.hero__copy { position: relative; z-index: 2; max-width: 900px; pointer-events: none; }
/* soft white halo so headings stay legible over the busy 3D behind them */
.hero__copy::before, .outro__copy::before {
  content: "";
  position: absolute;
  inset: -14% -16%;
  z-index: -1;
  background: radial-gradient(58% 52% at 50% 46%, rgba(255,255,255,0.92) 0%, rgba(255,255,255,0.7) 42%, rgba(255,255,255,0) 76%);
  filter: blur(8px);
  pointer-events: none;
}
.hero__copy .eyebrow { justify-content: center; }
.hero h1 {
  font-size: clamp(2.7rem, 8vw, 6.2rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
  font-weight: 680;
  margin: 14px 0 0;
}
.hero h1 .grad {
  background: linear-gradient(100deg, var(--cyan), var(--violet) 55%, var(--coral));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero__dek {
  font-size: clamp(1.05rem, 2.2vw, 1.4rem);
  color: var(--ink-soft);
  max-width: 40ch; margin: 22px auto 0; line-height: 1.5;
}
.hero__meta { margin-top: 26px; font-size: 13px; color: var(--muted); letter-spacing: .02em; }
.scrollcue {
  position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%);
  font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.scrollcue .bar { width: 1px; height: 34px; background: linear-gradient(var(--muted), transparent); animation: cue 1.8s var(--ease) infinite; }
@keyframes cue { 0% { transform: scaleY(0); transform-origin: top; } 45% { transform: scaleY(1); transform-origin: top; } 55% { transform: scaleY(1); transform-origin: bottom; } 100% { transform: scaleY(0); transform-origin: bottom; } }

/* ------------------------------------------------------------- chapters ---- */
.chapter { position: relative; padding: clamp(70px, 12vh, 150px) clamp(18px, 5vw, 56px); }
.chapter__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: clamp(28px, 5vw, 76px);
  align-items: stretch;
}
.chapter--flip .chapter__figure { order: 2; }
.chapter__figure { position: relative; }
.chapter__figure .figure {
  aspect-ratio: 1 / 1;
  width: 100%;
  position: sticky;
  top: 12vh;
}
.chapter__text { max-width: 52ch; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-soft); /* readable text; the accent lives in the decorative bar */
}
.eyebrow::before {
  content: ""; width: 22px; height: 2px; border-radius: 2px; background: var(--accent, var(--cyan)); opacity: .95;
}
.eyebrow .num { color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: .05em; }

.chapter h2 {
  font-size: clamp(1.9rem, 4.2vw, 3.05rem);
  line-height: 1.04;
  letter-spacing: -0.025em;
  font-weight: 660;
  margin: 16px 0 0;
}
.chapter .dek {
  font-size: clamp(1.05rem, 1.7vw, 1.28rem);
  color: var(--ink-soft);
  margin: 16px 0 6px;
  line-height: 1.45;
  font-weight: 450;
}
.chapter p { color: var(--ink-soft); margin: 14px 0; font-size: 1.02rem; }
.chapter p strong { color: var(--ink); font-weight: 600; }

.pull {
  margin: 26px 0 6px;
  padding: 4px 0 4px 20px;
  border-left: 3px solid var(--accent, var(--cyan));
  font-size: clamp(1.15rem, 2vw, 1.5rem);
  line-height: 1.32;
  letter-spacing: -0.01em;
  color: var(--ink);
  font-weight: 500;
}

.terms { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 10px; }
.terms li {
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--hair);
  border-radius: 14px;
  padding: 13px 16px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(6px);
}
.terms .t { font-weight: 640; font-size: .96rem; letter-spacing: -0.01em; }
.terms .t::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent, var(--cyan)); margin-right: 9px; vertical-align: middle;
}
.terms .d { color: var(--muted); font-size: .88rem; line-height: 1.5; margin-top: 3px; }

.scene-caption {
  margin-top: 14px; font-size: 12px; color: var(--muted); text-align: center;
  letter-spacing: .01em;
}

/* Section divider tag with big index numeral watermark */
.chapter__index {
  position: absolute; top: clamp(24px, 6vh, 60px); right: clamp(16px, 4vw, 60px);
  font-size: clamp(4rem, 12vw, 9rem); font-weight: 700; letter-spacing: -0.04em;
  color: var(--ink); opacity: 0.035; line-height: 1; pointer-events: none; user-select: none;
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------- reveal anim ------ */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity .9s var(--ease), transform .9s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.reveal.d1 { transition-delay: .07s; }
.reveal.d2 { transition-delay: .14s; }
.reveal.d3 { transition-delay: .21s; }
.reveal.d4 { transition-delay: .28s; }

/* -------------------------------------------------------------- outro ------ */
.outro {
  min-height: 92svh; display: grid; place-items: center; text-align: center;
  padding: 100px 22px; position: relative; overflow: hidden;
}
.outro .figure--hero { position: absolute; inset: 0; width: 100%; height: 100%; }
.outro__copy { position: relative; z-index: 2; max-width: 720px; }
.outro h2 { font-size: clamp(2rem, 5vw, 3.6rem); letter-spacing: -0.025em; line-height: 1.03; font-weight: 660; margin: 12px 0 0; }
.outro p { color: var(--ink-soft); font-size: clamp(1.02rem, 1.8vw, 1.25rem); margin: 20px auto 0; max-width: 46ch; }

/* --------------------------------------------------------------- footer ---- */
.site-footer {
  border-top: 1px solid var(--hair);
  padding: 46px clamp(18px, 5vw, 56px);
  background: rgba(255,255,255,0.7);
  position: relative; z-index: 1;
}
.site-footer .inner { max-width: var(--maxw); margin: 0 auto; display: flex; flex-wrap: wrap; gap: 20px 40px; justify-content: space-between; align-items: baseline; }
.site-footer .cols { display: flex; flex-wrap: wrap; gap: 8px 26px; font-size: 13px; color: var(--muted); }
.site-footer a:hover { color: var(--ink); }
.site-footer .fine { font-size: 12px; color: var(--muted); max-width: 52ch; line-height: 1.6; }
.site-footer strong { color: var(--ink-soft); font-weight: 600; }

/* ---------------------------------------------------------- responsive ----- */
@media (max-width: 900px) {
  .chapter__inner { grid-template-columns: 1fr; gap: 8px; }
  .chapter--flip .chapter__figure { order: 0; }
  .chapter__figure .figure { position: relative; top: 0; max-width: 460px; margin: 0 auto; aspect-ratio: 1 / 1; }
  .chapter__text { max-width: none; }
  .chapter__index { font-size: 5rem; opacity: 0.04; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { transition: none; opacity: 1; transform: none; }
  .scrollcue .bar { animation: none; }
}

/* ------------------------------------------------- WebGL unavailable -------- */
/* If the 3D engine can't initialize, drop the empty figure placeholders and let
   the text essay stand on its own — the content stays fully readable. */
.no-webgl #gl { display: none; }
.no-webgl .figure::after,
.no-webgl .scene-caption,
.no-webgl .chapter__figure,
.no-webgl .figure--hero { display: none; }
.no-webgl .chapter__inner { grid-template-columns: 1fr; }
.no-webgl .hero, .no-webgl .outro { min-height: auto; padding-top: 128px; padding-bottom: 72px; }
.no-webgl .scrollcue { display: none; }
