/* Content pages (/<slug>/index.html): the shared stylesheet. README.md "Content pages".
   The home page keeps its own inline styles; the colour tokens and type here are copied from
   index.html (the demo-only ones left out), so change both together. No build step, no script. */

:root {
  color-scheme: light dark;
  --bg: #e6e8e5;
  --fg: #161a1d;
  --muted: #59616a;
  --panel: #f3f4f1;
  --line: #c6cbc6;
  --ctl: #f8f9f7;
  --accent: #1f5fc8;
  --accent-fg: #ffffff;
  --ok: #15803d;
  --bad: #b91c1c;
  --amber: #a86e00;
  --cyan: #0b7f90;
  --shadow: 0 10px 30px rgba(0,0,0,0.12);
  --edge-shadow: rgba(0,0,0,0.18);   /* the "more to the side" shade on a scrolling table */
  --num: "Barlow Semi Condensed", "Barlow", ui-sans-serif, system-ui, sans-serif;
  --text: 42rem;    /* the reading column */
  --wide: 60rem;    /* the wider track for figures, tables and diagrams (class "wide") */
  --nav-w: 13rem;   /* the side nav's column on a wide screen */
  --nav-gap: 2.5rem;
  --gutter: 1rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1d20;
    --fg: #e4e7e3;
    --muted: #949ba2;
    --panel: #22262a;
    --line: #353b41;
    --ctl: #262b30;
    --accent: #5794f2;
    --accent-fg: #0d1115;
    --ok: #4ade80;
    --bad: #f87171;
    --amber: #f0b429;
    --cyan: #38c6d9;
    --shadow: 0 10px 30px rgba(0,0,0,0.5);
    --edge-shadow: rgba(0,0,0,0.6);
  }
}
@media (min-width: 40rem) { :root { --gutter: 2rem; } }
/* The sticky site header's height: the side nav sticks below it and anchor targets land below it. */
:root { --header-h: calc(3.5rem + 1px); }
@media (max-width: 39.99rem) { :root { --header-h: 3.45rem; } }
html { scroll-padding-top: calc(var(--header-h) + 0.75rem); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: "Barlow", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1 0 auto; }
img { max-width: 100%; height: auto; }
strong, b { font-weight: 600; }   /* only 400 and 600 are loaded */

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px;
}

/* --- Site header: the name, back to the home page, then the four main links (nav.site-nav). Sticky at
   the top on every page that has it, solid on the page's background. On a phone it is two compact rows
   (the name, then the links on one line, scrolling sideways within itself only if a phone is too narrow). --- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.site-header .bar, .site-footer .bar {
  max-width: calc(var(--nav-w) + var(--nav-gap) + var(--wide) + 2 * var(--gutter)); margin: 0 auto;
  padding: 0 var(--gutter);
}
.site-header .bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0 1.5rem; min-height: 3.5rem;
}
.site-name {
  font-family: var(--num); font-weight: 600; font-size: 1.2rem; letter-spacing: 0.01em; line-height: 1.2;
  color: var(--fg); text-decoration: none; padding: 0.6rem 0;
}
.site-name:hover { color: var(--accent); }
.site-nav { display: flex; flex-wrap: wrap; gap: 0 1.1rem; }
.site-nav a {
  display: block; padding: 0.55rem 0 0.45rem; border-bottom: 2px solid transparent;
  color: var(--fg); font-size: 0.95rem; font-weight: 600; line-height: 1.3; text-decoration: none;
}
.site-nav a:hover { color: var(--accent); }
.site-nav a[aria-current] { color: var(--accent); border-bottom-color: var(--accent); }   /* this page or its section */
@media (max-width: 39.99rem) {
  .site-header .bar { min-height: 0; row-gap: 0; padding-top: 0.3rem; }
  .site-name { font-size: 1.05rem; padding: 0.05rem 0; }
  .site-nav { flex-wrap: nowrap; width: 100%; gap: 0 1rem; overflow-x: auto; scrollbar-width: none; }
  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav a { flex: none; font-size: 0.88rem; padding: 0.15rem 0 0.25rem; white-space: nowrap; }
}

/* --- Keep me posted (a.kmp): the home page's call to action, on every content page but Contact (its
   target). On a wide screen it heads the sticky side nav (a.kmp-side); narrower, where the side nav folds
   above the page, it sits in the header beside the name (a.kmp-top). The home page has its own copy. --- */
.kmp {
  display: inline-block; border-radius: 8px; background: var(--accent); color: var(--accent-fg);
  font-weight: 600; line-height: 1.2; text-decoration: none; white-space: nowrap;
}
.kmp:hover { filter: brightness(1.08); }
.kmp-top { margin-right: auto; padding: 0.35rem 0.8rem; font-size: 0.88rem; }
.side-nav a.kmp-side { display: none; }
@media (min-width: 60rem) {
  .kmp-top { display: none; }
  .side-nav a.kmp-side {
    display: inline-block; margin: 0 0 1.1rem; padding: 0.6rem 1.2rem; border-left: 0;
    color: var(--accent-fg); font-size: 1rem;
  }
  .side-nav a.kmp-side:hover { color: var(--accent-fg); }
}
@media (max-width: 39.99rem) { .kmp-top { padding: 0.25rem 0.65rem; font-size: 0.8rem; } }

/* --- The page: every block sits in the reading column; class "wide" takes the wider track --- */
.page { padding: 0 var(--gutter) 1rem; }
.page > *, .page > section > * { max-width: var(--text); margin-left: auto; margin-right: auto; }
.page > section { max-width: none; }
.page .wide { max-width: var(--wide); }

/* --- Layout: <div class="layout"> holds the side nav and the page. On a wide screen the nav is a
   column on the left and the page's blocks sit against it; on a phone the nav folds above the page. --- */
/* width: 100%, because a flex item with auto margins is not stretched: it would grow to its widest
   unbreakable content (a table) instead of letting the table scroll. */
.layout { width: 100%; max-width: calc(var(--nav-w) + var(--nav-gap) + var(--wide) + 2 * var(--gutter)); margin: 0 auto; }
@media (min-width: 60rem) {
  .layout {
    display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); column-gap: var(--nav-gap);
    padding: 0 var(--gutter);
  }
  .layout > .page { padding-left: 0; padding-right: 0; }
  .layout > .page > *, .layout > .page > section > * { margin-left: 0; }
}

/* --- Side nav (nav.side-nav): the pages in their groups, the current one marked, its H2s under it.
   A <details> "Pages" folds it on a phone; on a wide screen it is always open, beside the page. --- */
.side-nav { border-bottom: 1px solid var(--line); padding: 0 var(--gutter); font-size: 0.92rem; line-height: 1.35; }
.side-fold > summary {
  display: flex; align-items: center; gap: 0.6rem; min-height: 2.75rem;
  font-weight: 600; cursor: pointer; list-style: none;
}
.side-fold > summary::-webkit-details-marker { display: none; }
.side-fold > summary::before {
  content: ""; width: 0.45rem; height: 0.45rem; margin-left: 0.15rem;
  border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(-45deg);
}
.side-fold[open] > summary::before { transform: rotate(45deg); }
.side-groups { padding-bottom: 0.75rem; }
.side-group {
  margin: 0.9rem 0 0.3rem; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
}
.side-groups > .side-group:first-child { margin-top: 0.25rem; }
.side-nav .side-group a {   /* the group's name links to its first page */
  display: inline; padding: 0; border: 0; background: none; color: inherit; font-weight: inherit;
}
.side-nav .side-group a:hover { color: var(--accent); text-decoration: underline; }
.side-nav ul { list-style: none; margin: 0; padding: 0; }
.side-nav li + li { margin-top: 0; }
.side-nav a {
  display: block; padding: 0.3rem 0.6rem; border-left: 2px solid transparent;
  color: var(--fg); text-decoration: none;
}
.side-nav a:hover { color: var(--accent); }
.side-nav a[aria-current="page"] {
  color: var(--accent); font-weight: 600; border-left-color: var(--accent); background: var(--panel);
}
.side-nav ul ul { margin: 0.1rem 0 0.35rem 0.75rem; border-left: 1px solid var(--line); }
.side-nav ul ul a { padding: 0.22rem 0.6rem; font-size: 0.88rem; color: var(--muted); }
.side-nav ul ul a:hover, .side-nav ul ul a[aria-current="page"] { color: var(--accent); }
@media (min-width: 60rem) {
  .side-nav {
    border-bottom: 0; padding: 2.25rem 0 1rem;
    position: sticky; top: var(--header-h); align-self: start; max-height: calc(100vh - var(--header-h)); overflow-y: auto;
  }
  /* Always open here. A browser without ::details-content keeps the "Pages" toggle instead. */
  @supports selector(::details-content) {
    .side-fold > summary { display: none; }
    .side-fold::details-content { content-visibility: visible; display: block; }
  }
}

.page-head { padding: 2.25rem 0 0.5rem; }

/* Breadcrumb (a hub and its sub-pages): first in .page-head, above the <h1>. Home / Hub / This page */
.crumbs {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem;
  font-size: 0.9rem; font-weight: 600; line-height: 1.4; color: var(--muted);
  margin: 0 0 0.9rem;
}
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs .sep { color: var(--line); font-weight: 400; }
.crumbs .cur { color: var(--fg); }
h1 {
  font-size: clamp(2rem, 1.4rem + 2.6vw, 3rem); line-height: 1.05; font-weight: 600;
  letter-spacing: -0.015em; margin: 0 0 0.9rem;
}
h2 {
  font-size: clamp(1.4rem, 1.2rem + 0.8vw, 1.75rem); line-height: 1.15; font-weight: 600;
  letter-spacing: -0.01em; margin: 2.75rem 0 0.75rem;
}
h3 { font-size: 1.2rem; line-height: 1.25; font-weight: 600; margin: 2rem 0 0.5rem; }
p, ul, ol { margin: 0 0 1rem; }
ul, ol { padding-left: 1.4rem; }
li + li { margin-top: 0.35rem; }
.lede { font-size: 1.2rem; line-height: 1.45; margin-bottom: 0.9rem; }


/* A name as the instrument's screen shows it (HOME, MAX ADV, SYSTEM) */
.ui { font-family: var(--num); font-weight: 600; letter-spacing: 0.03em; }
code, kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88em;
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 0.05em 0.3em;
}

/* --- Note / callout: the home page's .note --- */
.note {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 14px; font-size: 0.95rem; margin-top: 1.25rem; margin-bottom: 1.25rem;
}
.note > :first-child { margin-top: 0; }
.note > :last-child { margin-bottom: 0; }

/* --- Figures: every picture, diagram and table is a <figure> with a <figcaption> --- */
figure { margin: 1.75rem auto 2rem; }
figure > img, figure > picture > img, figure > svg { display: block; margin: 0 auto; }
figcaption {
  max-width: var(--text); margin: 0.65rem auto 0; text-align: center;
  color: var(--muted); font-size: 0.9rem; line-height: 1.45;
}
img.photo { border-radius: 8px; }

/* --- Lightbox (js/lightbox.mjs, README "Lightbox"): <a class="zoom" href="<largest file>"> around a
   picture. Without the script the link opens the file; with it, a modal overlay shows it full size. --- */
a.zoom { display: block; cursor: zoom-in; border-radius: 8px; }
a.zoom:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
a.zoom > picture { display: block; }
a.zoom > img, a.zoom > picture > img { display: block; margin: 0 auto; }
html.lb-open { overflow: hidden; }
dialog.lightbox {
  width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; background: transparent; color: #e4e7e3; cursor: zoom-out;
}
dialog.lightbox[open] { display: grid; place-items: center; }
dialog.lightbox::backdrop { background: rgba(10, 12, 14, 0.94); }
.lightbox figure { margin: 0; padding: 3.75rem 1rem 1rem; display: grid; justify-items: center; gap: 0.75rem; }
.lightbox img {
  display: block; max-width: calc(100vw - 2rem); max-height: calc(100vh - 8rem); max-height: calc(100dvh - 8rem);
  width: auto; height: auto; object-fit: contain; border-radius: 4px;
}
.lightbox figcaption { max-width: 42rem; font-size: 0.9rem; line-height: 1.45; text-align: center; color: #c9cdc8; }
.lb-close {
  position: fixed; top: 0.75rem; right: 0.75rem; width: 2.75rem; height: 2.75rem; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.4); background: rgba(0, 0, 0, 0.45); color: #fff;
  font: 400 1.6rem/1 "Barlow", ui-sans-serif, system-ui, sans-serif; cursor: pointer;
}
.lb-close:focus-visible { outline: 2px solid #8bb6f7; outline-offset: 2px; }
@media (prefers-reduced-motion: no-preference) {
  dialog.lightbox[open], dialog.lightbox[open]::backdrop { animation: lb-fade 160ms ease-out; }
  @keyframes lb-fade { from { opacity: 0; } to { opacity: 1; } }
}

/* Instrument screen captures: the 320 x 240 screen, rendered natively at 2x, 3x and 4x and offered with
   srcset, so the browser picks the one that is sharp at its width: 320 CSS px on a phone and in a row,
   640 on a wider screen (README "Screens"). */
.screen-shot {
  display: block; width: 320px; max-width: 100%; height: auto; aspect-ratio: 4 / 3;
  background: #000; border-radius: 3px; box-shadow: 0 0 0 1px var(--line);
}
@media (min-width: 44rem) { .screen-shot { width: 640px; } }
/* Several screens side by side, 320 px each, wrapping on a phone */
.screen-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem 1.25rem; }
.screen-row .screen-shot { width: 320px; margin: 0; }

/* --- Placeholder: where a picture will go. --ar is the final picture's aspect ratio. --- */
.placeholder {
  display: grid; place-items: center; width: 100%; aspect-ratio: var(--ar, 3 / 2);
  margin: 0 auto; padding: 1rem 1.25rem;
  border: 2px dashed var(--muted); border-radius: 8px;
  background: repeating-linear-gradient(-45deg, var(--panel) 0 12px, var(--bg) 12px 24px);
  color: var(--fg); text-align: center; font-size: 0.95rem; line-height: 1.45;
}
.placeholder > * { margin: 0; max-width: 28rem; }

/* --- Tables: in a .table-scroll box, which scrolls sideways when the table is wider than a phone.
   The shade at an edge says there is more that way (it goes as the end scrolls into view). --- */
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line); border-radius: 8px;
  background:
    linear-gradient(to right, var(--panel) 30%, transparent) left center / 2.5rem 100% no-repeat local,
    linear-gradient(to left, var(--panel) 30%, transparent) right center / 2.5rem 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--edge-shadow), transparent) left center / 0.9rem 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--edge-shadow), transparent) right center / 0.9rem 100% no-repeat scroll,
    var(--panel);
}
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; line-height: 1.4; }
th, td { text-align: left; vertical-align: top; padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--line); }
thead th {
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); white-space: nowrap; vertical-align: bottom;
}
tbody th { font-weight: 600; }
tbody tr:last-child > * { border-bottom: 0; }
.num { text-align: right; font-family: var(--num); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
/* Yes / no in a table: the word carries the meaning, the colour only repeats it */
.is-ok { color: var(--ok); font-weight: 600; }
.is-bad { color: var(--bad); font-weight: 600; }

/* --- Inline SVG diagrams: <svg class="diagram" viewBox="..." role="img" aria-label="...">.
   No colours in the SVG itself: use these classes (or currentColor), so it works light and dark. --- */
svg.diagram {
  display: block; width: 100%; height: auto; max-width: var(--text); margin: 0 auto;
  color: var(--fg); font-family: var(--num); overflow: visible;
}
.wide > svg.diagram { max-width: var(--wide); }
.diagram text { fill: currentColor; font-size: 16px; font-weight: 600; }
.diagram .small { font-family: "Barlow", ui-sans-serif, system-ui, sans-serif; font-weight: 400; font-size: 14px; fill: var(--muted); }
.diagram .mid { text-anchor: middle; }
.diagram .end { text-anchor: end; }
.diagram .box { fill: var(--panel); stroke: var(--line); stroke-width: 1.5; }
.diagram .box-key { fill: var(--panel); stroke: var(--accent); stroke-width: 2.5; }   /* what the figure is about */
.diagram .wire { fill: none; stroke: var(--fg); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.diagram .wire-key { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.diagram .wire-muted { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 4; }
.diagram .head { fill: var(--fg); }
.diagram .head-key { fill: var(--accent); }
.diagram .fill-accent { fill: var(--accent); }
.diagram .fill-ok { fill: var(--ok); }
.diagram .fill-bad { fill: var(--bad); }
.diagram .fill-amber { fill: var(--amber); }
.diagram .fill-muted { fill: var(--muted); }

/* --- Site footer: contact and the no-affiliation sentence (as on the home page) --- */
.site-footer { border-top: 1px solid var(--line); margin-top: 2rem; }
.site-footer .bar { padding-top: 1.5rem; padding-bottom: 2rem; text-align: center; }
.site-footer .contact { margin: 0 0 0.75rem; }
.site-footer .fine { color: var(--muted); font-size: 0.8rem; margin: 0; }

@media print {
  .site-header, .site-footer { border: 0; }
  .site-header { position: static; }
  .site-nav, .side-nav { display: none; }
  .table-scroll { overflow: visible; background: none; }
}
