/* ── reset & tokens ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

:root {
  --bg: #07070c;
  --bg-2: #0d0d16;
  --panel: #12121d;
  --panel-2: #171725;
  --line: #23233a;
  --text: #e8e8f2;
  --muted: #8b8ba7;
  --dim: #63637d;
  --accent: #7c5cff;
  --accent-2: #12d8b0;
  --accent-3: #ff5c8a;
  --radius: 16px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
}

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

code { font-family: var(--mono); font-size: .88em; color: #b9a8ff; }
h1, h2, h3, h4 { line-height: 1.15; letter-spacing: -0.02em; font-weight: 650; }
a { color: inherit; }

/* ── scroll progress ──────────────────────────────────────── */
.scrollbar {
  position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 60;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3));
  transform: scaleX(0); transform-origin: 0 50%;
}

/* ── topbar ───────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 1.5rem;
  padding: .85rem clamp(1rem, 4vw, 3rem);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; text-decoration: none; letter-spacing: -.02em; display: flex; align-items: center; gap: .5rem; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px var(--accent); }
.brand .muted { color: var(--dim); font-weight: 400; }
.topnav { display: flex; gap: 1.1rem; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a { color: var(--muted); text-decoration: none; font-size: .875rem; white-space: nowrap; transition: color .18s; }
.topnav a:hover { color: var(--text); }
.ver { font-family: var(--mono); font-size: .75rem; color: var(--dim); border: 1px solid var(--line); border-radius: 99px; padding: .15rem .55rem; }
@media (max-width: 820px) { .topnav { display: none; } }

/* ── hero ─────────────────────────────────────────────────── */
.hero {
  position: relative; min-height: 88vh; display: grid; place-items: center;
  padding: 6rem clamp(1rem, 5vw, 3rem) 4rem; overflow: hidden; text-align: center;
}
.hero-inner { position: relative; z-index: 2; max-width: 760px; }
.eyebrow { color: var(--muted); font-size: .85rem; letter-spacing: .04em; text-transform: uppercase; margin-bottom: 1.5rem; }
.hero-title {
  font-size: clamp(4rem, 16vw, 11rem); line-height: .88; font-weight: 800; letter-spacing: -.05em;
  margin-bottom: 1.5rem;
}
.hero-title .ch { display: inline-block; will-change: transform; background: linear-gradient(180deg, #fff, #9c8bff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { color: var(--muted); font-size: clamp(1rem, 2.2vw, 1.2rem); max-width: 560px; margin: 0 auto 2.2rem; }
.hero-cta { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }
.hero-stats { display: flex; gap: 2.5rem; justify-content: center; margin-top: 3.5rem; flex-wrap: wrap; }
.hero-stats div { display: flex; flex-direction: column; }
.hero-stats strong { font-size: 1.6rem; font-family: var(--mono); color: var(--accent-2); }
.hero-stats span { font-size: .75rem; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }

.orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; pointer-events: none; }
.orb1 { width: 480px; height: 480px; background: var(--accent); top: -8%; left: -6%; }
.orb2 { width: 380px; height: 380px; background: var(--accent-2); bottom: -12%; right: -4%; opacity: .35; }
.orb3 { width: 300px; height: 300px; background: var(--accent-3); top: 40%; right: 22%; opacity: .28; }

.scroll-hint { position: absolute; bottom: 2rem; color: var(--dim); font-size: 1.2rem; z-index: 2; }

/* ── chapters ─────────────────────────────────────────────── */
.chapter { max-width: 1080px; margin: 0 auto; padding: clamp(4rem, 9vw, 8rem) clamp(1rem, 5vw, 2rem); scroll-margin-top: 80px; }
.chapter-head { max-width: 720px; margin-bottom: 3rem; }
.chapter-head .num { font-family: var(--mono); font-size: .8rem; color: var(--accent); letter-spacing: .1em; }
.chapter-head h2 { font-size: clamp(1.9rem, 4.5vw, 2.9rem); margin: .5rem 0 1rem; }
.chapter-head p { color: var(--muted); font-size: 1.05rem; }

/* ── demo cards ───────────────────────────────────────────── */
.demo {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(1.25rem, 3vw, 2rem); margin-bottom: 1.75rem;
}
.demo header { margin-bottom: 1.25rem; }
.demo h3 { font-size: 1.25rem; margin: .5rem 0 .4rem; }
.demo header p { color: var(--muted); font-size: .93rem; max-width: 62ch; }
.tag {
  display: inline-block; font-family: var(--mono); font-size: .7rem; letter-spacing: .05em;
  color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-2) 25%, transparent);
  padding: .12rem .5rem; border-radius: 99px;
}

.stage {
  position: relative; background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  min-height: 180px; padding: 1.5rem; display: flex; align-items: center; overflow: hidden;
  background-image: radial-gradient(circle at 1px 1px, #ffffff0d 1px, transparent 0);
  background-size: 22px 22px;
}
.stage.tall { min-height: 300px; display: block; }
.stage.short { min-height: 130px; }

.box {
  width: 68px; height: 68px; border-radius: 14px; flex: none;
  background: linear-gradient(135deg, var(--accent), #a78bff);
  box-shadow: 0 10px 40px -10px var(--accent);
  display: grid; place-items: center; font-size: 1.5rem; color: #fff;
}
.box.b2 { background: linear-gradient(135deg, var(--accent-2), #6ee7d0); box-shadow: 0 10px 40px -10px var(--accent-2); margin-left: 40%; }
.box.b3 { background: linear-gradient(135deg, var(--accent-3), #ff9ab8); box-shadow: 0 10px 40px -10px var(--accent-3); width: 52px; height: 52px; }

/* controls */
.controls { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: 1rem; }
.btn {
  font: inherit; font-size: .85rem; font-weight: 500;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  padding: .5rem .9rem; border-radius: 9px; cursor: pointer; text-decoration: none;
  transition: background .16s, border-color .16s, color .16s;
}
.btn:hover { background: #1f1f30; border-color: #34344f; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #8f73ff; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.seg { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--muted); }
select {
  font: inherit; font-size: .8rem; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: .35rem .5rem;
}
.readout { font-family: var(--mono); font-size: .78rem; color: var(--dim); margin-left: auto; }

.sliders { gap: 1.2rem; }
.sliders label { display: flex; align-items: center; gap: .5rem; font-size: .78rem; color: var(--muted); font-family: var(--mono); }
.sliders output { color: var(--accent-2); min-width: 2.5rem; }
input[type=range] { accent-color: var(--accent); width: 110px; }

/* code */
.code { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .75rem; }
.code summary { cursor: pointer; font-size: .8rem; color: var(--muted); font-family: var(--mono); list-style: none; display: flex; align-items: center; gap: .4rem; }
.code summary::before { content: "▸"; transition: transform .15s; display: inline-block; }
.code[open] summary::before { transform: rotate(90deg); }
.code summary::-webkit-details-marker { display: none; }
.code pre {
  margin-top: .75rem; background: #05050a; border: 1px solid var(--line); border-radius: 10px;
  padding: 1rem; overflow-x: auto; font-size: .8rem; line-height: 1.65;
}
.code code { color: #c9c9e4; }

/* ── ease race ────────────────────────────────────────────── */
.ease-row { display: flex; align-items: center; gap: .75rem; margin-bottom: .55rem; }
.ease-name { font-family: var(--mono); font-size: .72rem; color: var(--dim); width: 118px; flex: none; text-align: right; }
.ease-track { position: relative; flex: 1; height: 22px; }
.ease-ball { position: absolute; top: 3px; left: 0; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); }

/* ── spring lab ───────────────────────────────────────────── */
.spring-lab { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 760px) { .spring-lab { grid-template-columns: 1fr; } }
.spring-plot { position: relative; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: .5rem; }
.spring-plot svg { width: 100%; height: 100%; min-height: 180px; display: block; }
.spring-plot .grid { stroke: #ffffff14; stroke-width: 1; }
.spring-plot .dashed { stroke-dasharray: 4 5; }
.spring-plot .plot { fill: none; stroke: var(--accent-2); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.plot-label { position: absolute; bottom: .5rem; right: .75rem; font-family: var(--mono); font-size: .7rem; color: var(--dim); }

/* ── dot grid ─────────────────────────────────────────────── */
.grid-stage { justify-content: center; }
.dotgrid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 10px; width: 100%; max-width: 460px; }
.gdot { aspect-ratio: 1; border-radius: 4px; background: #2a2a3d; }

/* ── sequence card ────────────────────────────────────────── */
.seq-stage { justify-content: center; min-height: 220px; }
.seq-card {
  position: relative; width: 300px; padding: 1.25rem; border-radius: 14px;
  background: var(--panel-2); border: 1px solid var(--line); display: flex; gap: 1rem; align-items: center; opacity: 0;
}
.seq-avatar { width: 52px; height: 52px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-3)); flex: none; }
.seq-lines { flex: 1; display: flex; flex-direction: column; gap: .45rem; }
.seq-lines i { height: 8px; border-radius: 4px; background: #2e2e46; display: block; opacity: 0; }
.seq-lines i:nth-child(2) { width: 80%; }
.seq-lines i:nth-child(3) { width: 55%; }
.seq-badge {
  position: absolute; top: -12px; right: -12px; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-2); color: #05231d; display: grid; place-items: center; font-weight: 700; transform: scale(0);
}

/* ── gesture cards ────────────────────────────────────────── */
.cards-stage { gap: 1rem; justify-content: center; flex-wrap: wrap; }
.gcard {
  font: inherit; cursor: pointer; width: 170px; height: 120px; border-radius: 14px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem;
}
.gcard span { font-weight: 600; }
.gcard em { font-style: normal; font-size: .75rem; color: var(--dim); }
.gcard.magnet { background: linear-gradient(135deg, #1b1b2e, #221a3a); border-color: #3a2f66; }

/* ── tilt ─────────────────────────────────────────────────── */
.tilt-stage { min-height: 340px; gap: 2rem; justify-content: center; flex-wrap: wrap; }
.tilt-wrap { perspective: 900px; }
.tilt-card {
  position: relative; width: 280px; height: 190px; border-radius: 18px; overflow: hidden;
  background: linear-gradient(140deg, #1c1731, #241a44 55%, #16233a);
  border: 1px solid #3a3163; transform-style: preserve-3d;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: .3rem;
  box-shadow: 0 30px 60px -30px #000;
}
.tilt-glare {
  position: absolute; inset: -20%;
  background: radial-gradient(circle at 50% 50%, #ffffff40, transparent 45%);
  background-size: 200% 200%; pointer-events: none;
}
.tilt-layer { position: relative; }
.tilt-layer.l1 { font-size: 1.9rem; font-weight: 700; letter-spacing: -.03em; }
.tilt-layer.l2 { font-family: var(--mono); font-size: .72rem; color: #a99bff; }
.tilt-layer.l3 { font-size: 1.3rem; color: var(--accent-2); margin-top: .4rem; }
.value-readout { display: grid; gap: .5rem; font-family: var(--mono); font-size: .78rem; }
.value-readout div { display: flex; gap: .75rem; justify-content: space-between; min-width: 190px; border-bottom: 1px dashed var(--line); padding-bottom: .3rem; }
.value-readout span { color: var(--dim); }
.value-readout b { color: var(--accent-2); font-weight: 500; }

/* ── scroll demos ─────────────────────────────────────────── */
.scrolltrack { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 2rem 1.5rem; }
.scroll-rail { position: relative; height: 44px; border-radius: 22px; background: var(--panel-2); border: 1px solid var(--line); }
.scroll-runner {
  position: absolute; top: 4px; left: 4px; width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-3)); display: grid; place-items: center; font-size: .9rem;
}
.scroll-pct { margin-top: .8rem; font-family: var(--mono); font-size: .78rem; color: var(--dim); }
.scroll-pct span { color: var(--accent-2); }

.hgallery { position: relative; height: 260vh; }
.hgallery-inner {
  position: sticky; top: 15vh; display: flex; gap: 1rem; padding: 1rem 0; width: max-content; will-change: transform;
}
.hg-item {
  width: 260px; height: 320px; border-radius: 16px; flex: none; padding: 1.25rem;
  border: 1px solid var(--line); display: flex; flex-direction: column; justify-content: flex-end;
  font-family: var(--mono); font-size: .8rem;
}
.hg-item b { display: block; font-size: 1.6rem; font-family: var(--sans); margin-bottom: .3rem; }

.inview-stage { gap: 1rem; flex-wrap: wrap; justify-content: center; }
.iv-item {
  width: 110px; height: 110px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line);
  display: grid; place-items: center; font-family: var(--mono); color: var(--muted); opacity: 0;
}

/* ── svg ──────────────────────────────────────────────────── */
.svg-stage { justify-content: center; }
.draw { width: 100%; max-width: 420px; height: auto; }
.draw .dp { fill: none; stroke: var(--accent-2); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.draw circle.dp { stroke: var(--accent); }
.draw path.dp:last-of-type { stroke: var(--accent-3); }

/* ── counters ─────────────────────────────────────────────── */
.counter-stage { gap: 2rem; flex-wrap: wrap; justify-content: space-around; }
.counter { font-family: var(--mono); font-size: clamp(2rem, 6vw, 3.4rem); font-weight: 600; color: var(--accent-2); font-variant-numeric: tabular-nums; }
.swatch {
  width: 130px; height: 84px; border-radius: 12px; background: #7c5cff; display: grid; place-items: center;
  font-family: var(--mono); font-size: .75rem; color: #fff; text-shadow: 0 1px 3px #0006;
}
.arcbox { position: relative; width: 280px; height: 110px; }
.arc-item { position: absolute; left: 6px; bottom: 6px; width: 38px; height: 38px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; }
.arc-target { position: absolute; right: 6px; top: 6px; font-size: 1.8rem; opacity: .6; }

/* ── view transitions ─────────────────────────────────────── */
.vt-stage { min-height: 300px; align-items: flex-start; }
.vt-list { display: flex; flex-direction: column; gap: .6rem; width: 100%; }
.vt-list.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .75rem; }
.vt-item {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: .8rem;
  display: flex; align-items: center; gap: .75rem; font-size: .85rem;
}
.vt-list.grid .vt-item { flex-direction: column; text-align: center; padding: 1.1rem .6rem; }
.vt-swatch { width: 32px; height: 32px; border-radius: 8px; flex: none; }
.vt-list.grid .vt-swatch { width: 46px; height: 46px; }

/* ── verdict ──────────────────────────────────────────────── */
.verdict { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 760px) { .verdict { grid-template-columns: 1fr; } }
.v-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; }
.v-card h4 { font-size: 1rem; margin-bottom: .9rem; color: var(--accent-2); }
.v-card ul { margin: 0; padding-left: 1.1rem; color: var(--muted); font-size: .92rem; display: grid; gap: .5rem; }
.install { margin-top: 1.5rem; display: grid; gap: .6rem; }
.install div { display: flex; align-items: center; gap: .75rem; background: #05050a; border: 1px solid var(--line); border-radius: 10px; padding: .75rem 1rem; overflow-x: auto; }
.install code { color: #c9c9e4; white-space: nowrap; }

/* ── footer ───────────────────────────────────────────────── */
.foot { border-top: 1px solid var(--line); padding: 2.5rem clamp(1rem, 5vw, 3rem); color: var(--dim); font-size: .85rem; text-align: center; }
.foot .rm { margin-top: .4rem; font-family: var(--mono); font-size: .75rem; }

/* reveal baseline — JS animates these in */
.reveal { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; } }
