:root {
  --bg: #121314;
  --bg-2: #18191b;
  --panel: rgba(24, 25, 27, 0.72);
  --edge: rgba(255, 255, 255, 0.09);
  --ink: #ecebe4;
  --muted: #a3a39c;
  --lime: #a7de59;
  --lime-ink: #142006;
  --c-events: #4dba74;
  --c-files: #5d9ae5;
  --c-system: #6284a4;
  --c-input: #46a969;
  --c-detection: #1ab7a2;
  --c-loops: #e59437;
  --c-variables: #9a78cb;
  --c-functions: #b48ae0;
  --font: "Space Grotesk", system-ui, sans-serif;
  --mono: "DM Mono", ui-monospace, monospace;
  --radius: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --nav-h: 68px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: auto; -webkit-text-size-adjust: 100%; }
html.lenis, html.lenis body { height: auto; }
body {
  margin: 0;
  background: radial-gradient(1200px 800px at 75% 20%, #1c2216 0%, transparent 60%), var(--bg);
  color: var(--ink);
  font: 400 1rem/1.6 var(--font);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; }
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.05; letter-spacing: -0.03em; font-weight: 600; }
h2 { font-size: clamp(2.2rem, 5vw, 4rem); }
h3 { font-size: 1.1rem; letter-spacing: -0.01em; }
em { font-style: normal; color: var(--lime); }
code, kbd, pre { font-family: var(--mono); }
kbd { padding: 0.1em 0.45em; border: 1px solid var(--edge); border-bottom-width: 2px; border-radius: 6px; background: #222426; font-size: 0.85em; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip-link { position: fixed; left: 16px; top: -60px; z-index: 100; padding: 10px 16px; border-radius: 8px; background: var(--lime); color: var(--lime-ink); font-weight: 600; text-decoration: none; transition: top 0.2s; }
.skip-link:focus { top: 16px; }

/* ---------- 3D stage ---------- */
.stage { position: fixed; inset: 0; z-index: 0; }
.stage canvas { display: block; width: 100%; height: 100%; }
.stage-vignette { position: fixed; inset: 0; z-index: 1; pointer-events: none; background: radial-gradient(ellipse at center, transparent 55%, rgba(8, 9, 10, 0.65) 100%); }
.no-webgl .stage { background: radial-gradient(600px 400px at 70% 40%, rgba(167, 222, 89, 0.12), transparent 70%); }

.scroll-progress { position: fixed; inset: 0 0 auto; height: 3px; z-index: 60; }
.scroll-progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--c-events), var(--lime)); transform-origin: 0 50%; transform: scaleX(0); }

/* ---------- Nav ---------- */
.site-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  height: var(--nav-h); padding: 0 clamp(16px, 4vw, 48px);
  background: linear-gradient(to bottom, rgba(18, 19, 20, 0.85), rgba(18, 19, 20, 0));
  backdrop-filter: blur(6px);
}
.nav-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; text-decoration: none; letter-spacing: -0.02em; }
.nav-brand img { border-radius: 7px; }
.site-nav nav { display: flex; gap: 4px; }
.site-nav nav a { padding: 8px 14px; border-radius: 999px; color: var(--muted); font-size: 0.92rem; text-decoration: none; transition: color 0.2s, background 0.2s; }
.site-nav nav a:hover, .site-nav nav a.active { color: var(--ink); background: rgba(255, 255, 255, 0.06); }

/* ---------- Buttons ---------- */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; text-align: center; gap: 10px; min-height: 48px; padding: 0 24px; border-radius: 999px; font-weight: 600; font-size: 1rem; text-decoration: none; cursor: pointer; transition: background 0.2s, color 0.2s, box-shadow 0.3s, border-color 0.2s; will-change: transform; }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--lime); color: var(--lime-ink); box-shadow: 0 0 0 0 rgba(167, 222, 89, 0.5), 0 10px 30px -10px rgba(167, 222, 89, 0.6); }
.btn-primary:hover { background: #b9ec6c; box-shadow: 0 0 0 6px rgba(167, 222, 89, 0.15), 0 14px 40px -10px rgba(167, 222, 89, 0.8); }
.btn-ghost { border: 1px solid var(--edge); background: rgba(255, 255, 255, 0.03); }
.btn-ghost:hover { border-color: rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.07); }
.btn-small { min-height: 40px; padding: 0 18px; font-size: 0.92rem; }
.btn-large { min-height: 58px; padding: 0 32px; font-size: 1.08rem; }

/* ---------- Layout ---------- */
main { position: relative; z-index: 2; }
.section { position: relative; min-height: 100vh; min-height: 100svh; }
.section.tall { height: 190vh; }
.sticky { position: sticky; top: 0; height: 100vh; height: 100svh; display: flex; align-items: center; }
.wrap { width: min(1240px, 100% - clamp(32px, 8vw, 96px)); margin-inline: auto; }
.split { display: flex; }
.split .copy { width: min(520px, 100%); }
.split.reverse { justify-content: flex-end; }
.eyebrow { display: inline-flex; align-items: center; gap: 10px; margin: 0 0 18px; color: var(--lime); font: 500 0.82rem/1 var(--mono); text-transform: uppercase; letter-spacing: 0.14em; }
.lead { margin: 20px 0 0; color: var(--muted); font-size: clamp(1.02rem, 1.4vw, 1.18rem); max-width: 56ch; }
.meta { margin: 22px 0 0; color: var(--muted); font: 0.85rem var(--mono); }
.fine { margin: 14px 0 0; color: var(--muted); font-size: 0.85rem; }
.cta-row { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 34px; }
.cta-row.center { justify-content: center; }
.panel { position: relative; }

/* ---------- Hero ---------- */
.hero { display: flex; align-items: center; padding-top: var(--nav-h); }
.hero-inner { padding-bottom: 120px; }
.hero-title { font-size: clamp(3rem, 8.4vw, 7.2rem); font-weight: 700; max-width: 9.5ch; line-height: 0.95; letter-spacing: -0.045em; }
.hero .lead { max-width: 46ch; }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 0 rgba(167, 222, 89, 0.7); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(167, 222, 89, 0); } 100% { box-shadow: 0 0 0 0 rgba(167, 222, 89, 0); } }

.scroll-cue { position: absolute; left: 50%; bottom: 92px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); font: 0.72rem var(--mono); text-transform: uppercase; letter-spacing: 0.2em; }
.scroll-cue span { width: 22px; height: 36px; border: 1.5px solid rgba(255, 255, 255, 0.3); border-radius: 12px; position: relative; }
.scroll-cue span::after { content: ""; position: absolute; left: 50%; top: 7px; width: 3px; height: 7px; margin-left: -1.5px; border-radius: 2px; background: var(--lime); animation: wheel 1.8s var(--ease) infinite; }
@keyframes wheel { 0% { opacity: 0; transform: translateY(-4px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(12px); } }

.marquee { position: absolute; left: 0; right: 0; bottom: 22px; overflow: hidden; mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); }
.marquee-track { display: flex; gap: 12px; width: max-content; animation: marquee 40s linear infinite; }
@keyframes marquee { to { transform: translateX(-50%); } }

.chip, .tag { display: inline-flex; align-items: center; white-space: nowrap; padding: 7px 14px; border-radius: 8px 8px 4px 4px; background: var(--c); color: #fff; font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.22); }
.c-events { --c: var(--c-events); } .c-files { --c: var(--c-files); } .c-system { --c: var(--c-system); } .c-input { --c: var(--c-input); }
.c-detection { --c: var(--c-detection); } .c-loops { --c: var(--c-loops); } .c-variables { --c: var(--c-variables); } .c-functions { --c: var(--c-functions); }

/* ---------- Steps ---------- */
.steps { list-style: none; margin: 34px 0 0; padding: 0 0 0 4px; display: grid; gap: 26px; position: relative; }
.step { display: grid; grid-template-columns: 44px 1fr; gap: 18px; transition: opacity 0.4s; }
.js .step { opacity: 0.35; }
.js .step.is-active { opacity: 1; }
.step-num { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--edge); background: #1c1e1f; font: 500 1rem var(--mono); transition: background 0.4s, color 0.4s, border-color 0.4s; }
.step.is-active .step-num { background: var(--lime); color: var(--lime-ink); border-color: var(--lime); }
.step h3 { margin-top: 2px; }
.step p { margin: 6px 0 0; color: var(--muted); }
.steps-rail { position: absolute; left: 25px; top: 230px; bottom: 30px; width: 2px; background: var(--edge); z-index: -1; display: none; }

/* ---------- Categories ---------- */
#blocks { padding: 140px 0 120px; }
.section-head.center { text-align: center; display: flex; flex-direction: column; align-items: center; }
.section-head.center .lead { margin-inline: auto; }
.cat-grid { list-style: none; margin: 64px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; perspective: 900px; }
.cat-card { position: relative; padding: 22px 22px 24px; border: 1px solid var(--edge); border-radius: var(--radius); background: var(--panel); backdrop-filter: blur(14px); transform-style: preserve-3d; transition: border-color 0.3s, box-shadow 0.3s; overflow: hidden; }
.cat-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--c); }
.cat-card::after { content: ""; position: absolute; inset: 0; background: radial-gradient(300px circle at var(--mx, 50%) var(--my, 0%), color-mix(in srgb, var(--c) 22%, transparent), transparent 60%); opacity: 0; transition: opacity 0.3s; pointer-events: none; }
.cat-card:hover { border-color: color-mix(in srgb, var(--c) 55%, transparent); box-shadow: 0 20px 50px -20px color-mix(in srgb, var(--c) 60%, transparent); }
.cat-card:hover::after { opacity: 1; }
.cat-swatch { display: block; width: 40px; height: 22px; border-radius: 6px 6px 3px 3px; background: var(--c); margin-bottom: 18px; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.22); }
.cat-card p { margin: 8px 0 0; color: var(--muted); font-size: 0.92rem; line-height: 1.5; }
.stats { margin: 56px 0 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stats div { padding: 22px; border-top: 1px solid var(--edge); border-radius: 0 0 var(--radius) var(--radius); background: linear-gradient(to bottom, rgba(18, 19, 20, 0.7), rgba(18, 19, 20, 0.25)); backdrop-filter: blur(10px); }
.stats dt { color: var(--muted); font: 0.78rem var(--mono); text-transform: uppercase; letter-spacing: 0.1em; }
.stats dd { margin: 6px 0 0; font-size: clamp(2.2rem, 4vw, 3.4rem); font-weight: 700; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }

/* ---------- Detection scanner ---------- */
.scanner { margin-top: 30px; border: 1px solid var(--edge); border-radius: var(--radius); background: #161718; overflow: hidden; max-width: 460px; }
.scan-screen { position: relative; height: 190px; background: linear-gradient(#2e3131 1px, transparent 1px) 0 0 / 24px 24px, linear-gradient(90deg, #2e3131 1px, transparent 1px) 0 0 / 24px 24px, #202223; overflow: hidden; }
.scan-window { position: absolute; left: 12%; top: 18%; width: 70%; height: 64%; padding: 14px; border-radius: 8px; background: #2a2c2e; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); }
.scan-bar { display: block; height: 8px; width: 70%; border-radius: 4px; background: #3a3d3f; margin-bottom: 8px; }
.scan-bar.short { width: 40%; }
.scan-button { position: absolute; right: 14px; bottom: 14px; padding: 6px 16px; border-radius: 6px; background: #4a4d50; color: #d6d6d0; font-size: 0.8rem; font-weight: 600; transition: background 0.3s, color 0.3s; }
.scan-button.is-green { background: var(--c-events); color: #fff; }
.scan-cross { position: absolute; left: 0; top: 0; width: 34px; height: 34px; margin: -17px 0 0 -17px; border: 2px solid var(--lime); border-radius: 50%; }
.scan-cross::before, .scan-cross::after { content: ""; position: absolute; background: var(--lime); }
.scan-cross::before { left: 50%; top: -10px; bottom: -10px; width: 1px; }
.scan-cross::after { top: 50%; left: -10px; right: -10px; height: 1px; }
.scan-line { position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--c-detection); box-shadow: 0 0 18px 4px rgba(26, 183, 162, 0.6); animation: scanline 3s ease-in-out infinite alternate; }
@keyframes scanline { to { transform: translateY(188px); } }
.scan-readout { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 12px 16px; font: 0.8rem var(--mono); color: var(--muted); }
.scan-readout b { color: var(--ink); font-weight: 500; }
.swatch-mini { width: 14px; height: 14px; border-radius: 4px; background: var(--scan-hex, #202223); border: 1px solid var(--edge); }
.scan-status { margin-left: auto; padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); }
.scan-status.is-match { background: var(--lime); color: var(--lime-ink); }

/* ---------- Logic ---------- */
.logic-list { list-style: none; margin: 30px 0 0; padding: 0; display: grid; gap: 14px; }
.logic-list li { display: flex; align-items: baseline; gap: 14px; color: var(--muted); }
.logic-list .tag { flex: none; min-width: 112px; justify-content: center; }
.logic-list code { color: var(--ink); }
.vars { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.var { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px; border: 1px solid color-mix(in srgb, var(--c-variables) 50%, transparent); background: color-mix(in srgb, var(--c-variables) 14%, #161718); font-size: 0.88rem; }
.dice { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; background: var(--c-variables); color: #fff; font-weight: 500; }

/* ---------- AI ---------- */
.ai-demo { margin-top: 28px; padding: 18px; border: 1px solid var(--edge); border-radius: var(--radius); background: #161718; max-width: 480px; }
.ai-prompt { display: flex; align-items: center; min-height: 52px; padding: 12px 14px; border-radius: 10px; background: #202223; font-size: 0.95rem; }
.ai-spark { flex: none; width: 18px; height: 18px; margin-right: 10px; background: var(--lime); clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); animation: spin 6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.caret { width: 2px; height: 1.2em; margin-left: 2px; background: var(--lime); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.ai-blocks { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 4px; }
.mini { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 7px 7px 3px 3px; background: var(--c); color: #fff; font-size: 0.78rem; font-weight: 600; text-transform: uppercase; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.22); }
.mini.indent { margin-left: 22px; }
.mini .field { padding: 2px 8px; border-radius: 4px; background: rgba(20, 20, 20, 0.45); font: 0.76rem var(--mono); text-transform: none; }
.providers { list-style: none; margin: 20px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.providers li { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--edge); color: var(--muted); font-size: 0.84rem; }

/* ---------- Code ---------- */
.code-card { margin-top: 28px; border: 1px solid var(--edge); border-radius: var(--radius); background: #141516; overflow: hidden; max-width: 560px; }
.code-tabs { display: flex; gap: 4px; padding: 8px; border-bottom: 1px solid var(--edge); }
.code-tabs span { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-size: 0.82rem; }
.code-tabs span.active { background: #222426; color: var(--ink); }
.code-card pre { margin: 0; padding: 18px 0; overflow-x: auto; font-size: 0.84rem; line-height: 1.75; }
.code-card pre code { display: flex; flex-direction: column; white-space: pre; }
.ln { display: block; padding: 0 18px; border-left: 2px solid transparent; transition: background 0.3s, border-color 0.3s; }
.ln.is-lit { background: rgba(167, 222, 89, 0.07); border-left-color: var(--lime); }
.kw { color: #db7599; } .st { color: var(--lime); } .nu { color: var(--c-loops); } .cm { color: #6d706b; }

/* ---------- Final ---------- */
.final { display: flex; flex-direction: column; justify-content: flex-end; min-height: 115vh; }
.final-inner { text-align: center; padding-bottom: 80px; display: flex; flex-direction: column; align-items: center; }
.final h2 { font-size: clamp(2.6rem, 6.4vw, 5.6rem); max-width: 14ch; }
.site-footer { display: flex; justify-content: space-between; padding: 22px clamp(16px, 4vw, 48px); border-top: 1px solid var(--edge); color: var(--muted); font: 0.82rem var(--mono); }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--ink); }

/* ---------- Split text ---------- */
.word { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: 0.08em; margin-bottom: -0.08em; }
.word > span { display: inline-block; will-change: transform; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .cat-grid, .stats { grid-template-columns: repeat(2, 1fr); }
  .site-nav nav { display: none; }
}
@media (max-width: 760px) {
  .split, .split.reverse { justify-content: center; }
  .split .panel { padding: 26px 22px; border: 1px solid var(--edge); border-radius: 20px; background: rgba(18, 19, 20, 0.8); backdrop-filter: blur(12px); }
  /* Phones: no sticky pinning; each section opens with a gap where the 3D formation is shown. */
  .section.tall { height: auto; }
  .sticky { position: relative; display: block; height: auto; padding: 44vh 0 8vh; }
  .hero { align-items: flex-start; padding-top: calc(var(--nav-h) + 34vh); }
  .hero-inner { padding-bottom: 110px; }
  .scroll-cue { display: none; }
  .cat-grid { grid-template-columns: 1fr; }
  .scan-screen { height: 140px; }
  @keyframes scanline { to { transform: translateY(138px); } }
  .logic-list li { flex-direction: column; gap: 6px; }
  .final h2 { font-size: clamp(2.2rem, 10vw, 3.2rem); }
}
@media (max-height: 760px) and (min-width: 761px) {
  .sticky .lead { font-size: 1rem; }
  .steps { gap: 16px; margin-top: 22px; }
  .scan-screen { height: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .marquee-track { animation: none; }
}
