/* The site's one stylesheet. No script: every page reads as it is served. */

:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --subtle: #f3f2ee;
  --text: #1b1b1f;
  --muted: #5b5b66;
  --border: #e3e1db;
  --border-strong: #cfccc3;
  --accent: #0f766e;
  --accent-soft: #e9f6f3;
  --control: #1d4ed8;
  --control-soft: #eaf0fe;
  --egress: #a8530a;
  --egress-soft: #fdf3e3;
  --cap: #0f766e;
  --cap-soft: #e9f6f3;
  --bad: #b42318;
  --bad-soft: #fdeceb;
  --code-bg: #f3f2ee;
  --code-text: #26262c;
  --guest-fill: #f6f5f1;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131316;
    --surface: #1b1b20;
    --subtle: #202026;
    --text: #ececf0;
    --muted: #a3a3b0;
    --border: #2e2e36;
    --border-strong: #44444f;
    --accent: #4fd1c1;
    --accent-soft: #12302d;
    --control: #8ab0ff;
    --control-soft: #172340;
    --egress: #f0b266;
    --egress-soft: #33240f;
    --cap: #4fd1c1;
    --cap-soft: #12302d;
    --bad: #ff8a80;
    --bad-soft: #3a1a18;
    --code-bg: #202026;
    --code-text: #e3e3ea;
    --guest-fill: #18181d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 var(--sans);
}

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

code, pre, kbd { font-family: var(--mono); }
code { font-size: 0.88em; background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 24px; }
.narrow { max-width: 720px; }

/* --- top bar --- */

.top { border-bottom: 1px solid var(--border); background: var(--bg); }
.top .wrap { display: flex; align-items: center; gap: 28px; min-height: 56px; flex-wrap: wrap; }
.brand { font-family: var(--mono); font-weight: 600; font-size: 15px; color: var(--text); text-decoration: none; }
.top nav { display: flex; gap: 22px; flex-wrap: wrap; flex: 1; }
.top nav a, .top .out { color: var(--muted); text-decoration: none; font-size: 15px; }
.top nav a:hover, .top .out:hover { color: var(--text); }
.top nav a[aria-current="page"] { color: var(--text); font-weight: 600; }

/* --- hero --- */

.hero { padding-top: 76px; padding-bottom: 56px; }
.eyebrow { font-family: var(--mono); font-size: 13px; letter-spacing: 0.04em; color: var(--accent); margin: 0 0 18px; }
h1 { font-size: clamp(34px, 5.2vw, 54px); line-height: 1.08; letter-spacing: -0.02em; margin: 0 0 22px; max-width: 17em; font-weight: 700; text-wrap: balance; }
.lede { font-size: 20px; line-height: 1.55; color: var(--muted); max-width: 37em; margin: 0; }
.lede strong { color: var(--text); font-weight: 600; }

/* --- sections --- */

section { padding: 52px 0; border-top: 1px solid var(--border); }
h2 { font-size: 28px; line-height: 1.2; letter-spacing: -0.01em; margin: 0 0 14px; text-wrap: balance; }
h3 { font-size: 18px; margin: 0 0 6px; }
p { margin: 0 0 16px; }
.sub { color: var(--muted); max-width: 42em; margin-bottom: 28px; }
.kicker { font-family: var(--mono); font-size: 13px; color: var(--muted); margin: 0 0 10px; }

/* --- the problem: two columns --- */

.versus { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 28px; }
.versus > div { border: 1px solid var(--border); border-radius: 10px; padding: 20px 22px; background: var(--surface); }
.versus h3 { font-size: 16px; }
.versus p { color: var(--muted); font-size: 16px; margin: 0; }
.versus .tag { font-family: var(--mono); font-size: 12px; display: inline-block; padding: 2px 8px; border-radius: 99px; margin-bottom: 10px; }
.tag.bad { color: var(--bad); background: var(--bad-soft); }
.tag.good { color: var(--cap); background: var(--cap-soft); }

/* --- diagram --- */

.figure { margin: 30px 0 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: 22px 18px 14px; overflow-x: auto; }
.figure svg { display: block; width: 100%; min-width: 760px; height: auto; font-family: var(--sans); }
.figure figcaption { color: var(--muted); font-size: 14.5px; margin: 12px 6px 4px; max-width: 60em; }

.d-box { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1.2; }
.d-guest { fill: var(--guest-fill); stroke: var(--text); stroke-width: 1.6; }
.d-control { fill: var(--control-soft); stroke: var(--control); stroke-width: 1.2; }
.d-egress { fill: var(--egress-soft); stroke: var(--egress); stroke-width: 1.2; }
.d-cap { fill: var(--cap-soft); stroke: var(--cap); stroke-width: 1.2; }
.d-host { fill: none; stroke: var(--border-strong); stroke-width: 1.2; stroke-dasharray: 5 4; }
.d-t { fill: var(--text); font-size: 14px; font-weight: 600; }
.d-s { fill: var(--muted); font-size: 12px; }
.d-m { fill: var(--muted); font-size: 11.5px; font-family: var(--mono); }
.d-label { fill: var(--muted); font-size: 11px; font-family: var(--mono); letter-spacing: 0.06em; }
.d-no { fill: var(--bad); font-size: 12px; font-weight: 600; }
.l-control { stroke: var(--control); } .f-control { fill: var(--control); }
.l-egress { stroke: var(--egress); } .f-egress { fill: var(--egress); }
.l-cap { stroke: var(--cap); } .f-cap { fill: var(--cap); }
.d-line { fill: none; stroke-width: 1.8; }
.d-num { fill: var(--surface); font-size: 12px; font-weight: 700; }

/* --- the three ways out --- */

.ways { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 26px; }
.way { border-top: 3px solid var(--border-strong); padding-top: 14px; }
.way.control { border-color: var(--control); }
.way.egress { border-color: var(--egress); }
.way.cap { border-color: var(--cap); }
.way .n { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.way p { font-size: 16px; color: var(--muted); margin: 0 0 10px; }
.way p strong { color: var(--text); font-weight: 600; }

/* --- walkthrough --- */

.steps { list-style: none; margin: 30px 0 0; padding: 0; counter-reset: step; }
.steps > li { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); gap: 28px; padding: 22px 0; border-top: 1px solid var(--border); counter-increment: step; }
.steps > li:first-child { border-top: 0; padding-top: 0; }
.steps h3::before { content: counter(step) ". "; color: var(--muted); font-weight: 500; }
.steps p { color: var(--muted); font-size: 16px; margin: 0 0 8px; }
.where { font-family: var(--mono); font-size: 12px; display: inline-block; padding: 2px 8px; border-radius: 99px; margin-top: 4px; }
.where.control { color: var(--control); background: var(--control-soft); }
.where.egress { color: var(--egress); background: var(--egress-soft); }
.where.cap { color: var(--cap); background: var(--cap-soft); }

pre { margin: 0; background: var(--code-bg); color: var(--code-text); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; font-size: 13px; line-height: 1.6; overflow-x: auto; }
pre .c { color: var(--muted); }
pre .o { color: var(--accent); }
pre + pre { margin-top: 10px; }
.cap-note { font-size: 14px; color: var(--muted); margin: 8px 0 0; }

/* --- tables --- */

.table { width: 100%; border-collapse: collapse; margin-top: 24px; font-size: 16px; }
.table th { text-align: left; font-size: 13px; font-family: var(--mono); font-weight: 500; color: var(--muted); padding: 0 16px 10px 0; border-bottom: 1px solid var(--border-strong); }
.table td { vertical-align: top; padding: 14px 16px 14px 0; border-bottom: 1px solid var(--border); }
.table td:first-child { width: 42%; }
.table td:last-child { color: var(--muted); padding-right: 0; }
.table td strong { color: var(--text); font-weight: 600; }
.table code { white-space: nowrap; }

/* --- feature grid --- */

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 26px 28px; margin-top: 28px; }
.grid p { color: var(--muted); font-size: 16px; margin: 0; }

/* --- limits list --- */

.plain { margin: 22px 0 0; padding: 0; list-style: none; max-width: 46em; }
.plain li { padding: 12px 0 12px 22px; border-top: 1px solid var(--border); position: relative; color: var(--muted); }
.plain li::before { content: "–"; position: absolute; left: 0; color: var(--border-strong); }
.plain li strong { color: var(--text); font-weight: 600; }

.status { margin-top: 26px; border: 1px solid var(--border); border-left: 3px solid var(--egress); border-radius: 8px; background: var(--surface); padding: 16px 20px; max-width: 46em; }
.status p { margin: 0; font-size: 16px; color: var(--muted); }
.status strong { color: var(--text); }

/* --- next --- */

.next { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 24px; }
.next a { display: block; border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; background: var(--surface); text-decoration: none; color: var(--text); }
.next a:hover { border-color: var(--accent); }
.next a strong { display: block; margin-bottom: 4px; }
.next a span { color: var(--muted); font-size: 15px; }

footer { border-top: 1px solid var(--border); padding: 28px 0 48px; color: var(--muted); font-size: 14.5px; }
footer a { color: var(--muted); }

/* --- inner pages --- */

.page-head { padding-top: 56px; padding-bottom: 40px; }
.page-head h1 { font-size: clamp(30px, 4.2vw, 42px); max-width: 20em; margin-bottom: 16px; }
.page-head .lede { font-size: 19px; }

.toc { margin: 26px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 8px 10px; }
.toc a { display: inline-block; font-size: 14.5px; color: var(--muted); text-decoration: none; border: 1px solid var(--border); border-radius: 99px; padding: 4px 12px; background: var(--surface); }
.toc a:hover { color: var(--text); border-color: var(--border-strong); }

section h2[id] { scroll-margin-top: 20px; }
section h3 { margin-top: 30px; }
section h3:first-child, .grid h3, .way h3, .versus h3, .steps h3, .cols h3 { margin-top: 0; }
.prose { max-width: 46em; }
.prose p, .prose li { color: var(--text); }
.prose ul { padding-left: 20px; margin: 0 0 16px; }
.prose li { margin-bottom: 6px; }
.prose pre { margin: 0 0 18px; }

.table.keys td:first-child { width: 26%; }
.table.keys td:first-child code { white-space: nowrap; }
.table.three td:first-child { width: 22%; }
.table.three td:nth-child(2) { width: 30%; color: var(--text); }
.table td.c-control { border-left: 3px solid var(--control); padding-left: 12px; }
.table td.c-egress { border-left: 3px solid var(--egress); padding-left: 12px; }
.table td.c-cap { border-left: 3px solid var(--cap); padding-left: 12px; }
.table-scroll { overflow-x: auto; }

.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; margin-top: 22px; align-items: start; }
.cols p { color: var(--muted); font-size: 16px; }
.cols p strong { color: var(--text); }
.cols pre + h3, .cols p + h3 { margin-top: 24px; }
.cols.r { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }

.note { margin: 22px 0 0; border: 1px solid var(--border); border-left: 3px solid var(--egress); border-radius: 8px; background: var(--surface); padding: 14px 18px; max-width: 46em; font-size: 16px; color: var(--muted); }
.note strong { color: var(--text); }
.note.ok { border-left-color: var(--cap); }
.note.bad { border-left-color: var(--bad); }

/* --- the overview's three mechanisms --- */

.way .lbl, .box .k, .controls-k { font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em; color: var(--muted); }
.way .lbl { display: block; margin-top: 10px; }
.way .go { font-size: 15px; }

.mech h2 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.num { display: inline-flex; width: 32px; height: 32px; border-radius: 50%; color: var(--bg); align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex: none; }
.num.control { background: var(--control); }
.num.egress { background: var(--egress); }
.num.cap { background: var(--cap); }
.dir { font-family: var(--mono); font-size: 13px; color: var(--muted); font-weight: 400; letter-spacing: 0; }

.mech-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 40px; margin-top: 22px; align-items: start; }
.mech-grid > div > p { color: var(--muted); }
.box { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 14px 18px; margin-top: 16px; font-size: 16px; color: var(--muted); }
.box .k { display: block; margin-bottom: 6px; color: var(--text); }
.box.open { border-left: 3px solid var(--egress); }
.box.open .k { color: var(--egress); }
.box strong { color: var(--text); font-weight: 600; }

.controls-k { display: block; margin-bottom: 12px; }
.controls { list-style: none; margin: 0; padding: 0; }
.controls li { display: grid; grid-template-columns: 11em minmax(0, 1fr); gap: 18px; padding: 11px 0; border-top: 1px solid var(--border); font-size: 16px; }
.controls li:first-child { border-top: 1px solid var(--border-strong); }
.controls strong { font-weight: 600; }
.controls span { color: var(--muted); }

details.more { margin-top: 24px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
details.more summary { cursor: pointer; padding: 12px 18px; font-weight: 600; font-size: 15.5px; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "+"; font-family: var(--mono); display: inline-block; width: 1.2em; color: var(--accent); }
details.more[open] summary::before { content: "\2212"; }
details.more summary:hover { color: var(--accent); }
details.more .inner { padding: 2px 18px 18px; }
details.more .inner > p { color: var(--muted); font-size: 16px; max-width: 46em; }
details.more .steps { margin-top: 10px; }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.pair pre + pre { margin-top: 0; }

@media (max-width: 860px) {
  .versus, .ways, .grid, .next { grid-template-columns: 1fr; }
  .cols, .cols.r { grid-template-columns: minmax(0, 1fr); }
  .mech-grid, .pair { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .pair { gap: 10px; }
  .controls li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .table.keys td:first-child, .table.three td:first-child, .table.three td:nth-child(2) { width: auto; }
  .table.keys td:first-child code { white-space: normal; }
  .steps > li { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .hero { padding-top: 48px; padding-bottom: 40px; }
  .table td:first-child { width: auto; }
  .table code { white-space: normal; }
}
