/* robotdescription.com — one stylesheet. Tokens match robotdescriptions.com so the two sites read as one family. */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --ink: #1d1d1b;
  --muted: #6b6a64;
  --faint: #a3a19a;
  --line: #e6e3dc;
  --accent: #2f5bd3;
  --accent-soft: #e9eefc;
  --warm: #b4502a;
  --warm-soft: #fbeee6;
  --good: #2f7d4f;
  --good-soft: #e7f3ec;
  --code-bg: #f3f1ec;
  --code-ink: #2b2a27;
  --tok-key: #7a4bb5;
  --tok-str: #2f7d4f;
  --tok-num: #b4502a;
  --tok-type: #2f5bd3;
  --tok-com: #8d8a80;
  --tok-tag: #2f5bd3;
  --tok-attr: #7a4bb5;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141412;
    --surface: #1c1c1a;
    --ink: #ecebe6;
    --muted: #a09e96;
    --faint: #6f6d66;
    --line: #2d2c29;
    --accent: #8aa8ff;
    --accent-soft: #1f2740;
    --warm: #f0956b;
    --warm-soft: #3a2419;
    --good: #7cc79a;
    --good-soft: #1b2f23;
    --code-bg: #1f1f1c;
    --code-ink: #e2e0d8;
    --tok-key: #c3a1f0;
    --tok-str: #7cc79a;
    --tok-num: #f0956b;
    --tok-type: #8aa8ff;
    --tok-com: #7d7b73;
    --tok-tag: #8aa8ff;
    --tok-attr: #c3a1f0;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #141412;
  --surface: #1c1c1a;
  --ink: #ecebe6;
  --muted: #a09e96;
  --faint: #6f6d66;
  --line: #2d2c29;
  --accent: #8aa8ff;
  --accent-soft: #1f2740;
  --warm: #f0956b;
  --warm-soft: #3a2419;
  --good: #7cc79a;
  --good-soft: #1b2f23;
  --code-bg: #1f1f1c;
  --code-ink: #e2e0d8;
  --tok-key: #c3a1f0;
  --tok-str: #7cc79a;
  --tok-num: #f0956b;
  --tok-type: #8aa8ff;
  --tok-com: #7d7b73;
  --tok-tag: #8aa8ff;
  --tok-attr: #c3a1f0;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 64px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16.5px/1.6 var(--sans);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
code { font-family: var(--mono); font-variant-ligatures: none; font-size: 0.88em; background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px; overflow-wrap: anywhere; }
strong { font-weight: 650; }
p { margin: 0 0 14px; }

.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }

/* ---------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; gap: 18px; height: 52px; }
.wordmark { font: 600 15px/1 var(--mono); color: var(--ink); letter-spacing: -0.01em; white-space: nowrap; }
.wordmark:hover { text-decoration: none; }
.wordmark span { color: var(--accent); }
.nav { display: flex; gap: 16px; margin-left: auto; overflow: hidden; }
.nav a { color: var(--muted); font-size: 14px; white-space: nowrap; }
.nav a:hover { color: var(--ink); text-decoration: none; }

/* ---------- masthead */
.masthead { padding-top: 56px; padding-bottom: 6px; }
.kicker { font: 13px/1.4 var(--mono); color: var(--muted); margin: 0 0 16px; letter-spacing: 0.02em; }
h1 { font-size: clamp(34px, 6.4vw, 54px); line-height: 1.04; letter-spacing: -0.025em; margin: 0 0 18px; font-weight: 680; }
.lede { font-size: 19px; color: var(--muted); max-width: 700px; margin: 0; }
.lede strong, .lede code { color: var(--ink); }
.cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 15px; border-radius: 8px; font-size: 15px; font-weight: 550;
  border: 1px solid var(--line); color: var(--ink); background: var(--surface);
}
.button:hover { text-decoration: none; border-color: var(--faint); }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .button.primary { color: #10131c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .button.primary { color: #10131c; } }

/* ---------- pipeline figure */
.pipeline {
  list-style: none; margin: 8px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 26px;
}
.pipeline li {
  position: relative;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 14px 15px;
}
.pipeline li + li::before {
  content: "→"; position: absolute; left: -21px; top: 50%; transform: translateY(-50%);
  color: var(--faint); font-size: 18px;
}
.pipeline .step { font: 12px/1 var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 9px; }
.pipeline .name { font: 600 14px/1.3 var(--mono); margin: 0 0 6px; overflow-wrap: anywhere; }
.pipeline .body { font-size: 14px; line-height: 1.45; color: var(--muted); margin: 0; }
.pipeline li:nth-child(3) { border-color: var(--accent); }
.pipeline li:nth-child(3) .name { color: var(--accent); }
.pipeline-fence {
  margin: 12px 0 0; font: 12.5px/1.4 var(--mono); color: var(--muted);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 26px;
}
.pipeline-fence span:first-child { grid-column: 1 / 3; border-top: 2px solid var(--line); padding-top: 6px; }
.pipeline-fence span:last-child { grid-column: 3 / 5; border-top: 2px solid var(--accent); padding-top: 6px; color: var(--accent); }

/* ---------- sections */
section { padding-top: 64px; }
.section-label { font: 12.5px/1 var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 10px; }
h2 { font-size: clamp(26px, 4.2vw, 34px); line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 18px; font-weight: 660; }
h3 { font-size: 18px; margin: 30px 0 12px; font-weight: 640; letter-spacing: -0.01em; }
.prose { max-width: 720px; }

/* ---------- the Corke quote */
.pullquote {
  margin: 4px 0 26px; padding: 26px 28px 22px;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--warm);
  border-radius: 12px;
}
.pullquote blockquote { margin: 0; font: 400 clamp(23px, 3.6vw, 31px)/1.3 var(--serif); letter-spacing: -0.005em; }
.pullquote figcaption { margin-top: 14px; font-size: 15px; color: var(--muted); }
.pullquote figcaption strong { color: var(--ink); }
.pullquote.mine { border-left-color: var(--accent); padding: 20px 24px 18px; margin-top: 30px; }
.pullquote.mine blockquote { font-size: clamp(20px, 3vw, 25px); }

/* ---------- problem cards */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 18px 0 0; padding: 0; list-style: none; }
.cards li { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.cards h4 { margin: 0 0 5px; font-size: 15.5px; font-weight: 640; }
.cards p { margin: 0; font-size: 15px; color: var(--muted); line-height: 1.5; }

/* ---------- code */
.code-tabs { margin: 22px 0 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--code-bg); }
.tablist { display: flex; gap: 2px; padding: 6px 6px 0; border-bottom: 1px solid var(--line); background: var(--surface); }
.tab {
  appearance: none; border: 0; background: none; cursor: pointer;
  font: 500 13.5px/1 var(--mono); color: var(--muted);
  padding: 10px 12px 11px; border-radius: 7px 7px 0 0; border-bottom: 2px solid transparent;
}
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tab .tab-note { color: var(--faint); font-size: 12px; margin-left: 6px; }
.panel-title { display: none; font: 600 12.5px/1 var(--mono); color: var(--muted); padding: 12px 16px 0; margin: 0; }
html:not(.js) .tablist { display: none; }
html:not(.js) .panel-title { display: block; }
html:not(.js) .panel + .panel { border-top: 1px solid var(--line); }
html.js .panel[hidden] { display: none; }
pre {
  margin: 0; padding: 16px 18px; overflow: auto; max-height: 560px;
  font: 13.2px/1.55 var(--mono); color: var(--code-ink); tab-size: 4;
  font-variant-ligatures: none;
}
pre.full { max-height: none; }
pre.errors { background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; margin-top: 10px; max-height: none; }
.t-key { color: var(--tok-key); }
.t-str { color: var(--tok-str); }
.t-num { color: var(--tok-num); }
.t-type { color: var(--tok-type); }
.t-com { color: var(--tok-com); font-style: italic; }
.t-tag { color: var(--tok-tag); }
.t-attr { color: var(--tok-attr); }
.t-err { color: var(--warm); font-weight: 600; }
.note { font-size: 14px; color: var(--muted); margin: 10px 2px 0; }
.note::before { content: "✓ "; color: var(--good); font-weight: 700; }

/* ---------- tables */
.table-wrap { overflow-x: auto; margin: 12px 0 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th, td { text-align: left; vertical-align: top; padding: 9px 12px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
th { font: 600 12px/1.3 var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; background: var(--bg); }
td code { white-space: nowrap; }
td.fields { color: var(--muted); }
.ops td:first-child { white-space: nowrap; }

/* ---------- principles */
.principles { list-style: none; margin: 22px 0 0; padding: 0; counter-reset: principle; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.principles li { counter-increment: principle; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px 15px; }
.principles li:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.principles h3 { margin: 0 0 7px; font-size: 17px; display: flex; gap: 10px; align-items: baseline; }
.principles h3::before { content: counter(principle, decimal-leading-zero); font: 600 12.5px/1 var(--mono); color: var(--accent); }
.principles p { margin: 0; font-size: 15px; color: var(--muted); line-height: 1.55; }
.principles p code { color: var(--ink); }

/* ---------- prior art */
.refs { list-style: none; margin: 18px 0 0; padding: 0; border-top: 1px solid var(--line); }
.refs li { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 18px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.refs .ref-name { font-weight: 640; font-size: 16px; }
.refs .ref-by { display: block; font-size: 13px; color: var(--muted); margin-top: 3px; }
.refs p { margin: 0; font-size: 15px; }
.refs .diff { margin-top: 6px; color: var(--muted); font-size: 14.5px; }
.refs .diff::before { content: "vs. RobotDescription — "; font: 12.5px var(--mono); color: var(--faint); }
.sibling { margin-top: 18px; padding: 12px 16px; border-radius: 10px; background: var(--accent-soft); font-size: 15px; }

/* ---------- status */
.status-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.status-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.status-card h3 { margin: 0 0 10px; font-size: 16px; }
.status-card ul { margin: 0; padding-left: 18px; font-size: 15px; }
.status-card li { margin: 0 0 7px; }
.status-card.works h3 { color: var(--good); }
.status-card.next h3 { color: var(--warm); }
.questions { margin: 14px 0 0; padding-left: 20px; font-size: 15.5px; }
.questions li { margin-bottom: 6px; }

/* ---------- footer */
.footer { margin-top: 72px; padding: 26px 0 48px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.footer p { margin: 0 0 6px; }

/* ---------- small screens */
@media (max-width: 760px) {
  .nav { display: none; }
  .pipeline, .pipeline-fence { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .pipeline li + li::before { content: "↓"; left: 50%; top: -17px; transform: translateX(-50%); }
  .pipeline-fence { display: none; }
  .cards, .principles, .status-grid { grid-template-columns: minmax(0, 1fr); }
  .refs li { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .pullquote { padding: 20px 18px 18px; }
  pre { font-size: 12.4px; padding: 14px; }
  .tablist { overflow-x: auto; }
  .tab .tab-note { display: none; }
  section { padding-top: 52px; }
}

/* ---------- 404 */
.notfound { padding: 96px 0; }
