/* Base: tokens, reset, type, layout primitives and the controls every page uses. */

:root {
  --paper: #edf0f5;
  --paper-2: #e2e7ef;
  --surface: #ffffff;
  --ink: #0e1a33;
  --ink-2: #4a5775;
  --line: #cfd6e3;
  --signal: #2563eb;
  --grant: #0e9f6e;
  --risk: #c77700;
  --blue-field: #1d4ed8;

  /* Dark surfaces: code, logs, the inspector. */
  --code-bg: #0e1a33;
  --code-bar: #162547;
  --code-line: #22345f;
  --code-ink: #dbe4f7;
  --code-dim: #8896b8;
  --code-scroll: #34487a;

  --font-display:
    "Bricolage Grotesque", "Hanken Grotesk", system-ui, sans-serif;
  --font-body: "Hanken Grotesk", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --wrap: 1120px;
  --gutter: 24px; /* the page's side padding; full-bleed pieces undo it */
}

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

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--signal);
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 3px solid var(--signal);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- Type ---------- */

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.6rem, 6vw, 4.6rem);
  font-variation-settings: "wdth" 90;
}

h2 {
  font-size: clamp(1.8rem, 3.4vw, 2.6rem);
}

h3 {
  font-size: 1.3rem;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

p {
  margin: 0;
}

.lede {
  font-size: 1.2rem;
  color: var(--ink-2);
  max-width: 52ch;
}

code,
pre,
kbd {
  font-family: var(--font-mono);
  font-size: 0.88em;
}

:not(pre) > code {
  background: var(--paper-2);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  overflow-wrap: anywhere;
}

/* ---------- Layout ---------- */

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

section {
  padding: 72px 0;
}

section + section {
  border-top: 1px solid var(--line);
}

.section-head {
  display: grid;
  gap: 14px;
  margin-bottom: 40px;
  max-width: 62ch;
}

.page-head {
  padding: 56px 0 28px;
  display: grid;
  gap: 14px;
}

.page-head h1 {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
}

.status-line {
  font-size: 0.9rem;
  color: var(--ink-2);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Grid children must be allowed to shrink below their widest content, or a
   long code block widens the whole page. */
.panel,
.controls,
.step,
.stage,
.hero-copy,
.flow-step,
.attack-stage,
.play-side,
.play-out,
.compose-out,
.prose {
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
}

/* ---------- Components ---------- */

.btn {
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  border: 0;
  border-radius: 7px;
  padding: 9px 14px;
  cursor: pointer;
  background: var(--signal);
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn:hover {
  filter: brightness(1.08);
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.small {
  padding: 6px 10px;
  font-size: 0.82rem;
}

.cta-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  display: grid;
  gap: 16px;
  align-content: start;
}

.panel p {
  color: var(--ink-2);
}

.badge {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--paper-2);
  color: var(--ink-2);
  width: fit-content;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}

.tab {
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  background: none;
  border: 0;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--ink-2);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--signal);
}

/* A segmented choice: a radiogroup of buttons, one checked. */

.seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.seg button {
  padding: 6px 12px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--ink-2);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

.seg button[aria-checked="true"] {
  background: var(--ink);
  color: #fff;
}

/* ---------- Forms ---------- */

.controls {
  display: grid;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  align-content: start;
}

.field {
  display: grid;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
}

.field input[type="text"],
.field select {
  font: inherit;
  font-weight: 400;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}

.field input[type="color"] {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 3px;
}

.checks {
  display: grid;
  gap: 8px;
  border: 0;
  padding: 0;
  margin: 0;
}

.checks legend {
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0;
  margin-bottom: 8px;
}

.checks label,
.switch {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.92rem;
}

.switch {
  font-weight: 600;
}

/* ---------- Tables ---------- */

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92rem;
}

th,
td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  background: var(--paper-2);
  font-weight: 600;
}

tr:last-child td {
  border-bottom: 0;
}

td:first-child code {
  white-space: nowrap;
}

/* ---------- Brand swatches (hero, gallery) ---------- */

.swatches {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.88rem;
  color: var(--ink-2);
}

.swatch-row {
  display: flex;
  gap: 10px;
}

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
  padding: 0;
}

.swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--ink);
}

/* ---------- Event logs (hero, sign-in) ---------- */

.log {
  background: var(--code-bg);
  color: var(--code-ink);
  border-radius: 12px;
  padding: 14px 16px;
  min-height: 96px;
  max-height: 220px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
}

.log .muted {
  color: var(--code-dim);
}

.log .ev {
  color: #7fe0b5;
}

.log .ev.deny {
  color: #ffb380;
}

.log pre {
  margin: 2px 0 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 900px) {
  section {
    padding: 56px 0;
  }
}

@media (max-width: 600px) {
  :root {
    --gutter: 16px;
  }
}
