/* Base layout, type, and controls. Colors come only from tokens.css. */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
img, svg { max-width: 100%; }
a { color: var(--accent); }
a:hover { color: var(--signal-amber); }
:focus-visible { outline: 2px solid var(--signal-amber); outline-offset: 3px; }
code, pre, .mono { font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace; }

/* ---------- background layers ---------- */
.bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bg-gradient {
  position: absolute; inset: 0;
  background: url(../assets/brand/patterns/gradient-bg5.webp) center 0% / cover no-repeat;
  opacity: 0; transition: opacity 1.2s ease;
}
body[data-chapter="hero"] .bg-gradient { opacity: 1; }
.bg-lines {
  position: absolute; opacity: .1;
  transition: opacity 1.2s ease, left 1.4s cubic-bezier(.2,.7,.2,1), top 1.4s cubic-bezier(.2,.7,.2,1), width 1.4s cubic-bezier(.2,.7,.2,1), height 1.4s cubic-bezier(.2,.7,.2,1);
}
body[data-chapter="hero"] .bg-lines { opacity: .22; }
.bg-lines svg { width: 100%; height: 100%; }
.bg-lines ellipse { fill: none; stroke: var(--ink-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
#well { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ---------- chrome ---------- */
.top, .nav, main { position: relative; z-index: 1; }
.top {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) clamp(16px, 4vw, 48px);
}
.brand { display: block; line-height: 0; flex: none; padding: 6px 0; }
.brand img { height: 32px; width: auto; }
.rail { flex: 1; display: flex; justify-content: center; gap: 6px; min-width: 0; }
.rail button {
  appearance: none; border: 0; background: none; padding: 10px 2px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0;
  color: var(--ink-muted); font: 700 11px/1 var(--font-body); letter-spacing: .12em; text-transform: uppercase;
}
.rail button::before {
  content: ""; display: block; width: clamp(18px, 4vw, 44px); height: 3px; border-radius: 2px;
  background: var(--rule); transition: background .3s ease;
}
.rail button.done::before { background: var(--drift-blue); }
.rail button[aria-current="step"]::before { background: var(--accent); }
.rail button[aria-current="step"] { color: var(--ink-strong); }
.rail button:disabled { cursor: default; }
.rail .rail-label { display: none; white-space: nowrap; }
@media (min-width: 1100px) { .rail .rail-label { display: block; } }
.top-actions { flex: none; }

main { flex: 1; display: flex; outline: none; }
.chapter {
  width: 100%; max-width: 1440px; margin: 0 auto;
  padding: var(--space-5) clamp(16px, 5vw, 72px) var(--space-6);
  display: flex; flex-direction: column; justify-content: center;
}
.nav {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-3) clamp(16px, 4vw, 48px) var(--space-4);
}
.nav-hint { color: var(--ink-muted); font-size: 13px; text-align: center; flex: 1; }
body[data-chapter="hero"] .nav { visibility: hidden; }

/* ---------- type ---------- */
.eyebrow { font: 700 12px/1.2 var(--font-body); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin: 0 0 var(--space-3); }
.display-xl, .display, .headline, .headline-sm { font-family: var(--font-display); font-weight: 400; text-transform: uppercase; margin: 0; color: var(--ink-strong); }
.display-xl { font-size: clamp(44px, 8vw, 96px); line-height: .95; letter-spacing: -.02em; }
.display { font-size: clamp(36px, 5.6vw, 64px); line-height: .95; letter-spacing: -.02em; }
.headline { font-size: clamp(30px, 4vw, 48px); line-height: 1; letter-spacing: -.01em; }
.headline-sm { font-size: clamp(22px, 2.6vw, 32px); line-height: 1.1; letter-spacing: -.01em; }
.hl { color: var(--accent); }
.lead { font-size: clamp(17px, 1.6vw, 20px); line-height: 1.55; max-width: 62ch; margin: var(--space-4) 0 0; }
.subhead { font-weight: 700; font-size: clamp(19px, 2vw, 24px); line-height: 1.25; margin: 0; color: var(--ink-strong); }
.caption, .muted { color: var(--ink-muted); font-size: 13px; line-height: 1.4; }
p { margin: 0 0 var(--space-3); }

/* ---------- buttons (DesignBot Button guidance) ---------- */
.btn {
  appearance: none; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 16px/1.2 var(--font-body); border-radius: var(--radius-sm); padding: 15px 28px; min-height: 44px;
  border: 1px solid transparent; transition: transform .15s ease, background .2s ease, color .2s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--signal-amber); color: var(--on-accent); }
.btn-secondary { background: transparent; color: var(--ink-strong); border-color: var(--ink-strong); }
.btn-secondary:hover { background: var(--surface-raised); color: var(--ink-strong); }
.btn-quiet { background: none; color: var(--accent); padding-left: 8px; padding-right: 8px; }
.btn-quiet:hover { color: var(--signal-amber); }
.btn-sm { padding: 11px 20px; font-size: 14px; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }

/* ---------- surfaces ---------- */
.card {
  background: color-mix(in srgb, var(--surface-raised) 88%, transparent);
  border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: var(--space-5);
  backdrop-filter: blur(6px);
}
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--rule); font-size: 13px; color: var(--ink-muted); background: var(--surface);
}
.codeblock {
  margin: 0; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  background: var(--surface); border: 1px solid var(--rule); color: var(--ink);
  font-size: 13px; line-height: 1.6; overflow-x: auto; white-space: pre;
}
.codeblock .pipe { color: var(--accent); }
.quote { margin: 0; padding-left: var(--space-3); border-left: 0; }
.quote blockquote { margin: 0; font-size: 17px; line-height: 1.5; color: var(--ink-strong); }
.quote blockquote::before { content: "“"; color: var(--accent); font-family: var(--font-display); margin-right: 2px; }
.quote blockquote::after { content: "”"; color: var(--accent); font-family: var(--font-display); margin-left: 2px; }
.quote figcaption { margin-top: var(--space-2); }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-family: var(--font-display); font-weight: 400; font-size: clamp(32px, 4vw, 48px); line-height: 1; color: var(--accent); }
.src { font-size: 12px; color: var(--ink-muted); }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { position: relative; z-index: 2; padding: 24px; }

@media (max-width: 720px) {
  .top { gap: var(--space-2); }
  .brand img { height: 30px; }
  .rail { gap: 3px; }
  .rail button::before { width: 12px; }
  .btn { padding: 13px 18px; }
  .nav-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
@media (max-width: 820px) {
  /* keep text over the calm, dark top of the brand gradient (uniform scale, cropped) */
  .bg-gradient { background-size: 280% auto; background-position: 30% 0; }
}
