/* ==========================================================================
   alexratman.com · site.css
   Design system v1 — black, white, greys, and one red.
   Red signals (labels, progress, rules, selected states). Black acts (buttons,
   links, controls). Greys carry structure. No second hue, no tints.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  /* colour */
  --red: #D7202E;          /* the one colour: signals, never a button */
  --red-on-dark: #F5474F;  /* red as text on dark surfaces (5.2:1 on --dark) */
  --ink: #131416;          /* acts: buttons, links, controls; headings */
  --ink-hover: #3C3F44;    /* pressed / hover of anything ink */
  --text: #2B2D31;
  --muted: #5F6368;
  --faint: #8A8F96;        /* decorative only — not for small text */
  --line: #E3E4E6;
  --line-strong: #C9CCD1;
  --ground: #FFFFFF;
  --ground-alt: #F4F4F2;
  --dark: #121315;
  --dark-raised: #1B1D21;
  --dark-line: #2A2C30;
  --on-dark: #F2F2F0;
  --on-dark-muted: #A6AAB0;

  /* type */
  --font-display: 'Bricolage Grotesque', 'Helvetica Neue', Arial, sans-serif;
  --font-body: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* shape */
  --r-control: 6px;
  --r-card: 10px;
  --r-pill: 999px;

  /* measure */
  --measure: 740px;         /* one column: text, cards and diagrams all fill it */
  --measure-wide: 740px;    /* kept for older markup; equals --measure on purpose */
  --measure-landing: 1100px;
  --gutter: 48px;

  /* rhythm */
  --section-y: 120px;
  --landing-y: 96px;
}

@media (max-width: 720px) {
  :root {
    --gutter: 20px;
    --section-y: 72px;
    --landing-y: 56px;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink);
  margin: 0;
  text-wrap: balance;
}
h1 { font-size: clamp(42px, 8vw, 80px); font-weight: 750; line-height: 1.05; letter-spacing: -0.02em; }
h2 { font-size: clamp(30px, 5vw, 44px); font-weight: 700; line-height: 1.12; letter-spacing: -0.015em; }
h3 { font-size: 20px; font-weight: 700; line-height: 1.3; }
p { margin: 0; }
p + p { margin-top: 12px; }
strong { font-weight: 700; color: var(--ink); }

a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
a:hover { color: var(--red); }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 2px;
}

input, textarea, button { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }
img, svg { max-width: 100%; }
::selection { background: var(--ink); color: #fff; }

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

/* ---------- Text styles ---------- */
.lead { font-size: clamp(18px, 2.5vw, 22px); line-height: 1.6; color: var(--muted); }
.small { font-size: 15.5px; line-height: 1.6; }
.caption { font-size: 14px; line-height: 1.5; color: var(--muted); }
.mono { font-family: var(--font-mono); }

.label {
  font-size: 13px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--red);
}
.label--muted { color: var(--muted); }
.label--sm { font-size: 11px; letter-spacing: 0.14em; }

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: var(--measure); margin-inline: auto; }
.wrap--wide { max-width: var(--measure-wide); }
.wrap--landing { max-width: var(--measure-landing); }

.stack { display: flex; flex-direction: column; gap: 20px; }
.stack--tight { gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.grid--cards { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid--rules { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* ---------- Site chrome ---------- */
.site-nav {
  height: 64px; padding-inline: var(--gutter);
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line); background: var(--ground);
}
.site-nav__brand {
  font-family: var(--font-display); font-size: 20px; font-weight: 700; letter-spacing: -0.01em;
  color: var(--ink); text-decoration: none;
}
.site-nav__brand:hover { color: var(--ink); }
.site-nav__links { display: flex; gap: 28px; align-items: center; font-size: 14px; font-weight: 600; }
.site-nav__links a { color: var(--muted); text-decoration: none; }
.site-nav__links a:hover { color: var(--red); }
.site-nav__links a[aria-current="page"], .site-nav__links a.is-active { color: var(--ink); }
@media (max-width: 720px) {
  .site-nav { height: 56px; }
  .site-nav__brand { font-size: 18px; }
  .site-nav__links { gap: 20px; }
}

.site-footer {
  padding: 32px var(--gutter);
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  border-top: 1px solid var(--line); font-size: 14px; color: var(--muted);
}
.site-footer__links { display: flex; gap: 24px; font-weight: 600; }
.site-footer__links a { color: var(--muted); text-decoration: none; }
.site-footer__links a:hover { color: var(--red); }
@media (max-width: 720px) {
  .site-footer { flex-direction: column; align-items: flex-start; gap: 10px; padding-block: 24px; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 44px; padding: 12px 20px;
  border-radius: var(--r-control); border: 1.5px solid var(--ink);
  background: var(--ink); color: #fff;
  font-size: 15px; font-weight: 700; line-height: 1.2; text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { background: var(--ink-hover); border-color: var(--ink-hover); color: #fff; }
.btn--secondary { background: var(--ground); color: var(--ink); font-weight: 600; padding-inline: 18px; }
.btn--secondary:hover { background: var(--ground-alt); border-color: var(--ink); color: var(--ink); }
.btn--ghost { background: none; border-color: transparent; color: var(--muted); font-size: 14px; font-weight: 600; padding-inline: 8px; }
.btn--ghost:hover { background: none; border-color: transparent; color: var(--red); }
.btn--lg { min-height: 48px; padding: 14px 22px; font-size: 16px; }
.btn--inverse { background: #fff; border-color: #fff; color: var(--ink); }
.btn--inverse:hover { background: var(--on-dark); border-color: var(--on-dark); color: var(--ink); }
.btn svg { flex: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--ground); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 24px;
}
.card--stack { display: flex; flex-direction: column; gap: 12px; }
.card--placeholder { border-style: dashed; border-width: 1.5px; }
@media (max-width: 720px) { .card { padding: 20px; } }

.card--dark {
  background: var(--dark); border-color: var(--dark); color: var(--on-dark);
}
.card--dark h2, .card--dark h3, .card--dark strong { color: var(--on-dark); }
.card--dark .label { color: var(--red-on-dark); }
.card--dark .caption, .card--dark .muted { color: var(--on-dark-muted); }
.card--dark a { color: var(--on-dark); }
.card--dark a:hover { color: var(--red-on-dark); }

/* ---------- Chips ---------- */
.chip {
  display: inline-block; padding: 7px 11px; border-radius: var(--r-control);
  font-weight: 600; font-size: 15.5px; line-height: 1.3; color: #fff; background: var(--ink);
}
.chip--sm { padding: 5px 9px; font-size: 14px; }
.chip--1 { background: var(--red); }
.chip--2 { background: var(--ink); }
.chip--3 { background: var(--muted); }

.chip-outline {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 14px; min-height: 44px; border-radius: var(--r-control);
  border: 1.5px solid var(--line); background: var(--ground); color: var(--text);
  font-size: 16px; font-weight: 600; line-height: 1.2;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.chip-outline:hover { border-color: var(--ink); }
.chip-outline.is-selected { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip-outline.is-target { border: 2px solid var(--red); color: var(--ink); padding: 9px 13px; }

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--ground);
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.pill__num { color: var(--red); font-variant-numeric: tabular-nums; }

.pill-link {
  display: inline-flex; align-items: center; min-height: 44px; padding: 10px 18px;
  border-radius: var(--r-pill); border: 1.5px solid var(--ink);
  color: var(--ink); font-size: 14px; font-weight: 600; text-decoration: none;
}
.pill-link:hover { background: var(--ink); color: #fff; }

/* ---------- Editorial blocks ---------- */
.rule { width: 64px; height: 4px; background: var(--red); }

.takeaway { border-top: 2px solid var(--ink); padding-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.takeaway .label { font-size: 12px; letter-spacing: 0.14em; }
.takeaway p { font-size: 17px; line-height: 1.6; font-weight: 700; color: var(--ink); }

.journey { display: flex; align-items: flex-start; gap: clamp(6px, 2vw, 14px); flex-wrap: wrap; justify-content: center; }
.journey__stop { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.journey__dot { width: 12px; height: 12px; border-radius: 50%; background: var(--ink); }
.journey__dot--1 { background: var(--red); }
.journey__dot--2 { background: var(--ink); }
.journey__dot--3 { background: var(--faint); }
.journey__link { width: clamp(16px, 4vw, 36px); height: 2px; background: var(--line); margin-top: 5px; }
/* step strip for cards: one segment per step, a fixed 4px tall, never wraps */
.steps { display: flex; gap: 4px; height: 4px; width: 100%; max-width: 200px; flex: none; }
.steps__seg { flex: 1 1 0; min-width: 0; border-radius: 2px; background: var(--faint); }
.steps__seg:nth-child(3n+1) { background: var(--red); }
.steps__seg:nth-child(3n+2) { background: var(--ink); }

/* ---------- Forms ---------- */
.input {
  width: 100%; padding: 12px 14px; border-radius: var(--r-control);
  border: 1.5px solid var(--line); background: var(--ground-alt); color: var(--ink); font-size: 16px;
}
.input:focus { border-color: var(--ink); background: var(--ground); }
.input:focus:not(:focus-visible) { outline: none; }

.range { flex: 1; min-width: 140px; accent-color: var(--ink); }

.bar { display: flex; align-items: center; gap: 10px; }
.bar__label { width: 64px; font-size: 14.5px; font-weight: 600; text-align: right; color: var(--ink); }
.bar__track { flex: 1; background: var(--ground-alt); border-radius: 4px; height: 26px; overflow: hidden; }
.bar__fill { height: 26px; border-radius: 4px; transition: width 0.35s ease, opacity 0.35s ease; }
.bar__value { width: 52px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Sections ---------- */
.section { padding: var(--section-y) var(--gutter); }
.section--alt { background: var(--ground-alt); }
.section--landing { padding-block: var(--landing-y); }

/* ---------- Hero ---------- */
.hero {
  min-height: 86vh; display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center; padding: 96px var(--gutter) 64px;
}
.hero__inner { max-width: 820px; display: flex; flex-direction: column; align-items: center; gap: 26px; }
.hero__lead { max-width: 560px; }
.hero__cue { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; font-weight: 600; color: var(--muted); animation: bounceDown 2.2s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .hero__cue { animation: none; } }

.hero--landing { min-height: 0; align-items: flex-start; text-align: left; padding: 72px var(--gutter) 80px; }
.hero--landing .hero__inner { align-items: flex-start; max-width: 980px; gap: 28px; }
.hero--landing .hero__lead { max-width: 640px; }
@media (max-width: 720px) {
  .hero { min-height: 0; padding-top: 64px; }
  .hero--landing { padding: 40px var(--gutter) 48px; }
  .hero--landing .hero__inner { gap: 20px; }
  .hero--landing .row .btn { width: 100%; }
}

/* ---------- Explainer chrome: progress + stage ---------- */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 4px; background: transparent; z-index: 60; pointer-events: none; }
.progress__bar { height: 4px; width: 0; background: var(--red); transition: width 0.1s linear; }
.stage { position: fixed; top: 14px; left: 14px; z-index: 60; pointer-events: none; background: rgba(255,255,255,0.92); backdrop-filter: blur(6px); opacity: 0; transition: opacity 0.3s; }
.stage.is-on { opacity: 1; }
@media (max-width: 720px) { .stage { top: 10px; left: 10px; } }

/* ---------- Reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } }

/* ---------- Motion ---------- */
@keyframes blink { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 0.55; } 50% { transform: scale(1.3); opacity: 1; } }
@keyframes bounceDown { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(8px); } }
@keyframes slotIn { from { opacity: 0; transform: translateY(-24px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---------- Prose bits used by explainers ---------- */
.example { font-size: 14.5px; line-height: 1.6; background: var(--ground-alt); border-radius: var(--r-control); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.example__row { display: flex; gap: 10px; align-items: flex-start; }
.example__row svg { flex: none; margin-top: 3px; }
.example__row--weak { color: var(--muted); }
.example__row--better { color: var(--ink); }

.codeblock {
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-control); padding: 16px;
  font-family: var(--font-mono); font-size: 13.5px; line-height: 1.7; color: var(--muted); background: var(--ground-alt);
  display: flex; flex-direction: column; gap: 4px;
}
.bubble { border-radius: 10px 10px 10px 2px; padding: 14px 18px; font-size: 16px; line-height: 1.5; max-width: 420px; }
.bubble--user { background: var(--ink); color: #fff; }
.bubble--user-right { border-radius: 10px 10px 2px 10px; margin-left: auto; }
.bubble--assistant { background: var(--ground-alt); border: 1px solid var(--line); color: var(--ink); max-width: none; font-size: 16.5px; line-height: 1.7; min-height: 88px; }

details.sources { border-top: 1px solid var(--line); padding-top: 18px; font-size: 13.5px; line-height: 1.55; color: var(--muted); text-align: left; }
details.sources summary { cursor: pointer; font-size: 14px; font-weight: 700; color: var(--ink); list-style-position: inside; }
details.sources ul { list-style: none; margin: 0; padding: 0; }
details.sources li { margin: 0 0 8px; }
details.sources .label { display: block; margin: 18px 0 8px; font-size: 11.5px; letter-spacing: 0.12em; color: var(--muted); }
