:root {
  --bg: #07080a;
  --fg: #e6ebf0;
  --dim: rgba(230, 235, 240, 0.55);
  --faint: rgba(230, 235, 240, 0.14);
  --accent: #c8f560;
  --hue: #c8f560; /* follows the current chapter */
  --gutter: clamp(16px, 2.4vw, 32px);
  --sans: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.is-loading { overflow: hidden; }
:where(button, label.btn, label.chip) { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--hue); color: var(--bg); }

.mono {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; z-index: 0; }
.grain {
  position: fixed; inset: -50%; z-index: 2; pointer-events: none; opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.9s steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 25% { transform: translate(-3%, 2%); }
  50% { transform: translate(2%, -3%); } 75% { transform: translate(-1%, -2%); }
}
.vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.75));
}
/* Brief wash of the chapter color on every kick */
.flash { position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0;
  background: radial-gradient(60% 60% at 50% 50%, var(--hue), transparent 70%); mix-blend-mode: screen; }

/* ---------- Cursor ---------- */
.cursor { position: fixed; left: 0; top: 0; z-index: 70; pointer-events: none; opacity: 0; transition: opacity 0.3s; }
body.has-cursor .cursor { opacity: 1; }
.cursor i {
  position: absolute; left: -18px; top: -18px; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--hue); transition: width 0.35s var(--ease), height 0.35s var(--ease), left 0.35s var(--ease), top 0.35s var(--ease), background 0.3s;
}
.cursor::after { content: ""; position: absolute; left: -2px; top: -2px; width: 4px; height: 4px; border-radius: 50%; background: var(--hue); }
.cursor.is-link i { left: -30px; top: -30px; width: 60px; height: 60px; background: color-mix(in srgb, var(--hue) 12%, transparent); }
.cursor span { position: absolute; left: 24px; top: 14px; white-space: nowrap; color: var(--hue); font-size: 9px; opacity: 0; transition: opacity 0.3s; }
.cursor.has-label span { opacity: 1; }
@media (hover: hover) and (pointer: fine) { body.has-cursor, body.has-cursor a, body.has-cursor button, body.has-cursor label, body.has-cursor summary { cursor: none; } }

/* ---------- Loader ---------- */
#loader {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: var(--gutter);
  transition: opacity 1.1s var(--ease), visibility 1.1s;
}
#loader.is-done { opacity: 0; visibility: hidden; }
.loader__bar { position: absolute; top: 0; left: 0; right: 0; height: 2px; }
.loader__bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s linear; }
.loader__count {
  font-weight: 300; font-size: clamp(88px, 20vw, 280px); line-height: 0.8;
  letter-spacing: -0.04em; font-variant-numeric: tabular-nums;
  transition: opacity 0.6s var(--ease), transform 0.8s var(--ease);
}
#loader.is-ready .loader__count { opacity: 0.12; transform: translateY(8px); }
.gate {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 24px; text-align: center;
  animation: rise 0.9s var(--ease) both;
}
.gate[hidden] { display: none; }
.gate__hint { color: var(--dim); }
.gate__row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, -40%); } }

/* ---------- Buttons ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; gap: 10px;
  padding: 16px 26px; border-radius: 999px; border: 1px solid var(--faint);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.03);
  transition: border-color 0.3s, background 0.3s, color 0.3s;
  will-change: transform;
}
.btn:hover { border-color: rgba(230, 235, 240, 0.5); }
.btn--primary { background: var(--hue); color: var(--bg); border-color: var(--hue); }
.btn__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(0.5); opacity: 0.5; } }
:focus-visible { outline: 1px solid var(--hue); outline-offset: 4px; }

/* ---------- HUD ---------- */
.hud {
  position: fixed; left: 0; right: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: var(--gutter); pointer-events: none;
  opacity: 0; transition: opacity 1s var(--ease) 0.4s;
}
body.is-in .hud { opacity: 1; }
.hud > * { pointer-events: auto; }
.hud--top { top: 0; z-index: 40; }
.hud--bottom { bottom: 0; align-items: end; }
.hud__left { color: var(--dim); transition: opacity 0.4s; }
.hud__left.is-swap { opacity: 0; }
.hud__right { justify-self: end; display: flex; align-items: center; gap: 22px; }
.hud__right-text { justify-self: end; color: var(--dim); font-variant-numeric: tabular-nums; }
.link { position: relative; padding: 4px 0; }
.link::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: currentColor;
  transform: scaleX(0); transform-origin: right; transition: transform 0.5s var(--ease);
}
.link:hover::after { transform: scaleX(1); transform-origin: left; }
#audioState { display: inline-block; min-width: 3ch; text-align: left; }
#audioToggle[aria-pressed="true"] #audioState { color: var(--hue); }

/* Centered, audio-reactive logo: each letter rides one band */
.logo { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 19px; letter-spacing: 0.04em; }
.logo__word { display: flex; align-items: flex-end; height: 22px; }
.logo__word b { display: inline-block; font-weight: 700; transform-origin: 50% 100%; transition: color 0.3s; }
.logo:hover .logo__word b { color: var(--hue); }
.logo__glyph { width: 26px; height: 12px; fill: var(--fg); overflow: visible; }
.logo__glyph circle, .logo__glyph path { transform-box: fill-box; transform-origin: center; }
.logo__glyph path { fill: var(--hue); }

.menu-btn { display: flex; gap: 3px; padding: 8px 0; }
.menu-btn i { width: 3px; height: 3px; border-radius: 50%; background: currentColor; transition: transform 0.4s var(--ease); }
.menu-btn:hover i:nth-child(1) { transform: translateY(-3px); }
.menu-btn:hover i:nth-child(3) { transform: translateY(3px); }
.menu-btn::after { display: none; }

.spectrum { display: flex; align-items: flex-end; gap: 5px; height: 44px; }
.spectrum i { width: 1px; height: 100%; background: var(--fg); opacity: 0.4; transform-origin: bottom; transform: scaleY(0.08); }
.spectrum i.hot { background: var(--hue); }

.progress { position: fixed; right: 6px; top: 50%; transform: translateY(-50%); height: 30vh; width: 1px; background: var(--faint); z-index: 20; }
.progress span { position: absolute; left: 0; top: 0; width: 1px; height: 100%; background: var(--hue); transform-origin: top; transform: scaleY(0); }

/* ---------- Chapters ---------- */
main { position: relative; z-index: 10; }
.chapter { min-height: 170vh; position: relative; display: flex; align-items: flex-start; justify-content: center; padding: 0 var(--gutter); }
.chapter > * { position: sticky; top: 0; height: 100vh; width: 100%; display: flex; flex-direction: column; justify-content: center; }
.chapter--hero { min-height: 150vh; }
.chapter--flow { min-height: auto; padding-top: 30vh; padding-bottom: 30vh; }
.chapter--flow > * { position: relative; height: auto; }

.hero-wrap { position: sticky; }
.hero {
  height: 100%; display: flex; flex-direction: column; justify-content: space-between;
  font-weight: 300; font-size: clamp(64px, min(13.5vw, 26vh), 230px); line-height: 0.86; letter-spacing: -0.045em;
  padding: calc(var(--gutter) * 2.6) 0 calc(var(--gutter) * 3.4); color: #dfe6ee;
}
.hero__line--b { align-self: flex-end; text-align: right; }
.lede {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  max-width: 470px; text-align: center; line-height: 1.8; color: var(--fg);
  text-shadow: 0 1px 20px rgba(0, 0, 0, 0.8);
}

.entry { align-items: center; text-align: center; gap: 26px; }
.title {
  font-weight: 400; font-size: clamp(44px, min(8vw, 15vh), 128px); line-height: 0.95; letter-spacing: -0.035em;
  text-shadow: 0 2px 40px rgba(0, 0, 0, 0.6);
}
.title sup { font-size: 13px; vertical-align: top; margin-left: 6px; position: relative; top: 0.6em; color: var(--hue); letter-spacing: 0; }
.desc { max-width: 440px; line-height: 1.8; color: var(--fg); text-shadow: 0 1px 16px rgba(0, 0, 0, 0.9); }
.tags { list-style: none; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.tags li { padding: 7px 12px; border: 1px solid var(--faint); border-radius: 999px; color: var(--dim); font-size: 10px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
@media (min-width: 900px) {
  .entry--left { align-items: flex-start; text-align: left; padding-left: 4vw; }
  .entry--left .tags { justify-content: flex-start; }
  .entry--right { align-items: flex-end; text-align: right; padding-right: 4vw; }
  .entry--right .tags { justify-content: flex-end; }
}
.kicker { color: var(--hue); }

/* ---------- Engine ---------- */
.engine { max-width: 1140px; margin: 0 auto; gap: 72px; }
.engine__head { max-width: 760px; display: flex; flex-direction: column; gap: 24px; }
.engine__lede { font-size: clamp(17px, 1.5vw, 20px); line-height: 1.6; font-weight: 300; text-shadow: 0 1px 18px rgba(0, 0, 0, 0.95); }
.steps { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--faint); border: 1px solid var(--faint); }
.steps li {
  background: rgba(7, 8, 10, 0.78); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  padding: 28px 24px 32px; display: flex; flex-direction: column; gap: 12px; min-height: 250px;
  transition: background 0.4s;
}
.steps li:hover { background: rgba(20, 22, 26, 0.85); }
.steps__n { color: var(--hue); }
.steps h3 { font-weight: 400; font-size: 28px; letter-spacing: -0.02em; }
.steps p { font-size: 14px; line-height: 1.65; color: rgba(230, 235, 240, 0.78); }
.stats__grid { list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(16px, 4vw, 64px); }
.stats__grid li { display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--faint); padding-top: 18px; }
.stats__grid b { font-weight: 300; font-size: clamp(56px, 9vw, 140px); line-height: 0.9; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.stats__grid span { color: var(--dim); }
.faq { max-width: 780px; display: flex; flex-direction: column; gap: 0; }
.faq h2 { margin-bottom: 18px; }
.faq details { border-top: 1px solid var(--faint); background: rgba(7, 8, 10, 0.55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.faq details:last-child { border-bottom: 1px solid var(--faint); }
.faq summary { cursor: pointer; list-style: none; padding: 20px 44px 20px 14px; font-size: 19px; position: relative; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-family: var(--mono); color: var(--hue); transition: transform 0.4s var(--ease); }
.faq details[open] summary::after { transform: translateY(-50%) rotate(45deg); }
.faq details p { padding: 0 44px 22px 14px; line-height: 1.7; color: rgba(230, 235, 240, 0.78); font-size: 15px; }

/* ---------- Outro ---------- */
.outro { align-items: center; text-align: center; gap: 24px; justify-content: flex-end; padding-bottom: 16vh; }
.outro .title { font-size: clamp(56px, min(11vw, 18vh), 180px); }
.follow { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 10px; color: var(--dim); }
.follow b { font-weight: 400; font-size: clamp(26px, 3vw, 40px); color: var(--fg); letter-spacing: -0.02em; transition: color 0.3s; }
.follow:hover b { color: var(--hue); }
.credit { position: absolute; bottom: calc(var(--gutter) * 3.6); color: var(--dim); font-size: 9px; text-transform: none; letter-spacing: 0.04em; }

/* ---------- Text reveal ---------- */
.split .ch { display: inline-block; opacity: 0; transform: translateY(0.35em); filter: blur(8px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease), filter 0.9s var(--ease); }
.split .w { display: inline-block; white-space: nowrap; }
.split.is-visible .ch { opacity: 1; transform: none; filter: none; }
.reveal { opacity: 0; transform: translateY(14px); transition: opacity 1s var(--ease) 0.25s, transform 1s var(--ease) 0.25s; }
.reveal.is-visible { opacity: 1; transform: none; }
.lede.reveal { transform: translate(-50%, calc(-50% + 14px)); }
.lede.reveal.is-visible { transform: translate(-50%, -50%); }

/* ---------- Index overlay ---------- */
.index {
  position: fixed; inset: 0; z-index: 30; display: flex; padding: 88px var(--gutter);
  background: rgba(7, 8, 10, 0.72); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  opacity: 0; visibility: hidden; transition: opacity 0.6s var(--ease), visibility 0.6s; overflow-y: auto;
}
.index.is-open { opacity: 1; visibility: visible; }
.index__inner { margin: auto; width: min(900px, 100%); display: flex; flex-direction: column; gap: 32px; }
.index__label { color: var(--dim); margin-bottom: 10px; }
.index ol { list-style: none; }
.index li { border-top: 1px solid var(--faint); overflow: hidden; }
.index li:last-child { border-bottom: 1px solid var(--faint); }
.index li button {
  width: 100%; display: flex; align-items: baseline; gap: 20px; padding: 10px 0; text-align: left;
  font-size: clamp(22px, min(4.4vw, 5vh), 54px); font-weight: 300; letter-spacing: -0.03em;
  transform: translateY(100%); transition: transform 0.8s var(--ease), color 0.3s, padding 0.4s var(--ease);
}
.index.is-open li button { transform: none; }
.index li button:hover { color: var(--hue); padding-left: 14px; }
.index li button .mono { color: var(--dim); min-width: 3ch; }
.index li.is-current button { color: var(--hue); }
.index__foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; }
.source-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 10px 16px; border-radius: 999px; border: 1px solid var(--faint); font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; transition: border-color 0.3s, color 0.3s; }
.chip:hover { border-color: var(--dim); }
.chip.is-active { border-color: var(--hue); color: var(--hue); }

/* ---------- Drop + toast ---------- */
.drop {
  position: fixed; inset: 12px; z-index: 60; border: 1px dashed var(--hue); border-radius: 18px;
  display: grid; place-items: center; background: rgba(7, 8, 10, 0.6);
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
  font-size: clamp(40px, 7vw, 90px); font-weight: 300; letter-spacing: -0.03em;
}
.drop.is-on { opacity: 1; }
.toast {
  position: fixed; left: 50%; bottom: 90px; z-index: 60; transform: translate(-50%, 20px);
  padding: 10px 16px; border-radius: 999px; background: var(--fg); color: var(--bg);
  opacity: 0; pointer-events: none; transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.noscript { position: relative; z-index: 10; padding: 40px var(--gutter); max-width: 640px; }

@media (max-width: 899px) {
  .steps { grid-template-columns: 1fr 1fr; }
  .stats__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .hud__left { font-size: 9px; }
  .hud__right { gap: 14px; }
  .spectrum { gap: 3px; height: 28px; }
  .hud--top { background: linear-gradient(var(--bg) 30%, transparent); }
  .hero { padding-bottom: calc(var(--gutter) * 5); }
  .entry { justify-content: flex-end; padding-bottom: 16vh; gap: 18px; }
  .title { font-size: 44px; }
  .steps { grid-template-columns: 1fr; }
  .steps li { min-height: 0; }
  .outro { padding-bottom: 20vh; }
}
@media (max-height: 640px) { .tags { display: none; } }
@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .split .ch, .reveal { transition-duration: 0.01s; filter: none; }
  .flash { display: none; }
}

.index__link { font-size: 15px; margin-bottom: 4px; }
.index__link a { color: var(--hue); }
