*, *::before, *::after { box-sizing: border-box; }
html { background: #082A20; }
body {
  margin: 0;
  background: #082A20;
  color: #F5F9FC;
  font-family: var(--f-body, "Inter", system-ui, sans-serif);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
html.record, html.record body { overflow: hidden; scrollbar-width: none; }
html.record ::-webkit-scrollbar { display: none; }

#scene {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  display: block;
  z-index: 0;
}
.track { height: 760vh; }

.scrim {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(90deg, rgba(3, 14, 11, 0.62) 0%, rgba(3, 14, 11, 0.32) 30%, rgba(3, 14, 11, 0) 52%);
}
.vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(120% 90% at 60% 45%, rgba(0,0,0,0) 55%, rgba(2, 8, 7, 0.55) 100%);
}

/* Top bar */
.bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px clamp(18px, 4vw, 48px);
}
.bar__logo img { height: 34px; width: auto; display: block; }
.bar__nav { display: flex; align-items: center; gap: 22px; }
.bar__link {
  color: rgba(245, 249, 252, 0.82); text-decoration: none;
  font-size: 13px; letter-spacing: 0.08em;
}
.bar__link:hover { color: #fff; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 14px 26px;
  background: #F5F9FC; color: #0D3B2E;
  border: 1px solid #F5F9FC; border-radius: 0;
  font-family: var(--f-body); font-size: 13px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; text-decoration: none;
  transition: background .25s, color .25s, border-color .25s;
}
.btn:hover { background: #D3E8F6; border-color: #D3E8F6; }
.btn--small { padding: 10px 16px; font-size: 11px; }
.btn--ghost { background: transparent; color: #F5F9FC; border-color: rgba(211, 232, 246, 0.5); }
.btn--ghost:hover { background: rgba(211, 232, 246, 0.12); border-color: #D3E8F6; color: #fff; }

/* Chapters */
.chapters { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
.chapter {
  position: absolute;
  left: clamp(20px, 6vw, 96px);
  bottom: clamp(56px, 13vh, 140px);
  width: min(32rem, 44vw);
  opacity: 0; visibility: hidden;
  will-change: opacity, transform;
}
.chapter.is-on { visibility: visible; pointer-events: auto; }
.eyebrow {
  margin: 0 0 18px;
  font-size: 11px; font-weight: 500; letter-spacing: 0.24em; text-transform: uppercase;
  color: #8DBFE6;
}
.eyebrow::before {
  content: ""; display: inline-block; width: 28px; height: 1px; margin-right: 12px;
  vertical-align: middle; background: #8DBFE6;
}
.chapter__title {
  margin: 0 0 20px;
  font-family: var(--f-heading); font-weight: 500;
  font-size: clamp(40px, 5.2vw, 76px); line-height: 1.0; letter-spacing: -0.01em;
  color: #F5F9FC;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.35);
}
.chapter__title--md { font-size: clamp(32px, 3.7vw, 54px); line-height: 1.06; }
.chapter__body {
  margin: 0; max-width: 26rem;
  font-size: 15px; line-height: 1.65; color: rgba(245, 249, 252, 0.78);
}
.chapter__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }

.formula {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 14px;
  margin: 4px 0 22px;
  font-family: var(--f-heading); font-size: clamp(24px, 2.4vw, 34px); font-style: italic;
  color: rgba(245, 249, 252, 0.8);
}
.formula b { font-weight: 500; color: #8DBFE6; }
.formula i { font-style: normal; color: rgba(211, 232, 246, 0.55); font-size: 0.8em; }
.formula__out { color: #F5F9FC; font-style: normal; font-weight: 500; }

/* HUD */
.hud {
  position: fixed; right: clamp(18px, 4vw, 48px); bottom: 34px; z-index: 6;
  display: flex; align-items: center; gap: 14px;
  font-size: 11px; letter-spacing: 0.2em; color: rgba(211, 232, 246, 0.75);
}
.hud__line { position: relative; width: 120px; height: 1px; background: rgba(211, 232, 246, 0.25); overflow: hidden; }
.hud__fill { position: absolute; inset: 0; background: #8DBFE6; transform-origin: left center; transform: scaleX(0); }

.cue {
  position: fixed; left: 50%; bottom: 26px; z-index: 6; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase; color: rgba(211, 232, 246, 0.7);
}
.cue i { display: block; width: 1px; height: 34px; background: linear-gradient(#8DBFE6, rgba(141, 191, 230, 0)); }

/* Portrait / phone */
@media (max-aspect-ratio: 1/1) {
  .scrim { background: linear-gradient(0deg, rgba(3, 14, 11, 0.8) 0%, rgba(3, 14, 11, 0.45) 34%, rgba(3, 14, 11, 0) 58%); }
  .chapter { left: 22px; right: 22px; width: auto; bottom: 74px; }
  .chapter__title { font-size: clamp(36px, 10.5vw, 52px); }
  .chapter__title--md { font-size: clamp(28px, 8vw, 40px); }
  .chapter__body { font-size: 14px; }
  .bar { padding: 16px 18px; }
  .bar__logo img { height: 28px; }
  .bar__link { display: none; }
  .hud { bottom: 26px; right: 22px; }
  .hud__line { width: 70px; }
  .cue { display: none; }
}

/* No WebGL fallback */
html.no-webgl body { background: radial-gradient(120% 80% at 70% 20%, #0D3B2E, #082A20 70%); }
html.no-webgl #scene, html.no-webgl .hud, html.no-webgl .cue, html.no-webgl .track, html.no-webgl .vignette, html.no-webgl .scrim { display: none; }
html.no-webgl .chapters { position: static; padding: 120px 0 60px; }
html.no-webgl .chapter {
  position: static; opacity: 1; visibility: visible; pointer-events: auto;
  width: auto; max-width: 40rem; margin: 0 clamp(20px, 6vw, 96px) 96px;
}

@media (prefers-reduced-motion: reduce) {
  .chapter { transition: none; }
}
