/* ---------- Reset & tokens ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink-100);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overflow-x: hidden;
}

img, svg, video { max-width: 100%; display: block; }

button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea, button { font-family: inherit; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent-500);
  outline-offset: 3px;
  border-radius: 6px;
}

:root {
  /* Palette */
  --bg-0: #0c0f15;
  --bg-1: #11151d;
  --bg-2: #161b25;
  --bg-3: #1c2230;
  --ink-0: #f3f1ea;
  --ink-100: #e8e6df;
  --ink-200: #c4c1b6;
  --ink-300: #8a8a82;
  --ink-400: #5b5f57;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.18);

  --accent-300: #ffd37a;
  --accent-500: #f0b04a;
  --accent-700: #b87a1c;
  --accent-ink: #1a1306;

  --ok: #6ad4a8;
  --warn: #f0a04a;
  --bad: #ef6f6f;

  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 22px;
  --radius-xl: 28px;

  --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 6px 18px rgba(0, 0, 0, 0.32);
  --shadow-2: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 24px 60px rgba(0, 0, 0, 0.55);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 160ms;
  --dur-mid: 260ms;
  --dur-slow: 480ms;

  --gutter: clamp(16px, 4vw, 28px);
  --maxw: 1180px;
}

/* Light theme override (auto) */
@media (prefers-color-scheme: light) {
  :root {
    --bg-0: #f6f3ec;
    --bg-1: #efeae0;
    --bg-2: #e6e0d3;
    --bg-3: #d9d2c2;
    --ink-0: #181614;
    --ink-100: #1d1a16;
    --ink-200: #3b342b;
    --ink-300: #6a614f;
    --ink-400: #8e846f;
    --line: rgba(20, 16, 10, 0.10);
    --line-strong: rgba(20, 16, 10, 0.18);
    --accent-ink: #1a1306;
    --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.45) inset, 0 6px 18px rgba(40, 28, 10, 0.12);
    --shadow-2: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 24px 60px rgba(40, 28, 10, 0.16);
  }
}

/* Reduced motion tokens */
:root[data-motion='reduced'] {
  --dur-fast: 0ms;
  --dur-mid: 0ms;
  --dur-slow: 0ms;
}

:root[data-motion='reduced'] *,
:root[data-motion='reduced'] *::before,
:root[data-motion='reduced'] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

/* Respect OS preference if user hasn't chosen */
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion='full']) {
    --dur-fast: 0ms;
    --dur-mid: 0ms;
    --dur-slow: 0ms;
  }
  :root:not([data-motion='full']) *,
  :root:not([data-motion='full']) *::before,
  :root:not([data-motion='full']) *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Layout primitives ---------- */
.lab-main { display: block; padding: 0 var(--gutter); }
.lab-section { max-width: var(--maxw); margin: 0 auto; padding: clamp(40px, 8vw, 88px) 0; }
.lab-section--alt { background: var(--bg-1); border-radius: var(--radius-xl); padding: clamp(36px, 6vw, 72px) clamp(20px, 4vw, 36px); margin-top: clamp(32px, 6vw, 56px); }
.lab-section__head { max-width: 720px; margin: 0 0 clamp(20px, 4vw, 36px); }
.lab-section__head h2 { font-size: clamp(24px, 4vw, 34px); margin: 0 0 8px; letter-spacing: -0.01em; }
.lab-section__lede { color: var(--ink-200); margin: 0; max-width: 56ch; }
.lab-section__filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  transform: translateY(-200%);
  background: var(--ink-0);
  color: var(--bg-0);
  padding: 8px 12px;
  border-radius: var(--radius-s);
  z-index: 100;
  font-weight: 600;
  text-decoration: none;
  transition: transform var(--dur-fast) var(--ease-out);
}
.skip-link:focus { transform: translateY(0); }

/* ---------- Header ---------- */
.lab-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  background: color-mix(in oklab, var(--bg-0) 78%, transparent);
  border-bottom: 1px solid var(--line);
}
.lab-header__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px var(--gutter);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink-100);
}
.brand__mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--bg-2);
  color: var(--accent-500);
  box-shadow: var(--shadow-1);
}
.brand__text { display: flex; flex-direction: column; line-height: 1.1; }
.brand__text strong { font-size: 15px; letter-spacing: -0.01em; }
.brand__sub { color: var(--ink-300); font-size: 12px; }

.lab-nav {
  display: none;
  margin-left: auto;
  gap: 4px;
}
.lab-nav a {
  text-decoration: none;
  color: var(--ink-200);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
}
.lab-nav a:hover { color: var(--ink-0); background: var(--bg-2); }

.lab-header__actions { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; }

.motion-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.motion-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.motion-toggle span {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--bg-3);
  position: relative;
  transition: background var(--dur-fast) var(--ease-out);
  border: 1px solid var(--line);
}
.motion-toggle span::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink-100);
  transition: transform var(--dur-fast) var(--ease-out);
}
.motion-toggle input:checked + span { background: var(--accent-500); }
.motion-toggle input:checked + span::after { transform: translateX(16px); background: var(--accent-ink); }

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink-100);
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.icon-btn:hover { background: var(--bg-3); }
.icon-btn:active { transform: scale(0.96); }

/* ---------- Hero ---------- */
.hero { max-width: var(--maxw); margin: 0 auto; padding: clamp(32px, 7vw, 72px) 0 clamp(20px, 4vw, 40px); }
.hero__grid { display: grid; gap: clamp(20px, 4vw, 36px); align-items: center; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  color: var(--accent-500);
  margin: 0 0 12px;
  font-weight: 600;
}
.hero h1 {
  font-size: clamp(32px, 7vw, 56px);
  line-height: 1.05;
  margin: 0 0 14px;
  letter-spacing: -0.02em;
  color: var(--ink-0);
}
.hero h1 em { font-style: normal; color: var(--accent-500); }
.hero__lead { color: var(--ink-200); max-width: 52ch; margin: 0 0 22px; font-size: clamp(15px, 2.2vw, 18px); }
.hero__cta { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }
.hero__stats { display: flex; flex-wrap: wrap; gap: 16px; margin: 0; }
.hero__stats > div {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 10px 14px;
  min-width: 110px;
}
.hero__stats dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-300); }
.hero__stats dd { margin: 4px 0 0; font-size: 18px; font-weight: 600; color: var(--ink-0); }

/* Hero orbit */
.hero__demo {
  position: relative;
  min-height: 260px;
  display: grid;
  place-items: center;
}
.hero-orbit {
  position: relative;
  width: min(380px, 100%);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(closest-side, color-mix(in oklab, var(--accent-500) 16%, transparent), transparent 70%),
    var(--bg-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  overflow: visible;
}
.hero-orbit__core {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 4px;
  text-align: center;
}
.hero-orbit__pulse {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-500);
  box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent-500) 60%, transparent);
  animation: pulse 2.4s var(--ease-out) infinite;
}
.hero-orbit__label { font-size: 12px; color: var(--ink-200); letter-spacing: 0.12em; text-transform: uppercase; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent-500) 60%, transparent); }
  70% { box-shadow: 0 0 0 24px color-mix(in oklab, var(--accent-500) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent-500) 0%, transparent); }
}
.hero-orbit__chip {
  position: absolute;
  border: 1px solid var(--line-strong);
  background: var(--bg-3);
  color: var(--ink-0);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.hero-orbit__chip:hover { background: var(--accent-500); color: var(--accent-ink); transform: scale(1.04); }
.hero-orbit__chip--1 { top: 6%; left: 50%; transform: translateX(-50%); }
.hero-orbit__chip--2 { right: 6%; top: 50%; transform: translateY(-50%); }
.hero-orbit__chip--3 { bottom: 6%; left: 50%; transform: translateX(-50%); }
.hero-orbit__chip--4 { left: 6%; top: 50%; transform: translateY(-50%); }
.hero-orbit__chip--1:hover { transform: translateX(-50%) scale(1.04); }
.hero-orbit__chip--2:hover { transform: translateY(-50%) scale(1.04); }
.hero-orbit__chip--3:hover { transform: translateX(-50%) scale(1.04); }
.hero-orbit__chip--4:hover { transform: translateY(-50%) scale(1.04); }

/* ---------- Buttons / chips ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
  position: relative;
  overflow: hidden;
}
.btn--primary { background: var(--accent-500); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-300); }
.btn--ghost { background: var(--bg-2); color: var(--ink-100); border-color: var(--line); }
.btn--ghost:hover { background: var(--bg-3); border-color: var(--line-strong); }
.btn:active { transform: scale(0.98); }

.chip {
  background: var(--bg-2);
  color: var(--ink-200);
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.chip:hover { color: var(--ink-0); border-color: var(--line-strong); }
.chip.is-active { background: var(--accent-500); color: var(--accent-ink); border-color: transparent; }

kbd {
  display: inline-block;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 12px;
  font-family: 'JetBrains Mono', 'Fira Mono', ui-monospace, monospace;
  color: var(--ink-100);
}

/* ---------- Footer ---------- */
.lab-footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 40px var(--gutter) 60px;
  color: var(--ink-300);
  font-size: 14px;
}
.lab-footer__keys { margin-top: 6px; }
.lab-footer__keys kbd { margin: 0 2px; }
