/* BrokerWrite hero lab — shared system.
   White ground, one electric blue, ink, hairlines. IBM Plex Sans + Mono. */
:root {
  --paper: #ffffff;
  --mist: #f5f7fa;
  --rule: #e4e8ef;
  --rule-2: #d3d9e3;
  --graphite: #596174;
  --slate: #8a91a1;
  --ink: #0b1020;
  --ink-2: #1c2335;
  --electric: #1f4bff;
  --electric-deep: #1536c9;
  --ice: #eef2ff;
  --sky: #b8c8ff;
  --fill: #0e9f6e;
  --fill-ice: #e7f6ef;

  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --ease-out: cubic-bezier(0.19, 1, 0.22, 1);
  --ease-soft: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-io: cubic-bezier(0.645, 0.045, 0.355, 1);

  --gutter: 56px;
  --r-card: 14px;
  --shadow-card: 0 1px 0 rgba(11, 16, 32, 0.04), 0 12px 32px -12px rgba(11, 16, 32, 0.16);

  /* ---- Design system v9 "The puzzle, solved": primitives not listed above ---- */
  --ink-3: #141a2e;          /* code window bar */
  --ink-4: #0c1120;          /* terminal */
  --blue-code: #7fa0ff;      /* keywords on ink */
  --blue-pale: #f2f5ff;      /* unlit piece fill */
  --blue-pale-line: #c9d3f5; /* unlit piece stroke */
  --blue-shadow: #d5ddf7;    /* lifted piece shadow */
  --fill-ink: #08744f;       /* positive text */
  --fill-tint: #f3fbf7;      /* delivered subscriber */
  --reject: #e5484d;         /* negative P&L */
  --code-text: #c9d4ea;
  --code-string: #8fd3b0;
  --code-number: #f0c38b;
  --code-comment: #6b7894;

  /* ---- semantic aliases (what components use) ---- */
  --bg-page: var(--paper);  --bg-subtle: var(--mist);  --bg-inverse: var(--ink);  --bg-code-bar: var(--ink-3);
  --bg-brand: var(--electric);  --bg-brand-strong: var(--electric-deep);  --bg-brand-subtle: var(--ice);  --bg-positive-subtle: var(--fill-ice);
  --text-primary: var(--ink);  --text-secondary: var(--graphite);  --text-tertiary: var(--slate);  --text-brand: var(--electric);
  --text-on-brand: var(--paper);  --text-positive: var(--fill-ink);  --text-negative: var(--reject);
  --border-default: var(--rule);  --border-strong: var(--rule-2);  --border-brand: var(--electric);  --border-brand-soft: var(--sky);
  --piece-white: var(--paper);  --piece-white-line: var(--rule-2);  --piece-blue: var(--electric);  --piece-blue-line: var(--paper);
  --piece-deep: var(--electric-deep);  --piece-ice: var(--ice);  --piece-ice-line: var(--electric);  --piece-pale: var(--blue-pale);
  --piece-pale-line: var(--blue-pale-line);  --piece-shadow: var(--blue-shadow);  --status-live: var(--fill);

  /* ---- spacing + radius scales ---- */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-7: 28px; --space-8: 32px;
  --space-10: 40px; --space-12: 48px; --space-14: 56px; --space-16: 64px; --space-24: 96px; --space-26: 104px;
  --radius-xs: 6px; --radius-sm: 8px; --radius-md: 10px; --radius-lg: 12px; --radius-xl: 14px; --radius-2xl: 16px; --radius-3xl: 18px; --radius-full: 999px;
  --shadow-float: 0 24px 48px -24px rgba(11, 16, 32, 0.3);
  --focus-ring: 0 0 0 3px var(--ice);

  /* ---- theme surfaces (night mode flips these) ---- */
  --surface: #ffffff;                       /* cards, tiles, white pieces */
  --surface-glass: rgba(255, 255, 255, 0.86); /* nav pill, floating panels */
  --inverse: var(--ink);                    /* primary buttons, ink badges */
  --inverse-hover: #000;
  --on-inverse: #ffffff;
  --code-bg: var(--ink);                    /* code windows and terminals stay dark in both themes */
  color-scheme: light;
}

/* ---- Night mode. Same one electric blue; paper becomes deep ink, ink becomes paper. ---- */
[data-theme="dark"] {
  --paper: #0b0f1c;
  --mist: #10162a;
  --rule: #1f2840;
  --rule-2: #2c3652;
  --graphite: #a3acc2;
  --slate: #7d879e;
  --ink: #f2f4fa;
  --ink-2: #d8deea;
  --ice: #172447;
  --sky: #3b57b9;
  --fill-ice: #0f2b21;
  --fill-tint: #0f2b21;
  --fill-ink: #5fd3a2;
  --reject: #ff6b70;
  --blue-pale: #151d36;
  --blue-pale-line: #2c3d70;
  --blue-shadow: #060a18;
  --ink-3: #0d1326;
  --ink-4: #070b16;
  --surface: #121a2e;
  --surface-glass: rgba(18, 26, 46, 0.86);
  --inverse: #f2f4fa;
  --inverse-hover: #ffffff;
  --on-inverse: #0b0f1c;
  --code-bg: #070b16;
  --text-on-brand: #ffffff;
  --piece-white: var(--surface);
  --piece-blue-line: #dfe6ff;
  --shadow-card: 0 1px 0 rgba(0, 0, 0, 0.3), 0 12px 32px -12px rgba(0, 0, 0, 0.6);
  --shadow-float: 0 24px 48px -24px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}
[data-theme="dark"] .vlogo { filter: brightness(0) invert(1); opacity: 0.85; }
[data-theme="dark"] .stage::before { background-image: url(hero-poster-dark.webp); }
@media (max-width: 900px) { [data-theme="dark"] .stage::before { background-image: url(hero-poster-dark-m.webp); } }

/* theme toggle in the nav */
.nav__theme {
  display: inline-grid; place-items: center; width: 34px; height: 34px; margin-left: 8px; padding: 0;
  border: 1px solid var(--rule); border-radius: 999px; background: transparent; color: var(--graphite); cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}
.nav__theme:hover { color: var(--ink); border-color: var(--rule-2); background: var(--mist); }
.nav__theme:focus-visible { outline: none; box-shadow: var(--focus-ring); }
[data-theme-toggle] .ic--sun { display: none; }
[data-theme="dark"] [data-theme-toggle] .ic--sun { display: block; }
[data-theme="dark"] [data-theme-toggle] .ic--moon { display: none; }
.mnav__theme { display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 12px; padding: 12px 14px; border: 1px solid var(--rule); border-radius: 10px; background: transparent; color: var(--ink); font: inherit; cursor: pointer; }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss02" 1;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Nav: centred pill, concentric radii (outer 14 = inner 8 + pad 6) ---------- */
.nav {
  position: fixed; top: 18px; left: 50%; z-index: 50;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px;
  padding: 6px; border-radius: 14px;
  background: var(--surface-glass);
  border: 1px solid var(--rule);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 1px 0 rgba(11, 16, 32, 0.03), 0 8px 24px -16px rgba(11, 16, 32, 0.2);
}
.nav__brand { white-space: nowrap; display: flex; align-items: center; gap: 9px; padding: 0 14px 0 10px; height: 36px; font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.mark { width: auto; height: 22px; flex: none; display: block; } /* the faceted bird PNG (portrait, 203x256) */
.nav__links { position: relative; display: flex; align-items: center; }
.nav__link { position: relative; z-index: 1; white-space: nowrap; height: 36px; display: flex; align-items: center; padding: 0 12px; border-radius: 8px; font-size: 14px; color: var(--ink-2); transition: color 150ms ease; }
.nav__link:hover { color: var(--ink); }
.nav__link--muted { color: var(--graphite); }
.nav__pill { position: absolute; top: 0; left: 0; height: 36px; border-radius: 8px; background: var(--mist); opacity: 0; pointer-events: none;
  transition: transform 260ms var(--ease-out), width 260ms var(--ease-out), opacity 160ms ease; }
.nav__cta { white-space: nowrap; height: 36px; display: flex; align-items: center; gap: 6px; padding: 0 14px; margin-left: 6px; border-radius: 8px; background: var(--inverse); color: var(--on-inverse); font-size: 14px; font-weight: 500; }
.nav__cta .arr { transition: transform 200ms var(--ease-out); }
.nav__cta:hover .arr { transform: translate(2px, -2px); }

/* ---------- Type ---------- */
.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--electric); }
.eyebrow--ink { color: var(--graphite); }
.display {
  font-weight: 600; letter-spacing: -0.042em; line-height: 0.98; margin: 0;
  font-size: clamp(48px, 6.1vw, 92px);
  text-wrap: balance;
}
.display .soft { color: var(--slate); }
.lede { font-size: 19px; line-height: 1.55; color: var(--graphite); margin: 0; max-width: 34em; text-wrap: pretty; }
.tagline { font-size: 22px; line-height: 1.35; letter-spacing: -0.015em; margin: 0; }
.tagline .soft { color: var(--slate); }
.rebus { display: inline-flex; flex-direction: column; justify-content: center; gap: 3px; width: 34px; height: 1em; vertical-align: -0.12em; margin: 0 0.18em; }
.rebus i { display: block; height: 5px; border-radius: 2px; border: 1.5px solid var(--ink); }
.rebus i:nth-child(2) { background: var(--electric); border-color: var(--electric); }
.meta { font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--graphite); }

/* ---------- Buttons ---------- */
.btns { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 50px; padding: 0 22px; border-radius: 12px; font-size: 16px; font-weight: 500; letter-spacing: -0.005em;
  transition: background-color 180ms ease, border-color 180ms ease, transform 150ms var(--ease-soft); }
.btn:active { transform: scale(0.97); }
.btn .arr { display: inline-block; transition: transform 220ms var(--ease-out); }
.btn--primary { background: var(--inverse); color: var(--on-inverse); }
.btn--primary:hover { background: var(--inverse-hover); }
.btn--primary:hover .arr { transform: translate(2px, -2px); }
.btn--ghost { background: var(--surface); border: 1px solid var(--rule-2); }
.btn--ghost:hover { border-color: var(--ink); }
.btn--ghost:hover .arr { transform: translateY(3px); }

/* ---------- UI kit: cards ---------- */
.card { position: relative; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-card); box-shadow: var(--shadow-card); overflow: hidden; }
.card__head { display: flex; align-items: center; justify-content: space-between; height: 40px; padding: 0 14px; border-bottom: 1px solid var(--rule); font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--graphite); }
.card__body { padding: 14px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--electric); display: inline-block; flex: none; }
.dot--fill { background: var(--fill); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border-radius: 6px; font-family: var(--mono); font-size: 11.5px; background: var(--ice); color: var(--electric-deep); white-space: nowrap; }
.chip--ok { background: var(--fill-ice); color: #08744f; }
.chip--line { background: var(--surface); border: 1px solid var(--rule); color: var(--graphite); }

/* Tilt + spotlight hover for floating UI (pointer: fine only) */
.tilt { transform-style: preserve-3d; transition: transform 500ms var(--ease-out), box-shadow 300ms ease; will-change: transform; }
.tilt::after { content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none; padding: 1px;
  background: radial-gradient(160px circle at var(--mx, 50%) var(--my, 50%), rgba(31, 75, 255, 0.55), transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity 240ms ease; }
@media (hover: hover) and (pointer: fine) { .tilt:hover::after { opacity: 1; } }

/* Event log rows */
.log { font-family: var(--mono); font-size: 12px; }
.log__row { white-space: nowrap; display: grid; grid-template-columns: 14px minmax(0,1fr) auto; align-items: center; gap: 8px; height: 30px; padding: 0 14px; border-top: 1px solid var(--rule); color: var(--ink-2); }
.log__row:first-child { border-top: 0; }
.log__row > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; }
.log__row code { font-family: var(--mono); color: var(--electric-deep); }
.log__row .t { color: var(--slate); }
.log__row.is-new { animation: rowIn 700ms var(--ease-out); }
@keyframes rowIn { from { background: var(--ice); } to { background: transparent; } }

/* Terminal */
.term { background: var(--code-bg); color: #e8ecf5; border-radius: var(--r-card); font-family: var(--mono); font-size: 12.5px; line-height: 1.7; padding: 14px 16px; box-shadow: var(--shadow-card); }
.term .p { color: #7f8bff; }
.term .s { color: #9fb3ff; }
.term .k { color: #8a93a8; }

/* Labels projected from 3D */
.labels { position: absolute; inset: 0; pointer-events: none; }
.label { position: absolute; left: 0; top: 0; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--graphite); white-space: nowrap; will-change: transform; }
.label--blue { color: var(--electric); }

/* Lab switcher */
.lab { position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 60; display: flex; gap: 2px; padding: 4px; border-radius: 10px; background: var(--surface-glass); border: 1px solid var(--rule); font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; backdrop-filter: blur(10px); }
.lab a { padding: 6px 9px; border-radius: 6px; color: var(--graphite); }
.lab a[aria-current] { background: var(--inverse); color: var(--on-inverse); }

/* Entrance */
.rise { opacity: 0; transform: translateY(14px); animation: rise 900ms var(--ease-out) forwards; animation-delay: calc(var(--i, 0) * 70ms + 120ms); }
@keyframes rise { to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .rise { animation: fadeOnly 300ms ease forwards; transform: none; }
  @keyframes fadeOnly { to { opacity: 1; } }
  .tilt { transition: none; }
}

/* Canvas stage */
.stage { position: absolute; inset: 0; }
.stage canvas { display: block; }
/* Poster: a pre-rendered first frame shown while three.js loads and builds the scene, then faded out
   once the first live frame is drawn (body[data-ready]). Generated by scripts/render_poster.py. */
.stage::before {
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: url(hero-poster.webp) center / contain no-repeat;
  transition: opacity var(--poster-fade, 400ms) ease;
}
@media (max-width: 900px) { .stage::before { background-image: url(hero-poster-m.webp); } }
body[data-ready] .stage::before { opacity: 0; }

/* ---------- Compact kit (round 2): icons, one word, logos ---------- */
.ic { display: block; flex: none; }
.vlogo { display: block; width: auto; opacity: 0.8; }
.kcard { position: relative; background: var(--surface); border: 1px solid var(--rule); border-radius: 14px; box-shadow: var(--shadow-card); overflow: hidden; }
.khead { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px 0 14px; border-bottom: 1px solid var(--rule); font-size: 13.5px; font-weight: 500; }
.khead .ic { color: var(--electric); }
.live { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 11px; background: var(--fill-ice); color: #08744f; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; }
.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--fill); animation: livePulse 1.8s ease-in-out infinite; }
@keyframes livePulse { 50% { opacity: 0.35; } }
.ev { display: grid; grid-template-columns: 28px 1fr auto 34px; align-items: center; gap: 10px; height: 44px; padding: 0 12px 0 10px; border-top: 1px solid var(--rule); }
.ev:first-child { border-top: 0; }
.ev__ic { width: 28px; height: 28px; border-radius: 8px; background: var(--ice); color: var(--electric); display: grid; place-items: center; }
.ev__w { font-size: 14px; font-weight: 500; letter-spacing: -0.005em; }
.ev__v { display: flex; justify-content: flex-end; }
.ev__d { font-family: var(--mono); font-size: 11px; color: var(--slate); }
.ev__t { font-family: var(--mono); font-size: 11px; color: var(--slate); text-align: right; font-variant-numeric: tabular-nums; }
.ev.is-new { animation: evIn 520ms var(--ease-out); }
@keyframes evIn { from { opacity: 0; transform: translateY(-6px); background: var(--ice); } to { opacity: 1; transform: none; background: transparent; } }

.ltag { display: flex; align-items: center; gap: 10px; }
.ltag__rule { width: 22px; height: 1px; background: var(--rule-2); }
.ltag__ic { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--rule); background: var(--surface); color: var(--ink-2); display: grid; place-items: center; }
.ltag__ic--brand { background: var(--electric); border-color: var(--electric); }
.ltag__ic--brand { color: #fff; }
.ltag__ic--brand .bird { display: block; }
.ltag__n { font-family: var(--mono); font-size: 11px; color: var(--slate); }
.ltag__w { font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--ink); letter-spacing: -0.005em; text-transform: none; }
.ltag--blue .ltag__w { color: var(--electric); }

.ktip { display: grid; gap: 8px; padding: 12px 14px; min-width: 170px; }
.ktip__row { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--graphite); }
.ktip__row .ic { color: var(--fill); }
.ktip__big { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.ktip__big .ic { color: var(--electric); }
@media (prefers-reduced-motion: reduce) { .live::before { animation: none; } .ev.is-new { animation: none; } }
.vchip { display: inline-flex; align-items: center; height: 26px; padding: 0 9px; background: var(--surface); border: 1px solid var(--rule); border-radius: 7px; box-shadow: 0 6px 16px -10px rgba(11,16,32,0.35); }
