/* ============================================================================
   proofstone — design direction 1 "technical paper" + status badges (dir. 2)
   Calm engineering document: narrow reading column, air, near-B/W + one accent,
   mono only for milestone IDs/code. Light + dark. Zero external fonts.
   ============================================================================ */

:root {
  --bg: #fdfdfc;
  --surface: #f4f5f7;
  --surface-2: #eceef1;
  --text: #16181d;
  --muted: #5b626d;
  --border: #e0e3e8;
  --accent: #2457d6;
  --accent-weak: #e7edfb;
  --gold: #9a6a00;
  --gold-weak: #f7efd8;
  --code-bg: #eef0f3;
  --shadow: 0 1px 2px rgba(20, 24, 33, .06), 0 4px 16px rgba(20, 24, 33, .04);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --measure: 46rem;
  --page: 60rem;
}

[data-theme="dark"] {
  --bg: #0e1116;
  --surface: #161b22;
  --surface-2: #1c222b;
  --text: #e6e8ec;
  --muted: #99a1ad;
  --border: #262c36;
  --accent: #6f9bff;
  --accent-weak: #16223b;
  --gold: #e0b64d;
  --gold-weak: #2a2413;
  --code-bg: #1a2028;
  --shadow: none;
}

/* No-JS fallback: honor OS dark unless the user explicitly picked light. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116; --surface: #161b22; --surface-2: #1c222b; --text: #e6e8ec;
    --muted: #99a1ad; --border: #262c36; --accent: #6f9bff; --accent-weak: #16223b;
    --gold: #e0b64d; --gold-weak: #2a2413; --code-bg: #1a2028; --shadow: none;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: #fff; padding: .5rem .75rem; border-radius: 6px; z-index: 100;
}
.skip-link:focus { left: .5rem; top: .5rem; }

/* ── Header / footer ──────────────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .7rem 1.25rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; letter-spacing: -.01em; font-size: 1.05rem; color: var(--text); }
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; }
.site-nav { display: flex; align-items: center; gap: 1rem; }

.theme-toggle {
  width: 2.1rem; height: 2.1rem; display: inline-grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); cursor: pointer;
}
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle__icon::before { content: "☾"; font-size: 1rem; }
[data-theme="dark"] .theme-toggle__icon::before { content: "☀"; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle__icon::before { content: "☀"; }
}

main { padding: 2.5rem 1.25rem 4rem; }

.site-footer {
  border-top: 1px solid var(--border); color: var(--muted);
  font-size: .85rem; padding: 1.75rem 1.25rem; text-align: center;
}
.site-footer p { margin: .25rem 0; }

/* ── Home ─────────────────────────────────────────────────────────────────── */
.hero { max-width: var(--page); margin: 1rem auto 2.5rem; text-align: center; }
.hero__title {
  font-size: clamp(1.9rem, 4.5vw, 3rem); line-height: 1.12; letter-spacing: -.02em;
  margin: 0 0 .5rem; font-weight: 800;
}
.hero__sub { font-size: 1.15rem; color: var(--muted); margin: 0 0 1.25rem; }
.hero__series {
  display: inline-block; font-size: .9rem; color: var(--muted);
  border: 1px dashed var(--border); border-radius: 999px; padding: .35rem .85rem;
}

.roadmaps { max-width: var(--page); margin: 0 auto; display: grid; gap: 1rem; }
.card {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 1.4rem 1.5rem; box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .12s ease;
}
.card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--accent); }
.card__title { margin: 0 0 .35rem; font-size: 1.4rem; letter-spacing: -.01em; color: var(--text); }
.card__tagline { margin: 0 0 1rem; color: var(--muted); }
.card__meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 0; }
.card__go { margin-left: auto; color: var(--accent); font-size: 1.3rem; }

.thesis { max-width: var(--measure); margin: 3rem auto 0; }
.thesis h2 { font-size: 1.3rem; letter-spacing: -.01em; }
.thesis p { color: var(--text); }
.thesis__contribute { color: var(--muted); font-size: .95rem; margin-top: 1.25rem; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-family: var(--mono); font-size: .72rem; letter-spacing: .02em;
  padding: .2rem .5rem; border-radius: 6px; border: 1px solid var(--border);
  color: var(--muted); background: var(--bg);
}
.badge--count { color: var(--muted); }
.badge--star { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); background: var(--accent-weak); }
.badge--flag { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 45%, var(--border)); background: var(--gold-weak); }

/* ── Roadmap page: top bar ────────────────────────────────────────────────── */
.roadmap__bar {
  max-width: var(--measure); margin: 0 auto 1.75rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding-bottom: 1rem; border-bottom: 1px solid var(--border);
}
.breadcrumb { color: var(--muted); font-size: .9rem; }
.breadcrumb span { color: var(--text); }
.roadmap__actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.btn {
  font-size: .85rem; padding: .4rem .75rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn--primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn--primary:hover { filter: brightness(1.06); background: var(--accent); }

/* ── Prose (rendered README) ──────────────────────────────────────────────── */
.prose { max-width: var(--measure); margin: 0 auto; }
.prose > :first-child { margin-top: 0; }
.prose h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); line-height: 1.15; letter-spacing: -.02em; margin: 2.5rem 0 1rem; }
.prose h2 {
  font-size: 1.5rem; letter-spacing: -.01em; margin: 3rem 0 1rem;
  padding-bottom: .4rem; border-bottom: 1px solid var(--border);
}
.prose h3 { font-size: 1.18rem; margin: 2rem 0 .6rem; }
/* Anchor jumps land below the sticky header + progress bar. */
.prose h1, .prose h2, .prose h3, .prose h4 { scroll-margin-top: 6rem; }
.prose h4 { font-size: 1.02rem; margin: 1.5rem 0 .5rem; }
.prose p, .prose li { line-height: 1.72; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin: .3rem 0; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2.5rem 0; }
.prose strong { font-weight: 700; }

/* Milestone criterion + callouts = the product's core visual. */
.prose blockquote {
  margin: 1rem 0; padding: .85rem 1.1rem;
  background: var(--surface); border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0; color: var(--text);
}
.prose blockquote p { margin: .4rem 0; }
.prose blockquote > :first-child { margin-top: 0; }
.prose blockquote > :last-child { margin-bottom: 0; }

.prose code {
  font-family: var(--mono); font-size: .86em;
  background: var(--code-bg); padding: .12em .4em; border-radius: 5px;
}
.prose pre {
  background: var(--code-bg); padding: 1rem 1.1rem; border-radius: 10px;
  overflow-x: auto; border: 1px solid var(--border);
}
.prose pre code { background: none; padding: 0; font-size: .85em; }

/* Wide tables scroll inside themselves — the page never scrolls sideways. */
.prose table { display: block; width: max-content; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: .92rem; }
.prose th, .prose td { border: 1px solid var(--border); padding: .5rem .7rem; text-align: left; vertical-align: top; }
.prose thead th { background: var(--surface); }

/* SVG roadmap map — responsive, never overflows the page. */
.prose img { max-width: 100%; height: auto; display: block; margin: 1rem auto; }
.prose sub { color: var(--muted); }

/* Heading anchor (# on hover) */
.ps-anchor { margin-left: .4rem; color: var(--muted); opacity: 0; text-decoration: none; font-weight: 400; }
.prose :hover > .ps-anchor, .ps-anchor:focus { opacity: 1; }

/* ── Milestone progress (injected by app.js) ──────────────────────────────── */
.prose h3.is-milestone { display: flex; align-items: flex-start; gap: .6rem; }
.ps-check {
  appearance: none; -webkit-appearance: none; flex: 0 0 auto;
  width: 1.15rem; height: 1.15rem; margin-top: .18rem;
  border: 2px solid var(--border); border-radius: 5px; background: var(--bg); cursor: pointer;
}
.ps-check:checked { background: var(--accent); border-color: var(--accent); }
.ps-check:checked::after { content: "✓"; color: #fff; font-size: .8rem; display: grid; place-items: center; height: 100%; }
.ps-check:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h3.is-flagship .ps-flag {
  font-family: var(--mono); font-size: .68rem; color: var(--gold);
  border: 1px solid color-mix(in srgb, var(--gold) 45%, var(--border));
  background: var(--gold-weak); border-radius: 5px; padding: .1rem .4rem; margin-left: .5rem; white-space: nowrap;
}

.progress {
  position: sticky; top: 3.4rem; z-index: 10;
  max-width: var(--measure); margin: 0 auto 1.5rem;
  display: flex; align-items: center; gap: .75rem;
  font-size: .82rem; color: var(--muted);
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(6px);
  padding: .4rem 0;
}
.progress__bar { flex: 1; height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress__fill { height: 100%; width: 0; background: var(--accent); transition: width .2s ease; }
.progress__reset { color: var(--muted); background: none; border: 0; cursor: pointer; font-size: .8rem; text-decoration: underline; }

/* ── 404 ──────────────────────────────────────────────────────────────────── */
.notfound { max-width: var(--measure); margin: 3rem auto; text-align: center; }
.notfound h1 { font-size: 4rem; margin: 0; letter-spacing: -.03em; }

/* ── Motion / small screens ───────────────────────────────────────────────── */
@media (max-width: 40rem) {
  body { font-size: 16.5px; }
  main { padding: 1.75rem 1rem 3rem; }
  .roadmap__bar { align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
