/* ═══════════════════════════════════════════════════════════════════════════
   base.css — reset, typography, focus, motion primitives
   ═══════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }

/* A class that sets `display` would otherwise beat the UA rule for [hidden],
   and every panel in the console relies on `hidden` to mean hidden. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 24px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: 450;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Chinese sets wider and taller than Latin — give it room */
html[lang="zh"] body {
  font-family: var(--f-cjk);
  letter-spacing: 0.01em;
  line-height: 1.78;
}
html[lang="zh"] .d1, html[lang="zh"] .d2, html[lang="zh"] .d3,
html[lang="zh"] .h4 { font-family: var(--f-cjk); letter-spacing: -0.01em; }

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

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 700;
  letter-spacing: var(--tr-tight);
  line-height: var(--lh-snug);
  text-wrap: balance;
}

p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

a {
  color: var(--accent-ink);
  text-decoration: none;
  transition: color var(--dur-1) ease-out;
}
a:hover { color: var(--accent-deep); }

button, input, select, textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}
button { cursor: pointer; background: none; border: 0; padding: 0; }

hr { border: 0; border-top: 1px solid var(--line); margin: 0; }

/* ── Type scale ─────────────────────────────────────────────────────────── */
.d1 { font-size: var(--fs-d1); line-height: var(--lh-tight); letter-spacing: -0.042em; font-weight: 700; }
.d2 { font-size: var(--fs-d2); line-height: 1.06; letter-spacing: -0.036em; font-weight: 700; }
.d3 { font-size: var(--fs-d3); line-height: 1.12; letter-spacing: var(--tr-tight); font-weight: 700; }
.h4 { font-size: var(--fs-h4); line-height: 1.3; letter-spacing: var(--tr-snug); font-weight: 650; }

.lead {
  font-size: var(--fs-lead);
  line-height: 1.5;
  color: var(--ink-2);
  letter-spacing: -0.012em;
  font-weight: 450;
  max-width: 34ch;
}
.body  { font-size: var(--fs-body); color: var(--ink-2); max-width: 62ch; }
.sm    { font-size: var(--fs-sm); color: var(--ink-2); }
.xs    { font-size: var(--fs-xs); color: var(--ink-3); }
.muted { color: var(--ink-3); }

.eyebrow {
  font-family: var(--f-mono);
  font-size: var(--fs-eyebrow);
  font-weight: 500;
  letter-spacing: var(--tr-wide);
  text-transform: uppercase;
  color: var(--ink-3);
}

.mono {
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.01em;
}

strong, b { font-weight: 650; color: var(--ink); }

::selection { background: var(--accent); color: #fff; }

/* ── Focus — one visible ring, used everywhere ──────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-1);
}
[data-surface="dark"] :focus-visible,
.console :focus-visible { outline-color: var(--k-accent); }

.skip {
  position: absolute;
  left: var(--sp-4);
  top: -100px;
  z-index: 200;
  padding: var(--sp-3) var(--sp-5);
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-weight: 600;
  transition: top var(--dur-2) var(--ease-out);
}
.skip:focus { top: var(--sp-4); color: var(--bg); }

/* ── Layout shells ─────────────────────────────────────────────────────── */
.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.shell--wide { max-width: var(--shell-wide); }

.section { padding-block: var(--section-y); position: relative; }
.section--tight { padding-block: clamp(3rem, 6vw, 5.5rem); }
.section--deep { background: var(--bg-deep); }

/* Section header: eyebrow, headline, lede — one repeated rhythm */
.sechead { display: grid; gap: var(--sp-5); max-width: 62rem; }
.sechead__top { display: flex; align-items: baseline; gap: var(--sp-4); flex-wrap: wrap; }
.sechead__rule { flex: 1 1 60px; height: 1px; background: var(--line); min-width: 40px; }
.sechead p.lead { max-width: 54ch; }

/* ── Atmosphere ────────────────────────────────────────────────────────── */
/* A faint engineering grid. Two layers: 8px minor, 64px major. */
.grid-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--line-3) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line-3) 1px, transparent 1px),
    linear-gradient(to right, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: 16px 16px, 16px 16px, 96px 96px, 96px 96px;
  mask-image: radial-gradient(120% 90% at 50% 0%, #000 12%, transparent 78%);
  -webkit-mask-image: radial-gradient(120% 90% at 50% 0%, #000 12%, transparent 78%);
}
/* A soft light bloom so the page is not flat colour */
.bloom {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(58rem 32rem at 78% -12%, var(--accent-glow), transparent 62%),
    radial-gradient(46rem 30rem at 6% 8%, rgba(10, 86, 240, 0.10), transparent 66%);
  filter: blur(2px);
}

/* ── Reveal on scroll ──────────────────────────────────────────────────── */
.reveal { opacity: 0; transform: translateY(22px); }
.reveal.is-in {
  opacity: 1;
  transform: none;
  transition:
    opacity var(--dur-3) var(--ease-out),
    transform var(--dur-3) var(--ease-out);
  transition-delay: var(--d, 0ms);
}
/* Groups stagger themselves with --d set inline or by nth-child */
.stagger > * { --d: 0ms; }
.stagger > *:nth-child(2) { --d: 70ms; }
.stagger > *:nth-child(3) { --d: 140ms; }
.stagger > *:nth-child(4) { --d: 210ms; }
.stagger > *:nth-child(5) { --d: 280ms; }
.stagger > *:nth-child(6) { --d: 350ms; }

/* ── Hero load sequence — one orchestrated moment ──────────────────────── */
@keyframes rise {
  from { opacity: 0; transform: translateY(26px); }
  to   { opacity: 1; transform: none; }
}
@keyframes maskUp {
  from { transform: translateY(105%); }
  to   { transform: translateY(0); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes drawLine { to { stroke-dashoffset: 0; } }

.seq { opacity: 0; animation: rise 760ms var(--ease-out) forwards; animation-delay: var(--d, 0ms); }
.seq-mask { display: block; overflow: hidden; }
.seq-mask > span {
  display: block;
  transform: translateY(105%);
  animation: maskUp 900ms var(--ease-out) forwards;
  animation-delay: var(--d, 0ms);
}

/* ── Motion degradation — the whole site obeys this ────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
  .seq, .seq-mask > span, .draw, .count { animation: none !important; opacity: 1 !important; transform: none !important; stroke-dashoffset: 0 !important; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Utility ───────────────────────────────────────────────────────────── */
.sr {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.stack   { display: grid; gap: var(--sp-5); }
.stack-3 { display: grid; gap: var(--sp-3); }
.stack-6 { display: grid; gap: var(--sp-6); }
.row     { display: flex; gap: var(--sp-4); align-items: center; flex-wrap: wrap; }
.nums    { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
