:root {
  --paper: #ECE8DF;
  --ink: #0E0E0F;
  --signal: #FF3B1F;
  --serif: "Fraunces", ui-serif, Georgia, serif;
  --flex: "Roboto Flex", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --gutter: clamp(16px, 3vw, 44px);
  --ease: cubic-bezier(.7, 0, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { overflow-x: clip; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .9s cubic-bezier(.2, .7, .2, 1), color .9s cubic-bezier(.2, .7, .2, 1);
}
body[data-tone="ink"]    { background-color: var(--ink);    color: var(--paper); }
body[data-tone="signal"] { background-color: var(--signal); color: var(--ink); }

::selection { background: var(--signal); color: var(--ink); }

p { margin: 0; }
a { color: inherit; }

.label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* ---------- atmosphere ---------- */

.grain {
  position: fixed; inset: -64px;
  z-index: 50; pointer-events: none;
  opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.ruler {
  position: fixed; top: 0; bottom: 0; left: 0;
  width: 22px; z-index: 40; pointer-events: none;
  opacity: .45;
  /* short tick every 12px, long tick every 60px; JS scrolls them via --ry */
  background-image:
    linear-gradient(to bottom, currentColor 0 1px, transparent 1px),
    linear-gradient(to bottom, currentColor 0 1px, transparent 1px);
  background-size: 7px 12px, 16px 60px;
  background-position: 0 var(--ry, 0px), 0 var(--ry, 0px);
  background-repeat: repeat-y, repeat-y;
}

/* ---------- HUD ---------- */

.hud {
  position: fixed; left: 0; right: 0; z-index: 45;
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 0 var(--gutter);
  pointer-events: none;
}
.hud-top { top: 14px; }
.hud-mark {
  pointer-events: auto;
  font-family: var(--serif);
  font-size: 15px; font-style: italic;
  font-variation-settings: "opsz" 14;
  text-decoration: none;
  letter-spacing: -.01em;
}
.hud-mark span { opacity: .45; }
.hud-depth {
  font-family: var(--mono);
  font-size: 13px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}

/* ---------- I. hero ---------- */

.hero { height: 230vh; position: relative; }
.hero-pin {
  position: sticky; top: 0;
  height: 100vh; height: 100svh;
  overflow: hidden;
  display: flex; flex-direction: column; justify-content: center;
  padding: 0 var(--gutter);
}
.hero-kicker { margin-bottom: 2.5vh; opacity: .6; }
.title {
  margin: 0;
  font-weight: 300;
  font-size: clamp(56px, 16vw, 330px);
  line-height: .84;
  letter-spacing: -.045em;
  font-variation-settings: "opsz" 144, "SOFT" 0, "WONK" 0;
}
.title .line { display: block; white-space: nowrap; }
.word { display: inline-block; white-space: nowrap; }
.ch { display: inline-block; }

.hero .ch {
  animation: drop-in 1.2s cubic-bezier(.2, .9, .1, 1) backwards;
  animation-delay: calc(var(--i) * 45ms + 150ms);
}
@keyframes drop-in {
  from { translate: 0 -.7em; opacity: 0; }
  to   { translate: 0 0;     opacity: 1; }
}

.hero-meta {
  position: absolute; left: var(--gutter); right: var(--gutter); bottom: 44px;
  display: flex; justify-content: space-between; gap: 16px;
}
.hero-scroll i {
  display: inline-block; font-style: normal;
  animation: nudge 1.6s var(--ease) infinite;
}
@keyframes nudge { 50% { transform: translateY(5px); } }

/* ---------- II. stairs ---------- */

.stairs { height: 280vh; position: relative; }
.stairs-pin {
  position: sticky; top: 0;
  height: 100vh; height: 100svh;
  overflow: hidden;
  display: flex; flex-direction: column; justify-content: center;
  padding: 0 var(--gutter);
  gap: 3vh;
}
.stairs-pin > .label { opacity: .6; }
.step {
  position: relative;
  font-family: var(--flex);
  font-size: clamp(44px, 12.5vh, 180px);
  line-height: .8;
  letter-spacing: -.02em;
  white-space: nowrap;
  width: max-content;
}
.step .spec {
  position: absolute; left: 100%; top: .1em;
  margin-left: 14px;
  font-family: var(--mono); font-size: 10px; letter-spacing: .06em;
  font-variation-settings: normal;
  white-space: nowrap; opacity: .55;
}

/* ---------- III. things ---------- */

.things { padding: 22vh var(--gutter) 26vh calc(var(--gutter) + 12px); }
.things-head {
  display: flex; justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid currentColor;
}
.things-head span:last-child::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--signal); margin-right: 8px; vertical-align: 1px;
  animation: blink 1.2s steps(2, jump-none) infinite;
}
.things-list { list-style: none; margin: 0; padding: 0; }

.thing {
  display: grid;
  grid-template-columns: 4ch 1fr auto;
  align-items: baseline;
  column-gap: 2vw;
  padding: 3.2vw 0 2.4vw;
  border-bottom: 1px solid color-mix(in srgb, currentColor 22%, transparent);
}
.thing .n, .thing .aside { opacity: .55; }
.thing .aside { text-align: right; }

.thing .w {
  display: block;
  font-size: clamp(44px, 10.5vw, 190px);
  line-height: .9;
  letter-spacing: -.03em;
  clip-path: inset(-25% -10% 125% -10%);
  transform: translateY(-30%);
  transition: clip-path 1.1s var(--ease), transform 1.1s var(--ease);
}
.thing.in .w { clip-path: inset(-25% -10% -25% -10%); transform: none; }

/* 01 markets — condensed wire headline */
.t-markets .w {
  font-family: var(--flex);
  text-transform: uppercase;
  font-variation-settings: "wdth" 25, "wght" 860, "opsz" 144;
  letter-spacing: -.005em;
}
.t-markets .aside { color: var(--signal); opacity: 1; font-weight: 600; }

/* 02 ice — soft italic, letters calving */
.t-ice .w {
  font-style: italic; font-weight: 200;
  font-variation-settings: "opsz" 144, "SOFT" 100;
}
.t-ice .ch {
  animation: calve var(--d, 5s) ease-in-out var(--dl, 0s) infinite alternate;
}
@keyframes calve { to { transform: translateY(.14em) rotate(var(--rot, 2deg)); } }

/* 03 sun — split flap */
.t-sun .w { font-family: var(--mono); font-weight: 600; font-size: clamp(36px, 8.5vw, 150px); display: flex; gap: .07em; letter-spacing: 0; }
.tile {
  position: relative;
  display: inline-grid; place-items: center;
  width: .9em; height: 1.12em;
  font-size: .82em;
  border-radius: .07em;
  background: color-mix(in srgb, currentColor 11%, transparent);
}
.tile::after {
  content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px;
  background: var(--ink);
}
.tile.gap { background: none; width: .45em; }
.tile.gap::after { display: none; }

/* 04 curtain — spaced caps, a curtain falls */
.t-curtain .w {
  position: relative; width: max-content; max-width: 100%;
  text-transform: uppercase; font-weight: 400;
  font-size: clamp(30px, 6.5vw, 120px);
  letter-spacing: .3em;
  font-variation-settings: "opsz" 144;
}
.t-curtain .w::after {
  content: ""; position: absolute; inset: -.15em -.1em -.1em -.25em;
  background: repeating-linear-gradient(90deg, currentColor 0 .34em, color-mix(in srgb, currentColor 70%, transparent) .34em .38em);
  transform-origin: top;
  transform: scaleY(0);
}

/* 05 bass — ultra wide, thumping at 120bpm */
.t-bass .w {
  font-family: var(--flex);
  font-variation-settings: "wdth" 151, "wght" 1000, "opsz" 144;
  letter-spacing: -.04em;
  transform-origin: left bottom;
}
.t-bass.in .w { animation: thump .5s cubic-bezier(.2, 0, .2, 1) infinite; }
@keyframes thump { 0% { scale: 1.035 .88; } 35%, 100% { scale: 1 1; } }

/* 06 house — wonky heavy serif that collapses */
.t-house .w {
  font-weight: 900;
  font-variation-settings: "opsz" 144, "SOFT" 30, "WONK" 1;
}
.t-house .ch { transition: transform 1.6s cubic-bezier(.6, 0, .25, 1.4) 1.2s; transform-origin: 50% 100%; }
.t-house.in .ch { transform: translateY(var(--y)) rotate(var(--r)); }

/* 07 battery — fine print among giants */
.t-battery { padding: 1.6vw 0 1.4vw; }
.t-battery .w {
  display: flex; align-items: center; gap: .9em;
  font-family: var(--mono); font-size: clamp(13px, 1.4vw, 20px);
  letter-spacing: 0;
}
.batt {
  position: relative; display: inline-block;
  width: 2.3em; height: 1.1em;
  border: 1.5px solid currentColor; border-radius: .22em;
}
.batt::before {
  content: ""; position: absolute; left: 2px; top: 2px; bottom: 2px; width: 9%;
  background: var(--signal); border-radius: 1px;
  animation: blink 1s steps(2, jump-none) infinite;
}
.batt::after {
  content: ""; position: absolute; right: -4px; top: 30%; height: 40%; width: 2.5px;
  background: currentColor; border-radius: 0 1px 1px 0;
}
@keyframes blink { 50% { opacity: 0; } }

/* 08 lights */
.t-lights .w {
  font-style: italic; font-weight: 300;
  font-variation-settings: "opsz" 144;
}

/* ---------- IV. gravity ---------- */

.gravity { height: 340vh; position: relative; }
.gravity-pin {
  position: sticky; top: 0;
  height: 100vh; height: 100svh;
  overflow: hidden;
  display: flex; flex-direction: column; justify-content: center;
  gap: 4vh;
  padding: 0 var(--gutter) 0 calc(var(--gutter) + 12px);
}
.gravity-pin > .label { opacity: .6; }
.prose {
  max-width: 19em;
  font-size: clamp(26px, 4.3vw, 76px);
  line-height: 1.1;
  font-weight: 330;
  letter-spacing: -.012em;
  font-variation-settings: "opsz" 72;
}
.prose .word { will-change: transform; }
.prose em { font-style: italic; }

/* ---------- V. finale ---------- */

.finale {
  position: relative;
  height: 100vh; height: 100svh; min-height: 560px;
  overflow: hidden;
}
.finale-copy {
  position: absolute; top: 16vh; left: var(--gutter); right: var(--gutter);
  display: flex; flex-direction: column; gap: 2.5vh;
}
.finale-copy .label { opacity: .7; }
.finale-line {
  max-width: 11em;
  font-size: clamp(42px, 8.5vw, 160px);
  line-height: .92;
  font-weight: 300;
  letter-spacing: -.035em;
  font-variation-settings: "opsz" 144, "SOFT" 100;
}
.finale-line em { font-weight: 800; font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1; }

.pile { position: absolute; inset: 0; z-index: 2; touch-action: pan-y; }
.p-ch {
  position: absolute; left: 0; top: 0;
  font-family: var(--flex);
  font-variation-settings: "wdth" 151, "wght" 1000, "opsz" 144;
  font-size: clamp(54px, 10.5vw, 200px);
  line-height: .74;
  padding: .02em .015em 0;
  color: var(--ink);
  user-select: none; -webkit-user-select: none;
  touch-action: pan-y;
  cursor: grab;
  transform: translate(-999px, -999px);
  will-change: transform;
}
.p-ch.grab { cursor: grabbing; }
.pile.static {
  inset: auto var(--gutter) 70px;
  display: flex; flex-wrap: wrap; gap: 0 .02em; align-items: flex-end;
}
.pile.static .p-ch { position: static; transform: none; cursor: default; }

.finale-foot {
  position: absolute; left: var(--gutter); right: var(--gutter); bottom: 34px;
  z-index: 3;
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  pointer-events: none;
}
.surface {
  pointer-events: auto;
  appearance: none; border: 1px solid currentColor; background: none; color: inherit;
  padding: 8px 12px; border-radius: 99px; cursor: pointer;
}
.surface:hover { background: var(--ink); color: var(--signal); }

/* ---------- small screens ---------- */

@media (max-width: 720px) {
  .ruler { display: none; }
  .title { font-size: 20vw; }
  .p-ch { font-size: 16vw; }
  .hero-meta span:first-child { max-width: 14ch; }
  .thing { grid-template-columns: 3ch 1fr; row-gap: 6px; padding: 5vw 0 4vw; }
  .thing .aside { grid-column: 2; text-align: left; }
  .step .spec { display: none; }
  .finale-foot { flex-direction: column; align-items: flex-start; gap: 10px; bottom: 26px; }
  .finale-foot > span:first-child { display: none; }
}

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
  .thing .w { clip-path: none; transform: none; }
}
