/* VeeMax site stylesheet. Plain CSS, no build step.

   Palette: "Colour code". Resistor bands number the pins:
   1 brown, 2 red, 3 orange, 4 yellow, 5 green, 6 blue, 7 violet, 8 grey.
   Light values sit on :root. Dark values apply when the OS prefers dark
   (unless the visitor picked light with the toggle) or when the toggle
   sets html[data-mode="dark"]. The two dark blocks must stay identical. */

/* ---------- fonts (self-hosted, latin subsets) ---------- */
@font-face {
  font-family: "Archivo";
  src: url("../fonts/archivo-latin-standard-normal.woff2") format("woff2-variations"),
       url("../fonts/archivo-latin-standard-normal.woff2") format("woff2");
  font-weight: 100 900; font-stretch: 62% 125%; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Archivo";
  src: url("../fonts/archivo-latin-ext-standard-normal.woff2") format("woff2-variations"),
       url("../fonts/archivo-latin-ext-standard-normal.woff2") format("woff2");
  font-weight: 100 900; font-stretch: 62% 125%; font-style: normal; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Archivo";
  src: url("../fonts/archivo-latin-standard-italic.woff2") format("woff2-variations"),
       url("../fonts/archivo-latin-standard-italic.woff2") format("woff2");
  font-weight: 100 900; font-stretch: 62% 125%; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-latin-400-italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
  font-weight: 500 700; font-style: normal; font-display: swap;
}

/* ---------- palette: light (default) ---------- */
:root {
  --paper: #e4e2dd;
  --sheet: #f9f8f6;
  --ink: #1c1a18;
  --ink-2: #47423d;
  --ink-3: #625c56;
  --rule: #d3cfc8;
  --rule-strong: #1c1a18;
  --accent: #b02a1e;
  --accent-ink: #ffffff;
  --accent-soft: #f6e8e4;
  --cta: #b02a1e;
  --cta-ink: #ffffff;
  --cta-hover: #92211a;
  --band: #1c1a18;
  --band-ink: #f9f8f6;
  --chip: #1c1a18;
  --chip-ink: #f9f8f6;
  --pin-1: #6e4220; --pin-2: #c0281c; --pin-3: #e0701c; --pin-4: #e8b400;
  --pin-5: #2f8a3e; --pin-6: #2160c4; --pin-7: #7b3fb5; --pin-8: #8b8780;
  --sec-1: #6e4220; --sec-1-ink: #ffffff;
  --sec-2: #c0281c; --sec-2-ink: #ffffff;
  --sec-3: #e0701c; --sec-3-ink: #1c1a18;
  --sec-4: #e8b400; --sec-4-ink: #1c1a18;
  --sec-5: #267a34; --sec-5-ink: #ffffff;
  --band-stripe: linear-gradient(90deg, var(--pin-1) 0 12.5%, var(--pin-2) 0 25%, var(--pin-3) 0 37.5%, var(--pin-4) 0 50%, var(--pin-5) 0 62.5%, var(--pin-6) 0 75%, var(--pin-7) 0 87.5%, var(--pin-8) 0);
  --pin: #8b8780;
  --pin-edge: #1c1a18;
  --body: #d9c396;
  --body-ink: #1c1a18;
  --body-ink-2: #5b4d33;
  --fig-bg: #f1efeb;
  --grid: rgba(28, 26, 24, 0.06);
  --trace-bg: #1c1a18;
  --trace-grid: rgba(249, 248, 246, 0.09);
  --trace-grid-strong: rgba(249, 248, 246, 0.26);
  --trace-clk: #a9a39b;
  --trace-data: #f0b90b;
  --trace-ink: #f9f8f6;
  --trace-dim: #b5aea5;
  --code-bg: #efede9;
  --mark: #fbe9b0;
  --ok: #267a34;
  --ring: #b8912c;
  --photo: #b02a1e;
  /* syntax highlighting */
  --hl-kw: #a8281c;
  --hl-str: #22702f;
  --hl-com: #6a645d;
  --hl-num: #8f4a0c;
  --hl-fn: #1d58b5;
  --hl-type: #7036a8;
  --hl-attr: #6e4220;
  --hl-err: #a8281c;
  --logo-red: #b02a1e;
  --logo-ink: #1c1a18;
  color-scheme: light;
}

/* ---------- palette: dark (OS preference) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-mode="light"]) {
    --paper: #100f0e;
    --sheet: #1a1917;
    --ink: #f0ece6;
    --ink-2: #c4bdb4;
    --ink-3: #a0988e;
    --rule: #34312d;
    --rule-strong: #e2ddd5;
    --accent: #ff7d6e;
    --accent-ink: #1a1917;
    --accent-soft: #2e1f1c;
    --cta: #ff7d6e;
    --cta-ink: #1a1917;
    --cta-hover: #ff998d;
    --band: #2b2825;
    --band-ink: #f0ece6;
    --chip: #f0ece6;
    --chip-ink: #1a1917;
    --pin-1: #b07a46; --pin-2: #f0544a; --pin-3: #f58a35; --pin-4: #f5c518;
    --pin-5: #4cbb5e; --pin-6: #5c93f0; --pin-7: #b183ea; --pin-8: #a8a39b;
    --sec-1: #b07a46; --sec-1-ink: #1a1917;
    --sec-2: #f0544a; --sec-2-ink: #1a1917;
    --sec-3: #f58a35; --sec-3-ink: #1a1917;
    --sec-4: #f5c518; --sec-4-ink: #1a1917;
    --sec-5: #4cbb5e; --sec-5-ink: #1a1917;
    --pin: #a8a39b;
    --pin-edge: #f0ece6;
    --body: #c9b48a;
    --body-ink: #1c1a18;
    --body-ink-2: #4a3e28;
    --fig-bg: #211f1c;
    --grid: rgba(240, 236, 230, 0.05);
    --trace-bg: #0b0a09;
    --trace-grid: rgba(240, 236, 230, 0.08);
    --trace-grid-strong: rgba(240, 236, 230, 0.22);
    --trace-clk: #8a847c;
    --trace-data: #f5c518;
    --trace-ink: #f0ece6;
    --trace-dim: #a0988e;
    --code-bg: #23211e;
    --mark: #3a2a14;
    --ok: #4cbb5e;
    --ring: #c9a23e;
    --photo: #ff7d6e;
    --hl-kw: #ff8a7c;
    --hl-str: #7fd38b;
    --hl-com: #a39b91;
    --hl-num: #f7a95f;
    --hl-fn: #86b4ff;
    --hl-type: #c9a3f2;
    --hl-attr: #d6a776;
    --hl-err: #ff8a7c;
    --logo-red: #f0544a;
    --logo-ink: #f0ece6;
    color-scheme: dark;
  }
}

/* ---------- palette: dark (toggle) ---------- */
:root[data-mode="dark"] {
  --paper: #100f0e;
  --sheet: #1a1917;
  --ink: #f0ece6;
  --ink-2: #c4bdb4;
  --ink-3: #a0988e;
  --rule: #34312d;
  --rule-strong: #e2ddd5;
  --accent: #ff7d6e;
  --accent-ink: #1a1917;
  --accent-soft: #2e1f1c;
  --cta: #ff7d6e;
  --cta-ink: #1a1917;
  --cta-hover: #ff998d;
  --band: #2b2825;
  --band-ink: #f0ece6;
  --chip: #f0ece6;
  --chip-ink: #1a1917;
  --pin-1: #b07a46; --pin-2: #f0544a; --pin-3: #f58a35; --pin-4: #f5c518;
  --pin-5: #4cbb5e; --pin-6: #5c93f0; --pin-7: #b183ea; --pin-8: #a8a39b;
  --sec-1: #b07a46; --sec-1-ink: #1a1917;
  --sec-2: #f0544a; --sec-2-ink: #1a1917;
  --sec-3: #f58a35; --sec-3-ink: #1a1917;
  --sec-4: #f5c518; --sec-4-ink: #1a1917;
  --sec-5: #4cbb5e; --sec-5-ink: #1a1917;
  --pin: #a8a39b;
  --pin-edge: #f0ece6;
  --body: #c9b48a;
  --body-ink: #1c1a18;
  --body-ink-2: #4a3e28;
  --fig-bg: #211f1c;
  --grid: rgba(240, 236, 230, 0.05);
  --trace-bg: #0b0a09;
  --trace-grid: rgba(240, 236, 230, 0.08);
  --trace-grid-strong: rgba(240, 236, 230, 0.22);
  --trace-clk: #8a847c;
  --trace-data: #f5c518;
  --trace-ink: #f0ece6;
  --trace-dim: #a0988e;
  --code-bg: #23211e;
  --mark: #3a2a14;
  --ok: #4cbb5e;
  --ring: #c9a23e;
  --photo: #ff7d6e;
  --hl-kw: #ff8a7c;
  --hl-str: #7fd38b;
  --hl-com: #a39b91;
  --hl-num: #f7a95f;
  --hl-fn: #86b4ff;
  --hl-type: #c9a3f2;
  --hl-attr: #d6a776;
  --hl-err: #ff8a7c;
  --logo-red: #f0544a;
  --logo-ink: #f0ece6;
  color-scheme: dark;
}

/* ---------- type ---------- */
:root {
  --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --measure: 68ch;
  --gutter: clamp(16px, 4vw, 48px);
  --maxw: 1240px;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 24px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  font-variation-settings: "wdth" 100;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 1px;
}
::selection { background: var(--accent); color: var(--accent-ink); }

.mono { font-family: var(--mono); font-size: 0.8125rem; letter-spacing: 0; }

.skip {
  position: absolute; left: -999px; top: 8px;
  background: var(--cta); color: var(--cta-ink); padding: 8px 12px;
}
.skip:focus { left: 8px; z-index: 10; }

.sheet {
  max-width: var(--maxw);
  margin: 0 auto;
  background: var(--sheet);
  border-left: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
  min-height: 100vh;
  overflow-x: clip;
}
.wrap { padding-left: var(--gutter); padding-right: var(--gutter); }

/* ---------- running header ---------- */
.runhead {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding-top: 18px; padding-bottom: 14px;
  border-bottom: 2px solid var(--rule-strong);
}
.brand { display: flex; align-items: center; gap: 14px; color: var(--ink); text-decoration: none; }
/* VeeMax logo, inline SVG (_includes/veemax-logo.svg); colours follow the theme */
.brand-logo { display: block; height: 28px; width: auto; aspect-ratio: 1104.79 / 190; flex: none; }
.brand-logo .logo-red { fill: var(--logo-red); }
.brand-logo .logo-ink { fill: var(--logo-ink); }
.brand-sub { color: var(--ink-3); }
.nav { justify-self: end; display: flex; gap: 4px; align-items: center; }
.nav a { color: var(--ink); text-decoration: none; font-size: 0.9375rem; font-weight: 500; padding: 6px 10px; }
.nav a:hover { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.nav a[aria-current] { box-shadow: inset 0 -2px 0 var(--accent); }
.theme-toggle {
  font-size: 0.75rem; color: var(--ink-2);
  background: transparent; border: 1px solid var(--rule);
  padding: 5px 9px; margin-left: 8px; cursor: pointer;
}
.theme-toggle::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; border: 1.5px solid currentColor; background: linear-gradient(90deg, currentColor 50%, transparent 50%); vertical-align: -0.5px; }
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

.docline {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 24px;
  padding-top: 8px; padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-3);
}
.docline span b { font-weight: 500; color: var(--ink-2); }

/* ---------- section scaffolding ---------- */
.section {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 0 48px;
  padding-top: 56px; padding-bottom: 56px;
  border-bottom: 1px solid var(--rule);
}
.section-head h2 {
  margin: 0;
  display: flex; align-items: center; gap: 12px;
  font-size: 1.375rem; font-weight: 700; line-height: 1.2;
  font-variation-settings: "wdth" 90; letter-spacing: -0.005em;
}
.section-head .num {
  --c: var(--chip); --ci: var(--chip-ink);
  flex: none;
  display: inline-grid; place-items: center;
  width: 30px; height: 30px;
  font-family: var(--mono); font-size: 0.875rem; font-weight: 500;
  background: var(--c); color: var(--ci);
}
.sec-1 .num { --c: var(--sec-1, var(--chip)); --ci: var(--sec-1-ink, var(--chip-ink)); }
.sec-2 .num { --c: var(--sec-2, var(--chip)); --ci: var(--sec-2-ink, var(--chip-ink)); }
.sec-3 .num { --c: var(--sec-3, var(--chip)); --ci: var(--sec-3-ink, var(--chip-ink)); }
.sec-4 .num { --c: var(--sec-4, var(--chip)); --ci: var(--sec-4-ink, var(--chip-ink)); }
.sec-5 .num { --c: var(--sec-5, var(--chip)); --ci: var(--sec-5-ink, var(--chip-ink)); }
.section-head p { margin: 12px 0 0; color: var(--ink-3); font-size: 0.9375rem; line-height: 1.45; max-width: 24ch; }

/* ---------- hero / front page ---------- */
.front {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
}
.front-text { padding: 64px 48px 56px 0; border-right: 1px solid var(--rule); }
.title {
  margin: 0 0 28px;
  font-size: clamp(2.5rem, 5.4vw, 4.5rem);
  line-height: 0.98; font-weight: 800; letter-spacing: -0.03em;
  font-variation-settings: "wdth" 78;
  max-width: 13ch;
  text-wrap: balance;
}
.title.is-long { font-size: clamp(2.25rem, 4.5vw, 3.75rem); max-width: 16ch; }
.lede { font-size: 1.1875rem; line-height: 1.5; color: var(--ink-2); max-width: 46ch; margin: 0 0 24px; }
.lede strong { color: var(--ink); font-weight: 600; }

.status-panel {
  display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start;
  max-width: 46ch;
  padding: 14px 16px;
  background: var(--accent-soft);
  border-left: 3px solid var(--ok);
}
.status-panel p { margin: 0; font-size: 1rem; line-height: 1.45; color: var(--ink); }
.status-panel a { color: var(--ink); font-weight: 600; text-decoration-color: var(--accent); }
.status-led {
  width: 10px; height: 10px; margin-top: 0.42em; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent);
}

.cta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin-top: 32px; }
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 13px 22px;
  font-weight: 650; font-size: 1rem;
  text-decoration: none;
  border: 0;
}
.btn-primary { background: var(--cta); color: var(--cta-ink); box-shadow: 4px 4px 0 var(--rule-strong); transition: transform .12s, box-shadow .12s; }
.btn-primary:hover { background: var(--cta-hover); transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--rule-strong); }
.btn-primary:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--rule-strong); }
.text-link { font-weight: 600; font-size: 0.9375rem; color: var(--ink); text-decoration-color: var(--accent); }
.text-link:hover { color: var(--accent); }

/* the pinout figure */
.front-fig {
  margin: 0;
  padding: 40px 0 28px 40px;
  display: flex; flex-direction: column; justify-content: center;
  background-color: var(--fig-bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 16px 16px;
  background-position: -1px -1px;
  margin-right: calc(var(--gutter) * -1);
  padding-right: var(--gutter);
}
.pinout { width: 100%; max-width: 520px; height: auto; margin: auto; color: var(--ink); }
.pinout .body { fill: var(--body); stroke: var(--rule-strong); stroke-width: 1.5; }
.pinout .pin { fill: var(--pin); stroke: var(--pin-edge); stroke-width: 1; }
.pinout .p1 { fill: var(--pin-1, var(--pin)); } .pinout .p2 { fill: var(--pin-2, var(--pin)); }
.pinout .p3 { fill: var(--pin-3, var(--pin)); } .pinout .p4 { fill: var(--pin-4, var(--pin)); }
.pinout .p5 { fill: var(--pin-5, var(--pin)); } .pinout .p6 { fill: var(--pin-6, var(--pin)); }
.pinout .p7 { fill: var(--pin-7, var(--pin)); } .pinout .p8 { fill: var(--pin-8, var(--pin)); }
.pinout .lbl { font-family: var(--mono); font-size: 13px; font-weight: 500; fill: var(--accent); }
.pinout .lbl-num { font-family: var(--mono); font-size: 11px; fill: var(--body-ink-2); }
.pinout .chipname { font-family: var(--sans); font-weight: 800; font-size: 26px; fill: var(--body-ink); letter-spacing: -0.5px; }
.pinout .chipsub { font-family: var(--mono); font-size: 11px; fill: var(--body-ink-2); }
.pinout .dim { stroke: var(--ink-3); stroke-width: 0.75; fill: none; }
.pinout .dim-arrow { fill: var(--ink-3); }
.pinout .dimtxt { font-family: var(--mono); font-size: 10px; fill: var(--ink-3); }
.pinout .dot { fill: var(--body-ink-2); }
.pinout a:hover .lbl { text-decoration: underline; }
.pinout a:focus-visible { outline: none; }
.pinout a:focus-visible .pin { stroke: var(--accent); stroke-width: 3; }
.figcap { margin: 20px 0 0; padding-right: 24px; color: var(--ink-3); }
.figcap b { color: var(--ink); font-weight: 500; }

/* ---------- Figure 2: timing diagram band ---------- */
.timing {
  margin: 0;
  background: var(--trace-bg);
  color: var(--trace-ink);
  border-bottom: 1px solid var(--rule);
}
.timing-inner { padding-top: 36px; padding-bottom: 28px; }
.timing-plot { width: 100%; }
.tsvg { width: 100%; height: auto; overflow: visible; }
.tsvg .gt { stroke: var(--trace-grid); stroke-width: 1; }
.tsvg .gb { stroke: var(--trace-grid-strong); stroke-width: 1; stroke-dasharray: 2 3; }
.tsvg .ch { font-family: var(--mono); font-size: 12px; font-weight: 500; fill: var(--trace-dim); }
.tsvg .clk { fill: none; stroke: var(--trace-clk); stroke-width: 1.25; stroke-linejoin: miter; }
.tsvg .data { fill: none; stroke: var(--trace-data); stroke-width: 2.25; stroke-linejoin: miter; }
.tsvg .bit { font-family: var(--mono); font-size: 8.5px; fill: var(--trace-dim); opacity: .8; }
.tsvg .byte { font-family: var(--sans); font-size: 19px; font-weight: 800; fill: var(--trace-data); }
.tsvg .hex { font-family: var(--mono); font-size: 11px; fill: var(--trace-dim); }
.t-mid, .t-narrow { display: none; }
.timing .figcap { color: var(--trace-dim); margin-top: 16px; }
.timing .figcap b { color: var(--trace-ink); }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
/* the palette's colour stripe sits on the caption, directly above the header band */
.table caption {
  caption-side: top; text-align: left; padding: 0 0 10px; color: var(--ink-3);
  border-bottom: 4px solid transparent; border-image: var(--band-stripe) 1;
}
.table caption b { color: var(--ink); font-weight: 500; }
.table thead th {
  text-align: left;
  font-family: var(--mono); font-size: 0.75rem; font-weight: 500;
  color: var(--band-ink);
  background: var(--band);
  padding: 9px 12px;
  white-space: nowrap;
}
.table td { padding: 14px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 2px solid var(--rule-strong); }
.table tbody tr:hover td, .table tbody tr:target td { background: var(--mark); }
.table td.num, .table th.num { font-family: var(--mono); font-size: 0.8125rem; color: var(--ink-2); width: 1%; white-space: nowrap; }
.table th.num { color: var(--band-ink); }
.sw { display: inline-block; width: 10px; height: 10px; margin-right: 8px; vertical-align: -1px; background: var(--pin); outline: 1px solid var(--pin-edge); outline-offset: -1px; }
.sw.p1 { background: var(--pin-1, var(--pin)); } .sw.p2 { background: var(--pin-2, var(--pin)); }
.sw.p3 { background: var(--pin-3, var(--pin)); } .sw.p4 { background: var(--pin-4, var(--pin)); }
.sw.p5 { background: var(--pin-5, var(--pin)); } .sw.p6 { background: var(--pin-6, var(--pin)); }
.sw.p7 { background: var(--pin-7, var(--pin)); } .sw.p8 { background: var(--pin-8, var(--pin)); }
.table td.name { font-family: var(--mono); font-weight: 500; font-size: 0.875rem; white-space: nowrap; width: 1%; color: var(--accent); }
.table td.type { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-2); white-space: nowrap; width: 1%; }
.table td.desc strong { font-weight: 600; display: block; margin-bottom: 2px; }
.table td.desc span { color: var(--ink-2); }

.tag {
  display: inline-block;
  font-family: var(--mono); font-size: 0.6875rem;
  padding: 1px 6px;
  border: 1px solid var(--rule);
  background: var(--sheet);
  color: var(--ink-2);
  margin: 0 4px 4px 0;
  white-space: nowrap;
}
.status { font-family: var(--mono); font-size: 0.75rem; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; }
.status::before { content: ""; width: 8px; height: 8px; border: 1.5px solid currentColor; border-radius: 50%; }
.status.live { color: var(--ok); font-weight: 500; }
.status.live::before { background: currentColor; }
.status.proto { color: var(--accent); }
.status.proto::before { background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
.status.wip { color: var(--ink-2); }

.proj-name { font-weight: 700; font-size: 1.0625rem; letter-spacing: -0.01em; color: var(--ink); }
.proj-link { display: block; margin-top: 4px; font-family: var(--mono); font-size: 0.75rem; }

/* ---------- writing index ---------- */
.notes { list-style: none; margin: 0; padding: 0; border-top: 4px solid transparent; border-image: var(--band-stripe) 1; }
.notes li { border-bottom: 1px solid var(--rule); }
.notes a {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) auto;
  gap: 24px; align-items: baseline;
  padding: 14px 8px;
  text-decoration: none; color: var(--ink);
}
.notes a:hover { background: var(--mark); }
.notes a:hover .note-title { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; }
.notes time { color: var(--ink-3); }
.note-title { font-size: 1.0625rem; font-weight: 500; line-height: 1.35; }
.note-topic { color: var(--ink-3); text-align: right; }
.more { margin: 18px 0 0; }
.more a { font-weight: 600; }

/* ---------- about ---------- */
.about-body { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 36px; align-items: start; }
.portrait { margin: 0; }
/* Round portrait in its own colours, inside a plain hairline ring. */
.pad {
  width: 168px; height: 168px; border-radius: 50%;
  padding: 5px;
  background: var(--paper, transparent);
  box-shadow: 0 0 0 2px var(--rule-strong);
}
.duo { border-radius: 50%; overflow: hidden; height: 100%; }
.duo img {
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scale(1.07);
}
.portrait figcaption { margin-top: 10px; color: var(--ink-3); text-align: center; }
.prose-short p { margin: 0 0 1em; max-width: var(--measure); }
.prose-short p:first-child { font-size: 1.1875rem; line-height: 1.5; }

/* ---------- contact ---------- */
.kv { margin: 0; display: grid; grid-template-columns: 140px minmax(0, 1fr); border-top: 2px solid var(--rule-strong); }
.kv dt, .kv dd { margin: 0; padding: 14px 4px; border-bottom: 1px solid var(--rule); }
.kv dt { color: var(--ink-3); font-family: var(--mono); font-size: 0.8125rem; padding-top: 17px; }
.kv dd { font-size: 1.0625rem; }
.kv dd a { font-weight: 500; }
.kv .kv-primary { font-weight: 700; font-size: 1.25rem; }
.contact-lede { font-size: 1.1875rem; margin: 0 0 24px; max-width: 52ch; }

/* ---------- running footer ---------- */
.runfoot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px;
  padding-top: 18px; padding-bottom: 28px;
  border-top: 2px solid var(--rule-strong);
  color: var(--ink-3);
}

/* ---------- article (post.html) ---------- */
.doc-head {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 0 48px;
  padding-top: 56px; padding-bottom: 40px;
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(var(--accent-soft), var(--accent-soft)) 0 0 / 100% 6px no-repeat;
}
.doc-kind { padding-top: 14px; }
.doc-kind span { display: inline-block; padding: 3px 8px; background: var(--chip); color: var(--chip-ink); }
.doc-title {
  margin: 0;
  font-size: clamp(2.25rem, 4.6vw, 3.75rem);
  line-height: 1.02; font-weight: 800; letter-spacing: -0.025em;
  font-variation-settings: "wdth" 80;
  max-width: 18ch;
  text-wrap: balance;
}
.doc-abstract { margin: 20px 0 0; font-size: 1.1875rem; color: var(--ink-2); max-width: 56ch; line-height: 1.5; }
.doc-meta {
  margin: 28px 0 0; display: grid; grid-template-columns: repeat(4, auto); justify-content: start;
  border-top: 4px solid transparent; border-image: var(--band-stripe) 1;
  border-bottom: 1px solid var(--rule);
}
.doc-meta div { padding: 10px 28px 10px 0; margin-right: 28px; border-right: 1px solid var(--rule); }
.doc-meta div:last-child { border-right: 0; margin-right: 0; }
.doc-meta dt { font-family: var(--mono); font-size: 0.6875rem; color: var(--ink-3); }
.doc-meta dd { margin: 2px 0 0; font-family: var(--mono); font-size: 0.8125rem; color: var(--ink); }

.doc-body {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 0 48px;
  padding-top: 40px; padding-bottom: 72px;
}
.toc { position: sticky; top: 24px; align-self: start; }
.toc h2 { font-family: var(--mono); font-size: 0.75rem; font-weight: 500; color: var(--band-ink); background: var(--band); padding: 6px 10px; margin: 0; }
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc li { counter-increment: toc; border-bottom: 1px solid var(--rule); }
.toc a {
  display: grid; grid-template-columns: 28px 1fr; gap: 4px;
  padding: 8px 0; font-size: 0.875rem; line-height: 1.3; color: var(--ink-2); text-decoration: none;
}
.toc a::before { content: counter(toc); font-family: var(--mono); font-size: 0.75rem; color: var(--accent); padding-top: 1px; }
.toc a:hover { color: var(--accent); background: var(--mark); }

.prose { max-width: var(--measure); counter-reset: h2 fig; }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol { margin: 0 0 1.1em; }
.prose li { margin-bottom: 0.35em; }
.prose h2 {
  counter-increment: h2;
  font-size: 1.5rem; line-height: 1.2; font-weight: 700;
  letter-spacing: -0.01em;
  font-variation-settings: "wdth" 88;
  margin: 2.4em 0 0.7em;
  padding-top: 14px;
  border-top: 1px solid var(--rule-strong);
  display: grid; grid-template-columns: 2.4em 1fr; align-items: start;
}
.prose h2::before {
  content: counter(h2);
  justify-self: start;
  font-family: var(--mono); font-size: 0.875rem; font-weight: 500;
  min-width: 1.9em; text-align: center; padding: 0.15em 0;
  margin-top: 0.15em;
  background: var(--chip); color: var(--chip-ink);
}
.prose code {
  font-family: var(--mono); font-size: 0.84em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border: 1px solid var(--rule);
  overflow-wrap: anywhere;
}
.prose a { overflow-wrap: anywhere; }

.code { margin: 1.4em 0 1.6em; border: 1px solid var(--rule-strong); background: var(--code-bg); }
.code-head {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 6px 12px;
  background: var(--band); color: var(--band-ink);
  font-family: var(--mono); font-size: 0.6875rem;
}
.code pre {
  margin: 0; padding: 14px 16px; overflow-x: auto;
  font-family: var(--mono); font-size: 0.8125rem; line-height: 1.65;
  color: var(--ink); tab-size: 2;
}
.code pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.code .k { color: var(--accent); font-weight: 500; }

.fig { margin: 2em 0; counter-increment: fig; }
.fig-ph {
  aspect-ratio: 16 / 9;
  border: 1px solid var(--rule-strong);
  display: grid; place-items: center;
  color: var(--ink-3);
  background:
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 16px 16px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 16px 16px,
    var(--fig-bg);
  position: relative;
}
.fig-ph::before, .fig-ph::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top right, transparent calc(50% - 0.5px), var(--rule) 50%, transparent calc(50% + 0.5px));
}
.fig-ph::after { transform: scaleX(-1); }
.fig-ph span { position: relative; z-index: 1; background: var(--sheet); padding: 4px 10px; border: 1px solid var(--rule); }
.fig figcaption { margin-top: 10px; font-size: 0.9375rem; color: var(--ink-2); }
.fig figcaption::before { content: "Figure " counter(fig) ". "; font-weight: 600; color: var(--ink); }

.note { margin: 1.6em 0; padding: 12px 16px; border-left: 3px solid var(--accent); background: var(--accent-soft); }
.note p { margin: 0; }
.note b { font-family: var(--mono); font-size: 0.75rem; font-weight: 500; color: var(--accent); display: block; margin-bottom: 2px; }

.doc-end { display: grid; grid-template-columns: 1fr 1fr; border-top: 2px solid var(--rule-strong); margin-top: 48px; }
.doc-end a { padding: 16px 8px; text-decoration: none; color: var(--ink); }
.doc-end a:hover { background: var(--mark); }
.doc-end a + a { text-align: right; border-left: 1px solid var(--rule); padding-left: 16px; }
.doc-end small { display: block; color: var(--ink-3); font-family: var(--mono); font-size: 0.75rem; margin-bottom: 4px; }
.doc-end span { font-weight: 600; }
.doc-end a:hover span { color: var(--accent); }

/* ---------- motion: one orchestrated moment on load ---------- */
@media (prefers-reduced-motion: no-preference) {
  .pinout .pin { animation: pin-in .5s ease-out both; }
  .pinout .p1 { animation-delay: .15s; } .pinout .p2 { animation-delay: .25s; }
  .pinout .p3 { animation-delay: .35s; } .pinout .p4 { animation-delay: .45s; }
  .pinout .p5 { animation-delay: .55s; } .pinout .p6 { animation-delay: .65s; }
  .pinout .p7 { animation-delay: .75s; } .pinout .p8 { animation-delay: .85s; }
  @keyframes pin-in { from { fill-opacity: 0; } }
  /* the trace is "acquired" left to right, like a logic analyser capture */
  .tsvg .clk { animation: sweep 1.6s linear .2s backwards; }
  .tsvg .data { animation: sweep 2.2s cubic-bezier(.5, .1, .3, 1) .45s backwards; }
  .tsvg .byte, .tsvg .hex { animation: settle .5s ease-out 1.9s backwards; }
  @keyframes sweep { from { clip-path: inset(-4px 100% -4px 0); } to { clip-path: inset(-4px 0 -4px 0); } }
  @keyframes settle { from { opacity: 0; } }
}

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .front { grid-template-columns: 1fr; }
  .front-text { border-right: 0; padding-right: 0; border-bottom: 1px solid var(--rule); }
  .front-fig { padding: 32px var(--gutter) 24px; margin-left: calc(var(--gutter) * -1); }
  .section, .doc-head, .doc-body { grid-template-columns: 1fr; }
  .section-head { margin-bottom: 24px; }
  .section-head p { max-width: 60ch; }
  .toc { position: static; margin-bottom: 32px; }
  .doc-kind { padding-top: 0; margin-bottom: 12px; }
  .t-wide { display: none; }
  .t-mid { display: block; max-width: 760px; }
}
@media (max-width: 560px) {
  .t-mid { display: none; }
  .t-narrow { display: block; max-width: 460px; }
  .t-narrow .bit { font-size: 10px; }
  .t-narrow .ch { font-size: 13px; }
  .t-narrow .hex { font-size: 13px; }
  .t-narrow .byte { font-size: 22px; }
}

@media (max-width: 760px) {
  body { font-size: 16px; }
  .runhead { grid-template-columns: 1fr auto; gap: 10px; }
  .brand-sub { display: none; }
  .nav { grid-column: 1 / -1; justify-self: stretch; justify-content: space-between; border-top: 1px solid var(--rule); padding-top: 8px; gap: 0; flex-wrap: wrap; }
  .nav a { padding: 6px 4px; font-size: 0.875rem; }
  .theme-toggle { grid-row: 1; grid-column: 2; margin: 0; }
  .front-text { padding-top: 40px; padding-bottom: 40px; }
  .section { padding-top: 40px; padding-bottom: 40px; }
  .docline span:last-child { display: none; }

  /* tables become stacked records */
  .table caption { display: block; }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table, .table tbody, .table tr, .table td { display: block; width: auto !important; }
  .table tr { border-bottom: 1px solid var(--rule); padding: 12px 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
  .table tbody tr:last-child { border-bottom: 2px solid var(--rule-strong); }
  .table td, .table tbody tr:last-child td { border: 0; padding: 0; }
  .table tbody tr:hover td { background: none; }
  .table td.desc, .table td.wide { grid-column: 1 / -1; }
  .pins td.num { grid-column: 1; }
  .pins td.name { grid-column: 2; }
  .pins td.type { display: none; }
  .projects td { grid-column: 1 / -1; }
  .projects td.status-cell { margin-top: 4px; }

  .notes a { grid-template-columns: 1fr; gap: 2px; }
  .note-topic { text-align: left; }
  .about-body { grid-template-columns: 1fr; gap: 20px; }
  .pad { width: 132px; height: 132px; }
  .portrait figcaption { text-align: left; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { border-bottom: 0; padding-bottom: 0; padding-top: 12px; }
  .doc-meta { grid-template-columns: 1fr 1fr; }
  .doc-meta div { border-right: 0; margin-right: 0; padding-right: 8px; }
  .doc-end { grid-template-columns: 1fr; }
  .doc-end a + a { text-align: left; border-left: 0; border-top: 1px solid var(--rule); padding-left: 8px; }
  .prose h2 { font-size: 1.3125rem; }
}


/* =========================================================
   Site additions beyond the mockup: long-form content, Rouge,
   archives, utility classes.
   ========================================================= */
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.runfoot a { color: inherit; }
.runfoot a:hover { color: var(--accent); }
.docline a { color: var(--ink-2); }

/* projects table: the name links to the write-up when there is one */
a.proj-name { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a.proj-name:hover { color: var(--accent); }

/* post header extras */
.doc-title { overflow-wrap: break-word; }
.doc-abstract a { color: var(--accent); }
.doc-abstract a[aria-current] { color: var(--ink); font-weight: 600; text-decoration-color: var(--accent); }
.doc-meta { display: flex; flex-wrap: wrap; }
.doc-meta div { min-width: 0; }
.doc-meta dd a { color: var(--ink); text-decoration-color: var(--rule-strong); }
.doc-meta dd a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.doc-link { margin: 14px 0 0; color: var(--ink-3); overflow-wrap: anywhere; }
.no-toc > .prose, .no-toc > .archive-groups { grid-column: 2; }

/* long-form content */
.prose { min-width: 0; }
.prose h3 { font-size: 1.1875rem; line-height: 1.3; font-weight: 700; margin: 1.8em 0 0.5em; }
.prose h4 { font-size: 1rem; font-weight: 700; margin: 1.5em 0 0.4em; }
.prose h2 + *, .prose h3 + * { margin-top: 0; }
.prose img {
  height: auto;
  margin: 1.4em 0;
  border: 1px solid var(--rule-strong);
  background: var(--fig-bg);
}
.prose p > a:only-child > img, .prose p > img:only-child { margin: 0; }
.prose p:has(> a:only-child > img), .prose p:has(> img:only-child) { margin: 1.6em 0; }
.prose figure { margin: 2em 0; }
.prose figcaption { margin-top: 10px; font-size: 0.9375rem; color: var(--ink-2); }
.prose blockquote {
  margin: 1.6em 0; padding: 12px 16px;
  border-left: 3px solid var(--accent); background: var(--accent-soft);
}
.prose blockquote > :last-child { margin-bottom: 0; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.4em 0; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li::marker { color: var(--ink-3); }
.prose dt { font-weight: 600; }
.prose dd { margin: 0 0 0.8em 1.2em; }
.prose kbd { font-family: var(--mono); font-size: 0.8em; border: 1px solid var(--rule-strong); border-bottom-width: 2px; padding: 0 0.3em; }
.prose mark { background: var(--mark); color: inherit; }

/* tables in posts: scroll inside their own box on narrow screens */
.prose table {
  display: block; max-width: 100%; overflow-x: auto;
  border-collapse: collapse; margin: 1.6em 0;
  font-size: 0.9375rem;
  border-top: 4px solid transparent; border-image: var(--band-stripe) 1;
}
.prose th {
  text-align: left; font-family: var(--mono); font-size: 0.75rem; font-weight: 500;
  color: var(--band-ink); background: var(--band); padding: 8px 12px; white-space: nowrap;
}
.prose td { padding: 9px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.prose tbody tr:last-child td { border-bottom: 2px solid var(--rule-strong); }

/* code blocks. Rouge output is wrapped by the post layout:
   div.code.language-xxx > div.code-head + div.highlight > pre > code */
.prose pre {
  margin: 1.4em 0 1.6em; padding: 14px 16px; overflow-x: auto;
  font-family: var(--mono); font-size: 0.8125rem; line-height: 1.65;
  color: var(--ink); background: var(--code-bg);
  border: 1px solid var(--rule-strong); tab-size: 4;
}
.prose pre code { background: none; border: 0; padding: 0; font-size: inherit; overflow-wrap: normal; white-space: pre; }
.code .highlight { margin: 0; }
.code pre, .prose .code pre { margin: 0; border: 0; tab-size: 4; }
.code-head span { text-transform: lowercase; }
.prose .highlighter-rouge:not(.code) { background: var(--code-bg); }

/* Rouge tokens, palette-matched */
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs, .highlight .cd, .highlight .ch,
.highlight .cpf { color: var(--hl-com); font-style: italic; }
.highlight .cp { color: var(--hl-type); }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kv,
.highlight .ow, .highlight .nt { color: var(--hl-kw); font-weight: 500; }
.highlight .kt, .highlight .kc, .highlight .nc, .highlight .nn, .highlight .ne { color: var(--hl-type); }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sc, .highlight .sd,
.highlight .sh, .highlight .sx, .highlight .sr, .highlight .ss, .highlight .dl { color: var(--hl-str); }
.highlight .se, .highlight .si, .highlight .sa { color: var(--hl-num); }
.highlight .m, .highlight .mi, .highlight .mf, .highlight .mh, .highlight .mo, .highlight .mb,
.highlight .mx, .highlight .il { color: var(--hl-num); }
.highlight .nf, .highlight .fm, .highlight .nb, .highlight .bp, .highlight .nd { color: var(--hl-fn); }
.highlight .na, .highlight .nv, .highlight .vi, .highlight .vg, .highlight .vc, .highlight .no { color: var(--hl-attr); }
.highlight .err { color: var(--hl-err); background: none; }
.highlight .gd { color: var(--hl-kw); }
.highlight .gi { color: var(--hl-str); }
.highlight .gh, .highlight .gu { color: var(--hl-fn); font-weight: 600; }
.highlight .ge { font-style: italic; }
.highlight .gs { font-weight: 600; }

/* about page */
.prose .portrait { float: right; margin: 0 0 16px 32px; }
.prose .portrait .duo img { display: block; width: 100%; height: 100%; max-width: none; margin: 0; border: 0; border-radius: 0; background: none; }
.prose .portrait figcaption { font-size: 0.8125rem; color: var(--ink-3); }
.prose .portrait + p { font-size: 1.1875rem; line-height: 1.5; }
.prose h2 { clear: both; }

/* archives */
.tag-cloud { list-style: none; margin: 0; padding: 0; }
.tag-cloud li { border-bottom: 1px solid var(--rule); }
.tag-cloud a {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 6px 0; font-size: 0.875rem; color: var(--ink-2); text-decoration: none;
}
.tag-cloud a:hover { color: var(--accent); background: var(--mark); }
.tag-cloud .mono { color: var(--ink-3); font-size: 0.75rem; }
.archive-group + .archive-group { margin-top: 40px; }
.archive-group { scroll-margin-top: 16px; }
.archive-title {
  margin: 0 0 10px; font-size: 1.375rem; font-weight: 700;
  font-variation-settings: "wdth" 90;
  display: flex; align-items: baseline; gap: 10px;
}
.archive-title .mono { color: var(--ink-3); font-weight: 400; }

@media (max-width: 1000px) {
  .no-toc > .prose, .no-toc > .archive-groups { grid-column: auto; }
  .archive .toc { margin-bottom: 32px; }
  .archive .tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 10px; }
  .archive .tag-cloud li { border: 1px solid var(--rule); }
  .archive .tag-cloud a { padding: 4px 8px; gap: 6px; }
}
@media (max-width: 760px) {
  .prose .portrait { float: none; margin: 0 0 20px; }
  .prose pre { margin-left: calc(var(--gutter) * -1); margin-right: calc(var(--gutter) * -1); border-left: 0; border-right: 0; }
  .prose .code { margin-left: calc(var(--gutter) * -1); margin-right: calc(var(--gutter) * -1); border-left: 0; border-right: 0; }
  .prose .code pre { margin: 0; }
  .doc-meta div { padding-right: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

@media print {
  .nav, .theme-toggle, .toc, .skip { display: none; }
  .sheet { border: 0; }
  .doc-body, .doc-head { grid-template-columns: 1fr; }
  .no-toc > .prose { grid-column: auto; }
}
.tag-cloud a::before { content: none; }
/* plain pages (About, 404): headings without section numbers */
.page-prose h2 { display: block; }
.page-prose h2::before { content: none; }
