/* BLOCK-20 documentation site. Hand-authored, no build step. */

:root {
  color-scheme: light dark;

  --bg: #f4f5f7;
  --bg-deep: #e6e9ee;
  --surface: #ffffff;
  --surface-2: #eceff3;
  --text: #14181f;
  --muted: #4a5261;
  --line: #ced3db;
  --line-strong: #9aa4b2;
  --accent: #8a5200;
  --accent-strong: #6d4100;
  --accent-bg: #fff3df;
  --ok: #14603a;
  --ok-bg: #e2f4ea;
  --bad: #97231c;
  --bad-bg: #fdeae8;
  --btn-fg: #ffffff;
  --shadow: 0 1px 0 rgba(20, 24, 31, .06), 0 6px 18px rgba(20, 24, 31, .05);

  --mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --wrap: 74rem;
  --radius: 4px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1218;
    --bg-deep: #080b0f;
    --surface: #151b23;
    --surface-2: #1c242e;
    --text: #e6eaf0;
    --muted: #a3adbb;
    --line: #2b3540;
    --line-strong: #46525f;
    --accent: #f2a938;
    --accent-strong: #ffc267;
    --accent-bg: #2a1e0c;
    --ok: #6fd39b;
    --ok-bg: #10281c;
    --bad: #ff9d92;
    --bad-bg: #2c1512;
    --btn-fg: #0e1218;
    --shadow: 0 1px 0 rgba(0, 0, 0, .5), 0 8px 22px rgba(0, 0, 0, .35);
  }
}

:root[data-theme="dark"] {
  --bg: #0e1218;
  --bg-deep: #080b0f;
  --surface: #151b23;
  --surface-2: #1c242e;
  --text: #e6eaf0;
  --muted: #a3adbb;
  --line: #2b3540;
  --line-strong: #46525f;
  --accent: #f2a938;
  --accent-strong: #ffc267;
  --accent-bg: #2a1e0c;
  --ok: #6fd39b;
  --ok-bg: #10281c;
  --bad: #ff9d92;
  --bad-bg: #2c1512;
  --btn-fg: #0e1218;
  --shadow: 0 1px 0 rgba(0, 0, 0, .5), 0 8px 22px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.62;
  overflow-wrap: break-word;
}

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-strong); }

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

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 60;
  background: var(--surface); color: var(--text);
  padding: 10px 16px; border: 2px solid var(--accent);
}
.skip:focus { left: 8px; top: 8px; }

/* ---------- header ---------- */

.site-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--line);
}
.nav-wrap {
  display: flex; flex-wrap: wrap; gap: 10px 18px;
  align-items: center;
  padding-top: 10px; padding-bottom: 10px;
}
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 700; letter-spacing: .01em; color: var(--text); text-decoration: none;
  margin-right: auto;
}
.brand-mark {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px;
  border: 2px solid var(--accent);
  border-radius: 3px;
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  color: var(--accent);
  background: var(--accent-bg);
}
.site-nav { display: flex; flex-wrap: wrap; gap: 2px 4px; }
.site-nav a {
  display: inline-block;
  padding: 5px 9px;
  font-size: .875rem; font-weight: 600;
  color: var(--muted); text-decoration: none;
  border-radius: var(--radius);
  border: 1px solid transparent;
}
.site-nav a:hover { color: var(--text); background: var(--surface-2); }
.site-nav a[aria-current="page"] {
  color: var(--accent); border-color: var(--line-strong); background: var(--accent-bg);
}
.header-tools { display: flex; gap: 8px; align-items: center; }

.theme-toggle {
  font: inherit; font-size: .8125rem; font-weight: 600;
  padding: 5px 10px; cursor: pointer;
  color: var(--text); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- search ---------- */

.search { position: relative; }
.search input {
  font: inherit; font-size: .875rem;
  width: 15rem; max-width: 46vw;
  padding: 5px 10px;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
}
.search input::placeholder { color: var(--muted); }
.search-results {
  position: absolute; right: 0; top: calc(100% + 6px);
  width: min(30rem, 90vw);
  max-height: 62vh; overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
  margin: 0; list-style: none;
}
.search-results:empty { display: none; }
.search-results li { margin: 0; }
.search-results a {
  display: block; padding: 8px 10px; border-radius: var(--radius);
  color: var(--text); text-decoration: none;
}
.search-results a:hover, .search-results a:focus-visible { background: var(--surface-2); }
.search-results .r-page { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--accent); font-weight: 700; }
.search-results .r-title { font-weight: 600; display: block; }
.search-results .r-snip { font-size: .8125rem; color: var(--muted); display: block; }
.search-empty { padding: 10px; color: var(--muted); font-size: .875rem; }

/* ---------- type ---------- */

main { display: block; padding-bottom: 64px; }

h1, h2, h3, h4 { line-height: 1.22; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: clamp(1.85rem, 1.2rem + 2.4vw, 2.9rem); }
h2 { font-size: clamp(1.35rem, 1.05rem + 1.1vw, 1.8rem); margin-top: 0; }
h3 { font-size: 1.09rem; }
h4 { font-size: .98rem; }
p, ul, ol, dl { margin: 0 0 1em; }
li { margin-bottom: .35em; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 62ch; }
.small { font-size: .875rem; }
.muted { color: var(--muted); }

.eyebrow {
  font-family: var(--mono); font-size: .75rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 .5em;
}

section { padding: 34px 0; border-top: 1px solid var(--line); }
section:first-of-type { border-top: 0; }
.section-head { max-width: 68ch; margin-bottom: 20px; }

/* ---------- hero ---------- */

.hero {
  background:
    linear-gradient(var(--bg-deep), var(--bg-deep)) padding-box,
    var(--bg-deep);
  border-bottom: 1px solid var(--line);
  padding: 40px 0 34px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute; inset: auto 0 0 0; height: 2px;
  background: repeating-linear-gradient(90deg, var(--accent) 0 26px, transparent 26px 34px);
  opacity: .55;
}
.hero-grid { display: grid; gap: 26px; align-items: start; }
@media (min-width: 62rem) { .hero-grid { grid-template-columns: 1.35fr .95fr; gap: 40px; } }

.height-display {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(2.6rem, 1.4rem + 5.5vw, 5.2rem);
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: .95;
  color: var(--accent);
  margin: 0;
}
.height-label {
  font-family: var(--mono); font-size: .75rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); margin: 6px 0 0;
}

.facts {
  margin: 0; padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.facts > div {
  display: grid; grid-template-columns: 11.5rem 1fr; gap: 4px 14px;
  padding: 9px 14px; border-bottom: 1px solid var(--line);
}
.facts > div:last-child { border-bottom: 0; }
.facts dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.facts dd { margin: 0; font-size: .9rem; }
@media (max-width: 34rem) { .facts > div { grid-template-columns: 1fr; } }

/* ---------- blocks / cards ---------- */

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.card h3 { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card.accent { border-left-color: var(--accent); }

.kicker {
  font-family: var(--mono); font-size: .72rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: var(--accent);
  margin: 0 0 .3em;
}

.callout {
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--accent);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0 0 16px;
}
.callout > :last-child { margin-bottom: 0; }
.callout.warn { border-left-color: var(--accent); background: var(--accent-bg); }
.callout.bad { border-left-color: var(--bad); background: var(--bad-bg); }
.callout.good { border-left-color: var(--ok); background: var(--ok-bg); }

/* ---------- code ---------- */

code, kbd, samp, pre { font-family: var(--mono); }
code {
  font-size: .875em;
  overflow-wrap: anywhere;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: .08em .32em;
}
pre {
  margin: 0;
  overflow-x: auto;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: .84rem;
  line-height: 1.55;
}
pre code { background: none; border: 0; padding: 0; font-size: inherit; overflow-wrap: normal; }

.code-card { margin: 0 0 16px; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.code-card > header {
  display: flex; flex-wrap: wrap; gap: 6px 12px; justify-content: space-between; align-items: baseline;
  padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--line);
  font-size: .8125rem;
}
.code-card > header span { color: var(--muted); font-family: var(--mono); font-size: .75rem; }
.code-card pre { border: 0; border-radius: 0; }

.hash {
  font-family: var(--mono);
  color: var(--accent);
  word-break: break-all;
  font-size: .84em;
}

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--line-strong); border-radius: var(--radius); margin: 0 0 16px; }
table { border-collapse: collapse; width: 100%; min-width: 34rem; font-size: .9rem; background: var(--surface); }
caption { text-align: left; padding: 10px 14px; color: var(--muted); font-size: .85rem; border-bottom: 1px solid var(--line); }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { background: var(--surface-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
tbody tr:last-child td { border-bottom: 0; }

/* ---------- numbered rules ---------- */

.rules { list-style: none; margin: 0 0 20px; padding: 0; counter-reset: none; }
.rule {
  display: grid; grid-template-columns: 5.4rem 1fr; gap: 4px 16px;
  padding: 12px 0; border-top: 1px solid var(--line);
  margin: 0;
}
.rule:last-child { border-bottom: 1px solid var(--line); }
.rule-id {
  font-family: var(--mono); font-size: .82rem; font-weight: 700;
  color: var(--accent); letter-spacing: .02em; padding-top: .12em;
}
.rule-body { min-width: 0; }
.rule-body > :last-child { margin-bottom: 0; }
@media (max-width: 34rem) { .rule { grid-template-columns: 1fr; } }

/* ---------- diagrams ---------- */

figure { margin: 0 0 20px; }
figure svg { display: block; width: 100%; height: auto; max-width: 100%; }
figcaption { font-size: .85rem; color: var(--muted); margin-top: 8px; }
.diagram {
  --d-line: var(--line-strong);
  --d-fill: var(--surface);
  --d-text: var(--text);
  --d-muted: var(--muted);
  --d-accent: var(--accent);
  --d-accent-bg: var(--accent-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 14px;
  overflow-x: auto;
}

/* ---------- verifier tool ---------- */

.tool {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
}
.tool[hidden] { display: none; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: .875rem; margin-bottom: 4px; }
.field .hint { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea {
  font-family: var(--mono); font-size: .85rem;
  width: 100%; padding: 8px 10px;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
}
.field textarea { min-height: 7.5rem; resize: vertical; line-height: 1.5; }
.field-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }

.button {
  font: inherit; font-weight: 700; font-size: .9rem;
  display: inline-block; cursor: pointer;
  padding: 9px 16px; border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent); color: var(--btn-fg);
  text-decoration: none;
}
.button:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.button.secondary { background: transparent; color: var(--accent); }
.button.secondary:hover { background: var(--accent-bg); color: var(--accent-strong); }

.steps { list-style: none; margin: 18px 0 0; padding: 0; }
.steps li {
  display: grid; grid-template-columns: 1.6rem 1fr; gap: 4px 12px;
  padding: 10px 12px; margin-bottom: 6px;
  border: 1px solid var(--line); border-left: 4px solid var(--line-strong);
  border-radius: var(--radius); background: var(--bg);
  font-size: .9rem;
}
.steps li.pass { border-left-color: var(--ok); }
.steps li.fail { border-left-color: var(--bad); background: var(--bad-bg); }
.steps li.info { border-left-color: var(--accent); }
.steps .mark { font-family: var(--mono); font-weight: 700; }
.steps li.pass .mark { color: var(--ok); }
.steps li.fail .mark { color: var(--bad); }
.steps li.info .mark { color: var(--accent); }
.steps .step-body > :last-child { margin-bottom: 0; }

.verdict {
  font-weight: 700; font-size: 1.05rem;
  padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); margin: 18px 0 0;
}
.verdict.pass { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.verdict.fail { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }

/* ---------- chain strip ---------- */

.chain-strip {
  display: flex; gap: 0; align-items: stretch; flex-wrap: wrap;
  margin: 0 0 18px;
}
.chain-strip .blk {
  flex: 1 1 8.5rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 12px;
  margin-right: 14px; margin-bottom: 12px;
  position: relative;
}
.chain-strip .blk::after {
  content: ""; position: absolute; right: -14px; top: 50%;
  width: 14px; height: 2px; background: var(--line-strong);
}
.chain-strip .blk:last-child { margin-right: 0; }
.chain-strip .blk:last-child::after { display: none; }
.chain-strip .blk.anchor { border-color: var(--accent); background: var(--accent-bg); }
.chain-strip .blk .h { font-family: var(--mono); font-weight: 700; font-size: .95rem; }
.chain-strip .blk .t { font-size: .78rem; color: var(--muted); display: block; }
@media (max-width: 44rem) { .chain-strip .blk::after { display: none; } }

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg-deep);
  padding: 26px 0 40px;
  font-size: .85rem;
  color: var(--muted);
}
.footer-facts {
  display: grid; gap: 4px 22px;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  margin: 0 0 14px; padding: 0;
}
.footer-facts div { display: flex; gap: 8px; flex-wrap: wrap; padding: 3px 0; border-bottom: 1px solid var(--line); }
.footer-facts dt { font-weight: 700; color: var(--text); font-size: .8rem; }
.footer-facts dd { margin: 0; font-size: .8rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; padding: 0; list-style: none; }

/* ---------- misc ---------- */

.toc { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 14px 18px; margin: 0 0 22px; }
.toc h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: .6em; }
.toc ol { margin: 0; padding-left: 1.3em; columns: 2; column-gap: 26px; font-size: .9rem; }
@media (max-width: 40rem) { .toc ol { columns: 1; } }

.tag {
  display: inline-block; font-family: var(--mono); font-size: .7rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 2px;
  border: 1px solid var(--line-strong); color: var(--muted); background: var(--surface-2);
}
.tag.ok { color: var(--ok); border-color: var(--ok); background: var(--ok-bg); }
.tag.no { color: var(--bad); border-color: var(--bad); background: var(--bad-bg); }
.tag.amber { color: var(--accent); border-color: var(--accent); background: var(--accent-bg); }

.anchor-link { color: var(--muted); text-decoration: none; font-weight: 400; margin-left: .35em; opacity: 0; }
h2:hover .anchor-link, h3:hover .anchor-link, .anchor-link:focus-visible { opacity: 1; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 0; }
.note-list { padding-left: 1.2em; }
.js-only { display: none; }
