/* Zero Mile Instruments: shared design system (spec-sheet look, from design/home-b-v2.html).
   One light look by choice; every colour is a token below. Pages add only page-specific CSS in
   their own page.css and reuse these classes where they exist.
   Layout: .page is the paper (and an inline-size container named "page", so cqi units work);
   breakpoints in this file are viewport media queries: 820px (two columns become one) and
   640px (tables stack into rows). */

/* ---- Fonts: self-hosted IBM Plex, latin subset (OFL, see /fonts/OFL.txt) ---- */
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400 600;
  font-stretch: 100%;
  font-display: swap;
  src: url("/fonts/ibm-plex-sans-latin-var.woff2") format("woff2");
  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: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/ibm-plex-mono-latin-400.woff2") format("woff2");
  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: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/ibm-plex-mono-latin-500.woff2") format("woff2");
  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;
}

/* ---- Tokens ---- */
:root {
  --paper: #f4f6f7; --grid: #e2e7ea; --sheet: #ffffff; --ink: #10202f; --body: #2b3a48; --mute: #55636f;
  --rule: #c9d2d9; --field: #6b7884; --blue: #1f5fbf; --chip: #eef2f5; --tint: #f7f9fa; --code: #eef2f5;
  --ink-hover: #1d3448; --press: #dce6f5;
  /* status colours: text colour + pale background */
  --ok: #1d7a4c; --ok-bg: #e8f4ed;
  --soon: #8a5a00; --warn: #8a5a00; --warn-bg: #fbf3e2;
  --bad: #b42318; --bad-bg: #fcefee;
  --note: #3d5266; --note-bg: #edf1f5;
  --idea: #55636f;
  --sans: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --gap: max(28px, 4cqi);
  color-scheme: light;
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--body); font-family: var(--sans); font-size: 16px; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
strong, b { font-weight: 600; }
img, svg { max-width: 100%; }
a { color: var(--blue); text-underline-offset: .15em; }
a:hover { text-decoration-thickness: 2px; }
code, kbd, samp, .mono { font-family: var(--mono); }
code { font-size: .92em; background: var(--code); color: var(--ink); padding: 1px 4px; overflow-wrap: anywhere; }
kbd { font: 500 12.5px var(--mono); color: var(--ink); background: var(--chip); border: 1px solid var(--rule); border-bottom-width: 2px; padding: 0 5px; white-space: nowrap; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.nw { white-space: nowrap; }
[hidden] { display: none !important; }

/* Focus ring: one rule for every interactive element */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: 2px solid var(--blue); outline-offset: 4px; }
[tabindex="-1"]:focus:not(:focus-visible) { outline: none; }

/* Visually hidden, still read by screen readers */
.sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 10; padding: 10px 14px; background: var(--ink); color: var(--sheet); font-weight: 500; text-decoration: none; }
.skip:focus { top: 8px; }

/* ---- Page frame: paper with a faint 24px grid ---- */
.page { container-type: inline-size; container-name: page; min-height: 100vh; background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px; }
.wrap { box-sizing: content-box; max-width: 1200px; margin-inline: auto; padding-inline: max(16px, 4.5cqi); padding-block: max(20px, 3.5cqi) 48px; display: grid; gap: var(--gap); }
.wrap > *, .main > * { min-width: 0; }
.main { display: grid; gap: var(--gap); align-content: start; }
.main:focus { outline: none; }

/* Site header */
.top { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; border-bottom: 2px solid var(--ink); padding-bottom: 12px; }
.top .brand { color: var(--ink); font-size: 18px; font-weight: 600; text-decoration: none; }
.top .brand:hover { text-decoration: underline; }
.top .desc { color: var(--mute); font-size: 14px; }

/* Site footer (house rules line + company line, on every page) */
.foot { border-top: 2px solid var(--ink); padding-top: 12px; display: grid; gap: 6px; font-size: 13.5px; line-height: 1.55; color: var(--mute); }
.foot p { margin: 0; }
.foot .foot-rules { color: var(--ink); font-size: 14.5px; }
.foot .foot-rules strong { font-weight: 500; }
.foot-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 20px; }

/* ---- Headings and text ---- */
.hero { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 28px 48px; align-items: start; }
.hero h1, .h1 { margin: 0; color: var(--ink); font-weight: 600; font-size: clamp(32px, 4.8cqi, 62px); line-height: 1.05; letter-spacing: -.025em; text-wrap: balance; }
.hero p, .lede { margin: 16px 0 0; font-size: clamp(16.5px, 1.4cqi, 19px); line-height: 1.6; max-width: 36em; }
.hero p a { font-weight: 500; }
.hero .sig, .sig { color: var(--mute); font-size: 15px; margin-top: 10px; }
.rules-line { margin: 10px 0 0; font-size: 15px; color: var(--ink); font-weight: 500; }
.hero .rules-line { margin-top: 12px; font-size: 15px; }
.intro h1 { margin: 0; color: var(--ink); font-weight: 600; font-size: clamp(28px, 3.1cqi, 40px); line-height: 1.1; letter-spacing: -.02em; text-wrap: balance; }
.intro p { margin: 10px 0 0; font-size: clamp(16px, 1.35cqi, 18px); line-height: 1.55; max-width: 40em; }

/* ---- Spec box: white sheet, ink border, mono heading, definition rows ---- */
.spec, .sheet { background: var(--sheet); border: 1px solid var(--ink); }
.spec > h2, .sheet-h { margin: 0; padding: 10px 14px; border-bottom: 1px solid var(--ink); font: 600 13px var(--mono); color: var(--ink); }
.spec dl { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); }
.spec dt, .spec dd { margin: 0; padding: 9px 14px; border-bottom: 1px solid var(--rule); font-size: 14.5px; }
.spec dt { font: 500 13px var(--mono); color: var(--mute); border-right: 1px solid var(--rule); }
.spec dd { color: var(--ink); }
.spec > p { margin: 0; padding: 12px 14px; font-size: 14px; line-height: 1.5; }
.spec dl:last-child > :nth-last-child(-n+2) { border-bottom: 0; }

/* ---- Buttons and chips ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 16px; border: 1px solid var(--ink); background: var(--sheet); color: var(--ink); font: 500 15px var(--sans); text-decoration: none; cursor: pointer; text-align: center; }
.btn:hover { background: var(--tint); }
.btn.primary { background: var(--ink); color: var(--sheet); font-weight: 600; }
.btn.primary:hover { background: var(--ink-hover); }
.btn:disabled, .btn[aria-disabled="true"] { color: var(--mute); border-color: var(--rule); background: var(--sheet); cursor: not-allowed; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip, .chips button { font: 500 13px var(--mono); min-height: 32px; padding: 6px 10px; border: 1px solid var(--rule); background: var(--chip); color: var(--ink); cursor: pointer; }
.chip[aria-pressed="true"], .chips button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--sheet); }

/* ---- Inputs ---- */
.field { font: 500 17px var(--mono); color: var(--ink); padding: 10px 12px; border: 1px solid var(--field); background: var(--sheet); border-radius: 0; min-width: 0; }
.field:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
.field[aria-invalid="true"] { border-color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad); }

/* ---- Status words (mono, coloured, never colour alone: the word carries the meaning) ---- */
.st { font: 600 13px var(--mono); white-space: nowrap; }
.st.ready, .st.ok { color: var(--ok); }
.st.soon, .st.warn { color: var(--warn); }
.st.idea { color: var(--idea); }
.st.bad { color: var(--bad); }
.st.note { color: var(--note); }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; font-size: 15px; }
thead th { text-align: left; font: 600 12.5px var(--mono); color: var(--mute); padding: 9px 14px; border-bottom: 1px solid var(--ink); }
td, tbody th { padding: 12px 14px; border-bottom: 1px solid var(--rule); vertical-align: top; text-align: left; font-weight: 400; }
td.num, td.mono { font: 500 14px var(--mono); color: var(--ink); font-variant-numeric: tabular-nums; }

/* Tool catalogue (home): whole row is the link, via the name link's ::after, no JS */
.catalog { background: var(--sheet); border: 1px solid var(--ink); }
.cat-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--ink); }
.cat-head h2 { margin: 0; color: var(--ink); font-size: 20px; font-weight: 600; }
tr.tool { position: relative; }
tr.tool.live:hover { background: var(--tint); }
th.name { font-weight: 600; color: var(--ink); white-space: nowrap; }
th.name a::after { content: ""; position: absolute; inset: 0; }
td.runs { color: var(--mute); white-space: nowrap; }
.next { margin: 0; padding: 12px 14px; font-size: 14.5px; line-height: 1.55; border-top: 1px solid var(--rule); }
.next strong { color: var(--ink); }
.mail { font-family: var(--mono); color: var(--ink); overflow-wrap: anywhere; }
a.mail { color: var(--blue); }

/* ---- Three-column story strip ---- */
.story { background: var(--sheet); border: 1px solid var(--ink); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.story > div { padding: 18px 20px; border-right: 1px solid var(--rule); min-width: 0; }
.story > div:last-child { border-right: 0; }
.story h2 { margin: 0 0 8px; color: var(--ink); font-size: 17px; font-weight: 600; }
.story p { margin: 0; font-size: 15px; line-height: 1.6; }
.story p + p { margin-top: 8px; }

/* ---- Short note blocks and plain prose ---- */
.note-block { font-size: 14px; line-height: 1.6; color: var(--body); max-width: 60em; }
.note-block h2 { margin: 0 0 4px; color: var(--ink); font-size: 15px; font-weight: 600; }
.note-block p { margin: 0; }
.prose { max-width: 44em; font-size: 16.5px; line-height: 1.65; }
.prose > h1 { margin: 0 0 12px; color: var(--ink); font-weight: 600; font-size: clamp(30px, 3.4cqi, 44px); line-height: 1.1; letter-spacing: -.02em; }
.prose > h2 { margin: 32px 0 8px; color: var(--ink); font-size: 20px; font-weight: 600; line-height: 1.3; }
.prose > p, .prose > ul { margin: 0 0 12px; }
.prose > ul { padding-left: 1.25em; }
.prose li + li { margin-top: 4px; }
.prose > .spec { margin: 20px 0 8px; }
.prose > .lede { margin: 0 0 12px; }
.prose .meta { color: var(--mute); font-size: 14px; font-family: var(--mono); }

/* ---- Folded detail (details/summary) ---- */
details.fold { background: var(--sheet); border: 1px solid var(--ink); }
details.fold > summary { cursor: pointer; padding: 12px 14px; color: var(--ink); font-weight: 600; list-style-position: inside; }
details.fold[open] > summary { border-bottom: 1px solid var(--rule); }
details.fold > .fold-body { padding: 12px 14px; }

/* ---- Narrow screens ---- */
@media (max-width: 820px) {
  .hero, .story { grid-template-columns: minmax(0, 1fr); }
  .story > div { border-right: 0; border-bottom: 1px solid var(--rule); }
  .story > div:last-child { border-bottom: 0; }
}
@media (max-width: 640px) {
  /* table.stack: each row becomes a small card; cells show their data-label */
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td, table.stack tbody th { display: block; width: 100%; }
  table.stack tr { padding: 12px 14px; border-bottom: 1px solid var(--rule); }
  table.stack tr > * { padding: 0; border: 0; }
  table.stack td[data-label]::before { content: attr(data-label) ": "; font: 500 12px var(--sans); color: var(--mute); }
  /* the tool catalogue: name and status on the first line */
  table.stack tr.tool { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  table.stack tr.tool th.name { grid-column: 1; white-space: normal; }
  table.stack tr.tool td.stc { grid-column: 2; grid-row: 1; text-align: right; }
  table.stack tr.tool td:not(.stc) { grid-column: 1 / -1; }
  .spec dt, .spec dd { padding: 9px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media print {
  .page { background-image: none; }
  .skip { display: none; }
}
