/* Styles for the design model viewer (index.html + viewer.js). UI only: no content.
   A drafting-sheet page: one map on a framed sheet with a faint grid, a mode
   switch above it, and one card under it; prose sits in a narrower column.
   Light and dark palettes; an explicit data-theme on the root element wins
   over the system setting. */

:root {
  color-scheme: light;
  --paper: #F2F4F7; --sheet: #FFFFFF; --ink: #16202B; --ink2: #4B5768; --ink3: #7A8697; --rule: #D3DAE3; --grid: #EDF0F4;
  --data: #1E5CCB; --trig: #C2461A; --time: #7144C4; --ctrl: #566476; --mon: #14825A;
  --out: #8A6100; --outbg: #FBEFCB; --sel: #16202B; --hot: #FFF1BF;
  --msg: #FFF8C5; --err: #82071E; --errbg: #FFEBE9;
  --f-ui: "Archivo", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --f-body: "Source Serif 4", Georgia, "Times New Roman", serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --headbg: color-mix(in srgb, var(--ink) 4%, var(--sheet));
  --pad: 16px;     /* side padding of a card */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0E1318; --sheet: #141A21; --ink: #E3E8EF; --ink2: #A3AFBE; --ink3: #748194; --rule: #2B3540; --grid: #192028;
    --data: #7AA7FF; --trig: #FF8E62; --time: #B9A0FF; --ctrl: #A0AEC1; --mon: #52CB93;
    --out: #E8C062; --outbg: #3A2F12; --sel: #E3E8EF; --hot: #3A3416;
    --msg: #3A3416; --err: #FFB4AB; --errbg: #3B1219;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0E1318; --sheet: #141A21; --ink: #E3E8EF; --ink2: #A3AFBE; --ink3: #748194; --rule: #2B3540; --grid: #192028;
  --data: #7AA7FF; --trig: #FF8E62; --time: #B9A0FF; --ctrl: #A0AEC1; --mon: #52CB93;
  --out: #E8C062; --outbg: #3A2F12; --sel: #E3E8EF; --hot: #3A3416;
  --msg: #3A3416; --err: #FFB4AB; --errbg: #3B1219;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* No in-page click moves the page: the browser must not shift the page to
   keep content in view when something above the window changes size. */
html, body { overflow-anchor: none; }
body { background: var(--paper); color: var(--ink); font: 17px/1.6 var(--f-body); margin: 0; }
.wrap { max-width: 1220px; margin: 0 auto; padding-inline: 20px; padding-block: 18px 96px; }
.prose { max-width: 68ch; }
h1, h2, h3, h4, h5, h6, .eyebrow, .ui { font-family: var(--f-ui); }
h1 { font-size: clamp(34px, 5vw, 52px); line-height: 1.02; font-weight: 700; font-stretch: 72%; letter-spacing: -.01em; margin: 22px 0 14px; text-wrap: balance; }
h2 { font-size: 27px; line-height: 1.15; font-weight: 650; font-stretch: 84%; margin: 0 0 10px; text-wrap: balance; }
h3 { font-size: 18px; font-weight: 650; font-stretch: 88%; margin: 0 0 6px; }
h4 { font-size: 16px; font-weight: 650; font-stretch: 90%; margin: 10px 0 4px; }
.eyebrow { font-size: 12px; font-weight: 650; letter-spacing: .11em; text-transform: uppercase; color: var(--ink2); }
p { margin: 0 0 12px; }
a { color: var(--data); }
code { font-family: var(--f-mono); font-size: .86em; background: var(--grid); padding: 1px 4px; border-radius: 3px; overflow-wrap: anywhere; }
:focus-visible { outline: 2px solid var(--data); outline-offset: 2px; }
/* the map section takes the focus (tabindex="-1") when clicked, so that the
   arrow keys move the tour; it draws no focus ring of its own */
#map-section:focus, #card-title:focus { outline: none; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- header ---------------------------------------------------------- */
.topbar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; font-family: var(--f-ui); }
.header-link { font: 600 14px var(--f-ui); font-stretch: 90%; white-space: nowrap; display: inline-flex; align-items: center; min-height: 32px; }
.header-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.edit-link { color: var(--ink2); }
#help-toggle[aria-expanded="true"], #read-toggle[aria-pressed="true"] { background: var(--ink); color: var(--sheet); }

/* ---- help and messages -------------------------------------------------- */
/* the help: an overlay over the page that scrolls inside itself, so that
   opening and closing it never moves the page */
.help { position: fixed; inset: 0; z-index: 50; overflow-y: auto; overscroll-behavior: contain; padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(24px + env(safe-area-inset-bottom, 0px)); background: color-mix(in srgb, var(--ink) 40%, transparent); }
.help-panel { max-width: 92ch; margin: 0 auto; padding: 0 22px 16px; background: var(--sheet); border: 1px solid var(--rule); border-left: 3px solid var(--ink); border-radius: 4px; font-size: 16px; box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
.help-top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 1; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin: 0 -22px 8px; padding: 12px 22px 10px; background: var(--sheet); border-bottom: 1px solid var(--rule); border-radius: 4px 4px 0 0; }
.help h2 { font-size: 21px; margin: 0; }
.help h2:focus { outline: none; }
.help ul { margin: 0 0 12px; padding-left: 20px; }
.help li { margin: 6px 0; }
.message { margin: 18px 0 0; padding: 8px 14px; background: var(--msg); border: 1px solid var(--rule); border-radius: 4px; font: 15px var(--f-ui); }
.message.error { background: var(--errbg); color: var(--err); }

/* ---- the map section: mode switch, Emphasize, stage, tour bar, cards ---- */
#map-section { margin-top: 8px; }
.modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--ink); border-radius: 4px; overflow: hidden; background: var(--sheet); }
.mode { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; text-align: left; min-height: 44px; padding: 9px 14px 10px; border: 0; border-left: 1px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer; font-family: var(--f-ui); }
.mode:first-child { border-left: 0; }
.mode-name { font-size: 16px; font-weight: 650; font-stretch: 88%; }
.mode-sub { font-size: 13px; line-height: 1.3; font-stretch: 92%; color: var(--ink2); }
.mode:hover { background: var(--headbg); }
.mode[aria-pressed="true"] { background: var(--ink); color: var(--sheet); }
.mode[aria-pressed="true"] .mode-sub { color: color-mix(in srgb, var(--sheet) 78%, var(--ink)); }
.mode:focus-visible { outline: 2px solid var(--data); outline-offset: -4px; }
@media (max-width: 600px) {
  .modes { grid-template-columns: minmax(0, 1fr); }
  .mode { border-left: 0; border-top: 1px solid var(--ink); }
  .mode:first-child { border-top: 0; }
}
/* the note of the tour and of Compare kinds: one heading line, then text */
.mode-note { margin-top: 12px; font-size: 15.5px; line-height: 1.55; color: var(--ink2); max-width: 84ch; }
.mode-note .note-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; margin: 0; font-size: 19px; line-height: 1.25; color: var(--ink); }
.mode-note .note-head .eyebrow { font-size: 12px; }
.mode-note .prose { max-width: none; }
.mode-note p { margin: 4px 0 6px; }
.mode-note details { margin-top: 2px; }
.mode-note summary { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; cursor: pointer; font: 600 14px var(--f-ui); color: var(--ink2); list-style: none; }
.mode-note summary::-webkit-details-marker { display: none; }
.mode-note summary::before { content: "\25B8"; font: 13px var(--f-ui); width: 12px; transition: transform .15s; }
.mode-note details[open] > summary::before { transform: rotate(90deg); }
.mode-note summary:focus-visible { outline: 2px solid var(--data); outline-offset: 2px; }
.ui-note { font: 600 14px var(--f-ui); font-stretch: 92%; color: var(--ink); }

/* ---- the stage: the one figure frame the modes swap ---------------------- */
.sheet { background-color: var(--sheet); background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 24px 24px; border: 1px solid var(--rule); border-radius: 4px; padding: 14px; overflow-x: auto; }
@media (max-width: 820px) {
  .sheet { padding: 6px; }
  /* a tablet in portrait: a little more width for the figures, so that the
     fitted map's smallest text (12 units) stays at 7 px or more at 744 px */
  .wrap { padding-inline: 14px; }
  #map { padding: 4px; }
  :root { --pad: 12px; }
}
figure { margin: 0; }
.stage { margin-top: 12px; }
figcaption, .kind-caption { font-size: 15px; line-height: 1.5; color: var(--ink2); max-width: 80ch; margin: 10px 0 0; }
figcaption b, .kind-caption b { color: var(--ink); font-weight: 600; }
.sec-caption:empty { display: none; }
.kind-caption { border-left: 3px solid var(--ink3); padding-left: 10px; }
.seq-caption { margin-top: 6px; }
.seq-key { display: flex; align-items: center; gap: 8px; margin: 6px 0 0; font: 14px/1.4 var(--f-ui); font-stretch: 92%; color: var(--ink2); max-width: 80ch; }
.seq-key svg { width: 28px; height: 8px; flex: none; overflow: visible; }
.seq-key .ln { stroke-width: 3; }
.seq-status { margin: 0; margin-right: auto; font: 600 15px/1.35 var(--f-ui); font-stretch: 92%; color: var(--ink); }
.seq-status .eyebrow { margin-right: 6px; }

/* ---- controls ------------------------------------------------------------ */
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0 0; }
.bar .lbl { font: 600 12px var(--f-ui); letter-spacing: .1em; text-transform: uppercase; color: var(--ink2); margin-right: 4px; }
.chip { font: 600 14px var(--f-ui); font-stretch: 90%; display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 6px 12px; border: 1px solid var(--rule); background: var(--sheet); color: var(--ink); border-radius: 999px; cursor: pointer; }
.chip svg { width: 28px; height: 8px; overflow: visible; }
.chip[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.btn { font: 600 14px var(--f-ui); min-height: 36px; padding: 7px 14px; border: 1px solid var(--ink); background: var(--sheet); color: var(--ink); border-radius: 3px; cursor: pointer; }
.btn:disabled { opacity: .35; cursor: default; }
.btn-small { font-size: 13px; min-height: 32px; padding: 4px 10px; }
.fullsize[aria-pressed="true"] { background: var(--ink); color: var(--sheet); }
.linkish { font: 600 15px var(--f-ui); font-stretch: 92%; background: none; border: 0; padding: 4px 0; min-height: 32px; color: var(--data); text-decoration: underline; cursor: pointer; text-align: left; }

/* ---- figure bar under a frame: the scroll cue and the Full size button --- */
.figbar { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; justify-content: flex-end; margin: 6px 0 0; }
.figbar:not(:has(.fullsize)):not(:has(.seq-status)):has(.scroll-hint[hidden]) { display: none; }
.scroll-hint { font: 600 13px var(--f-ui); font-stretch: 90%; color: var(--ink2); }
.dhead { display: flex; justify-content: flex-end; margin: 0 0 6px; }
.dhead:has(.scroll-hint[hidden]) { display: none; }
/* a frame that scrolls fades out at the side where more of the figure is */
[data-scrolls="true"].more-right { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), rgba(0, 0, 0, .3)); mask-image: linear-gradient(to right, #000 calc(100% - 36px), rgba(0, 0, 0, .3)); }
[data-scrolls="true"].more-left { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 36px), rgba(0, 0, 0, .3)); mask-image: linear-gradient(to left, #000 calc(100% - 36px), rgba(0, 0, 0, .3)); }
[data-scrolls="true"].more-left.more-right { -webkit-mask-image: linear-gradient(to right, rgba(0, 0, 0, .3), #000 36px, #000 calc(100% - 36px), rgba(0, 0, 0, .3)); mask-image: linear-gradient(to right, rgba(0, 0, 0, .3), #000 36px, #000 calc(100% - 36px), rgba(0, 0, 0, .3)); }

/* ---- relations the map does not draw (map.omitted) ----------------------- */
.omitted { font-size: 15px; line-height: 1.5; color: var(--ink2); max-width: 80ch; margin-top: 8px; }
.omitted .omitted-head { font: 650 12px var(--f-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--ink2); }
.omitted ul { margin: 2px 0 0; padding-left: 18px; }
.omitted li { margin: 2px 0; }
.omitted .om-pair { font-family: var(--f-ui); font-weight: 600; font-stretch: 90%; color: var(--ink); }

/* ---- SVG common ------------------------------------------------------------ */
svg.map, svg.detail, svg.seq { display: block; width: 100%; height: auto; }
svg text { font-family: var(--f-ui); font-stretch: 88%; text-rendering: geometricPrecision; }
svg.map { min-width: 720px; }
svg.map.mini { min-width: 0; }
svg.detail { min-width: 720px; }
svg.seq { min-width: 820px; }
/* From a tablet's width up, the figures fit their frame (no sideways scroll);
   on a phone they keep a minimum width and scroll inside their frame. */
@media (min-width: 700px) { svg.map, svg.detail, svg.seq { min-width: 0; } }
/* On a wide, tall enough window the whole map fits in the first screen: its
   height is capped and the drawing is centred in its frame. */
@media (min-width: 1000px) and (min-height: 700px) {
  #map:not(.full) > svg.map { max-height: max(560px, calc(100vh - 300px)); }
}
/* "Full size": the figure at its natural size (1 viewBox unit = 1 CSS px);
   viewer.js sets the width, the frame scrolls. */
.sheet.full > svg { min-width: 0; max-width: none; }
svg.measure { position: absolute; left: -10000px; top: 0; width: 10px; height: 10px; visibility: hidden; pointer-events: none; }
.guide { stroke: var(--rule); stroke-width: 1; stroke-dasharray: 2 4; }
.t-axis { font-size: 12.5px; font-weight: 650; letter-spacing: .09em; fill: var(--ink2); text-transform: uppercase; }
.t-band { font-size: 12.5px; font-weight: 650; letter-spacing: .08em; fill: var(--ink3); }
.band-label .t-band { text-transform: uppercase; }
.t-title { font-size: 15px; font-weight: 650; fill: var(--ink); }
.t-sub { font-size: 12.5px; fill: var(--ink2); }
.t-lab { font-size: 12px; font-weight: 550; }
/* the map's smallest texts are 12.5 units, so that they stay above 7 px when
   the map is fitted to a 744-px window */
svg.map .t-lab { font-size: 12.5px; }
.t-note { font-family: var(--f-body); font-style: italic; font-size: 13px; fill: var(--ink2); font-stretch: 100%; }
.t-group { font-size: 12px; font-weight: 650; letter-spacing: .04em; fill: var(--ink3); }
.t-out { font-size: 12.5px; font-weight: 650; fill: var(--out); letter-spacing: .02em; font-stretch: 75%; }
.t-glyph { font-size: 15px; font-weight: 650; fill: var(--ink); }
.halo { paint-order: stroke; stroke: var(--sheet); stroke-width: 4px; stroke-linejoin: round; }
.mini .t-title { font-size: 30px; }

.ln { fill: none; stroke-linejoin: round; }
.ln.data { stroke: var(--data); stroke-width: 3.5; }
.ln.trigger { stroke: var(--trig); stroke-width: 2.25; stroke-dasharray: 7 4; }
.ln.timing { stroke: var(--time); stroke-width: 2.5; stroke-dasharray: 1.5 4.5; stroke-linecap: round; }
.ln.control { stroke: var(--ctrl); stroke-width: 2; stroke-dasharray: 9 3 2 3; }
.ln.monitoring { stroke: var(--mon); stroke-width: 2.25; stroke-dasharray: 9 3 2 3 2 3; }
.ln.out { stroke: var(--out); }
.mini .ln.data { stroke-width: 7; } .mini .ln.trigger, .mini .ln.timing, .mini .ln.monitoring { stroke-width: 5; } .mini .ln.control { stroke-width: 4.5; }
.mk.data { fill: var(--data); } .mk.trigger { fill: var(--trig); } .mk.timing { fill: var(--time); } .mk.control { fill: var(--ctrl); } .mk.monitoring { fill: var(--mon); } .mk.ink { fill: var(--ink2); } .mk.out { fill: var(--out); }
.lab.data { fill: var(--data); } .lab.trigger { fill: var(--trig); } .lab.timing { fill: var(--time); } .lab.control { fill: var(--ctrl); } .lab.monitoring { fill: var(--mon); } .lab.out { fill: var(--out); }
.port { fill: var(--sheet); stroke-width: 1.75; }
.port.data { stroke: var(--data); } .port.trigger { stroke: var(--trig); } .port.timing { stroke: var(--time); } .port.control { stroke: var(--ctrl); } .port.monitoring { stroke: var(--mon); }
.box rect.b { fill: var(--sheet); stroke: var(--ink); stroke-width: 1.25; }
.box .otag { fill: var(--outbg); stroke: var(--out); stroke-width: .75; }
.pick .box, .detail .box, .dgroup { cursor: pointer; }
.pick .box:hover rect.b, .detail .box:hover rect.b { stroke-width: 2.25; }
.box:focus, .dgroup:focus, .stub:focus, .row:focus { outline: none; }
.box:focus-visible rect.b { stroke: var(--data); stroke-width: 3; }
.box.hot rect.b { fill: var(--hot); stroke-width: 2.5; }
.ln, .port, .lab, .box { transition: opacity .25s; }
.dim { opacity: .12; }
.ln.focus.data { stroke-width: 5; } .ln.focus.trigger, .ln.focus.timing, .ln.focus.monitoring { stroke-width: 3.5; } .ln.focus.control { stroke-width: 3.25; }
.mini .ln.focus.data { stroke-width: 10; } .mini .ln.focus.trigger, .mini .ln.focus.timing, .mini .ln.focus.monitoring, .mini .ln.focus.control { stroke-width: 8; }
.ln.hot.data { stroke-width: 6; } .ln.hot.trigger, .ln.hot.timing, .ln.hot.monitoring, .ln.hot.control { stroke-width: 4; }
.callout rect.cbox { fill: none; stroke: var(--sel); stroke-width: 1.5; stroke-dasharray: 6 4; }
.callout rect.ctag { fill: var(--sel); }
.calltxt { fill: var(--sheet); font-size: 12.5px; font-weight: 700; letter-spacing: .08em; }

.tok { transition: transform .6s cubic-bezier(.45, 0, .2, 1), opacity .35s; }
.tok circle { stroke: var(--sheet); stroke-width: 2.5; }
.tok.b circle { fill: var(--data); } .tok.r circle { fill: var(--trig); } .tok.g circle { fill: var(--mon); } .tok.v circle { fill: var(--time); } .tok.k circle { fill: var(--data); }
.tok.s rect { fill: var(--ctrl); stroke: var(--sheet); stroke-width: 2.5; }
@media (prefers-reduced-motion: reduce) { .tok, .ln, .port, .lab, .box { transition: none; } }

/* ---- detail views -------------------------------------------------------- */
.dgroup rect.gbox { fill: none; stroke: var(--ink3); stroke-width: 1; stroke-dasharray: 4 3; }
.dgroup rect.gtitle { fill: var(--sheet); fill-opacity: .55; stroke: none; }
.dgroup:hover rect.gbox { stroke: var(--ink); stroke-width: 1.5; }
.dgroup:focus-visible rect.gbox { stroke: var(--data); stroke-width: 2.5; stroke-dasharray: none; }
.dgroup.hot rect.gtitle { fill: var(--hot); fill-opacity: 1; }
.dgroup.hot rect.gbox { stroke: var(--sel); stroke-width: 2; }
.stub { cursor: pointer; }
.stub rect.tag { fill: var(--sheet); stroke-width: 1.25; }
.stub:hover rect.tag { stroke-width: 2.25; }
.stub:focus-visible rect.tag { stroke-width: 3; }
.stub.data rect.tag { stroke: var(--data); } .stub.trigger rect.tag { stroke: var(--trig); } .stub.timing rect.tag { stroke: var(--time); } .stub.control rect.tag { stroke: var(--ctrl); } .stub.monitoring rect.tag { stroke: var(--mon); }
.stub .t-shead { font-size: 12px; font-weight: 700; }
.stub.data .t-shead { fill: var(--data); } .stub.trigger .t-shead { fill: var(--trig); } .stub.timing .t-shead { fill: var(--time); } .stub.control .t-shead { fill: var(--ctrl); } .stub.monitoring .t-shead { fill: var(--mon); }
.stub .t-slab { font-size: 12px; fill: var(--ink2); }

/* ---- cards: a head that stays in view, a body, an end ----------------------- */
.card { margin-top: 18px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 4px; }
/* (no overflow on .card or its ancestors: it would stop the head sticking) */
.card-head { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 3; display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; justify-content: space-between; padding: 8px var(--pad); background: var(--headbg); border-bottom: 1px solid var(--rule); border-radius: 4px 4px 0 0; box-shadow: 0 1px 0 var(--rule); }
.card-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 10px; min-width: 0; flex: 1 1 260px; }
.card-title .eyebrow { color: var(--ink3); }
.card-title h2 { font-size: 21px; line-height: 1.2; margin: 0; }
.card-title .otxt { align-self: center; }
.card-hint { font: 14px var(--f-ui); font-stretch: 92%; color: var(--ink2); }
/* a part's head: the part's title (its short name when a box inside it is
   open), then that box; nothing is cut short: a name that does not fit
   goes on to the next line */
#card-title, .card-node { min-width: 0; flex: 0 1 auto; overflow-wrap: break-word; }
.card-node { font: 600 17px/1.2 var(--f-ui); font-stretch: 88%; color: var(--ink2); }
/* the step card's head: "Step k of T" and its own Back and Next */
.step-count { font: 650 21px/1.2 var(--f-ui); font-stretch: 84%; white-space: nowrap; }
.card-nav { display: flex; flex-wrap: wrap; gap: 6px; }
.card-nav .btn { font-stretch: 90%; }
.btn-close { border-color: var(--ink3); color: var(--ink2); }
.card-body { padding: 12px var(--pad) 4px; }
.card-foot { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; padding: 10px var(--pad) 12px; margin-top: 10px; border-top: 1px dashed var(--rule); background: var(--headbg); border-radius: 0 0 4px 4px; font: 14px var(--f-ui); font-stretch: 92%; color: var(--ink2); }
.card-foot a { font-weight: 600; display: inline-flex; align-items: center; min-height: 32px; }
/* The spacer at the top of a card's body (viewer.js, keepPlace): when the
   card turns to new content while its top is above the window, the spacer
   takes that height, so that the new content starts right under the stuck
   head and the page does not move. Its box starts at the top of the body
   (over the body's 12px top padding) and its 12px bottom padding keeps the
   same gap above the content. Its note stays under the head while a reader
   scrolls back up through the blank. */
.card-spacer { box-sizing: content-box; margin-top: -12px; padding-bottom: 12px; }
.spacer-note { position: sticky; top: 8px; margin: 0; padding: 6px 0; font: 14px/1.4 var(--f-ui); font-stretch: 92%; color: var(--ink2); text-align: center; }
.spacer-note a { font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; min-height: 32px; }
/* the step card's end: the previous and the next step */
.foot-nav { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.foot-nav .btn { font-stretch: 90%; }

/* the overview (the card when no part is open) */
.overview .question { font-family: var(--f-ui); font-size: 20px; font-weight: 600; font-stretch: 90%; line-height: 1.35; color: var(--ink2); margin: 4px 0 10px; max-width: 60ch; }
.overview .read-map { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--rule); }
.overview .read-map h3 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; font-size: 19px; margin: 0 0 6px; }
.overview .read-map h3 .eyebrow { font-size: 12px; }

/* a part's detail runs to the card's edges, so that it keeps the page's width */
.card .detail-wrap { margin-inline: calc(-1 * var(--pad)); }
.card .detail-wrap .sheet { border-inline: 0; border-radius: 0; }
.card .dhead { padding-inline: var(--pad); }

/* ---- the node panel -------------------------------------------------------- */
.panel { margin-top: 10px; max-width: 80ch; font-size: 16px; line-height: 1.55; }
.panel .prose { max-width: none; }
.detail-title { font-size: 22px; line-height: 1.2; margin: 4px 0 4px; }
.detail-title:focus { outline: none; }
.detail-path { font: 14px var(--f-ui); color: var(--ink2); margin: 4px 0 10px; }
.panel h3 { font-size: 17px; margin: 0; }
.panel h4 { font-size: 15px; }
.summary { font-weight: 600; }
.otxt, .badge-outside { font: 650 11px var(--f-ui); letter-spacing: .05em; color: var(--out); background: var(--outbg); border: 1px solid var(--out); border-radius: 3px; padding: 1px 6px; vertical-align: 2px; white-space: nowrap; }
.otxt { margin-left: 6px; }
.outside-note { background: var(--outbg); border: 1px solid var(--out); border-radius: 4px; padding: 8px 12px; font-size: 14px; }
.badge { font: 600 11px var(--f-ui); letter-spacing: .03em; line-height: 1.4; padding: 1px 6px; border-radius: 3px; border: 1px solid var(--rule); color: var(--ink2); white-space: nowrap; vertical-align: 1px; }
.decision-card { border-left: 3px solid var(--rule); padding: 2px 0 2px 12px; margin: 10px 0 14px; }
.decision-label { font: 650 11.5px var(--f-ui); text-transform: uppercase; letter-spacing: .08em; color: var(--ink2); }
.ref-list { padding-left: 18px; margin: 4px 0; font-size: 15px; }
.ref-list li { margin: 5px 0; }
.ref-list.compact { font-size: 14px; }
.ref-note { display: block; font-size: 14px; color: var(--ink2); }
.flow-heading { color: var(--ink2); }
/* folded sections: one line each until opened */
details.fold { border-top: 1px solid var(--rule); }
details.fold:first-of-type { margin-top: 16px; }
details.fold:last-of-type { border-bottom: 1px solid var(--rule); }
details.fold > summary { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 0; cursor: pointer; list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "\25B8"; font: 13px var(--f-ui); color: var(--ink2); width: 12px; flex: none; transition: transform .15s; }
details.fold[open] > summary::before { transform: rotate(90deg); }
details.fold > summary:focus-visible { outline: 2px solid var(--data); outline-offset: 2px; }
details.fold > summary h3 { display: inline; margin: 0; padding: 0; border: 0; font-size: 17px; }
details.fold[open] { padding-bottom: 8px; }
.fold-count { display: inline-block; padding: 0 7px; border: 1px solid var(--rule); border-radius: 999px; font: 600 12px/1.6 var(--f-ui); color: var(--ink2); font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { details.fold > summary::before, .mode-note summary::before { transition: none; } }
.flow-list { list-style: none; padding: 0; margin: 4px 0; }
.flow { border-left: 3px solid var(--rule); padding: 2px 0 2px 10px; margin: 8px 0; font-size: 15px; }
.flow.kind-data { border-color: var(--data); } .flow.kind-trigger { border-color: var(--trig); } .flow.kind-timing { border-color: var(--time); } .flow.kind-control { border-color: var(--ctrl); } .flow.kind-monitoring { border-color: var(--mon); }
.badge-kind.kind-data { color: var(--data); border-color: var(--data); } .badge-kind.kind-trigger { color: var(--trig); border-color: var(--trig); } .badge-kind.kind-timing { color: var(--time); border-color: var(--time); } .badge-kind.kind-control { color: var(--ctrl); border-color: var(--ctrl); } .badge-kind.kind-monitoring { color: var(--mon); border-color: var(--mon); }
.flow-where, .flow-dir, .flow-key { color: var(--ink2); }
.flow-end { font-weight: 600; }
.flow-label, .flow-inside { font-size: 14px; margin-top: 2px; }
.flow-prose { font-size: 14px; margin-top: 2px; }
.flow-prose p { margin: 0 0 .4em; }

/* ---- the tour: its bar under the map and its card ---------------------------- */
.tourbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.pips { display: flex; flex-wrap: wrap; gap: 4px; }
.pip { font: 600 12px var(--f-ui); width: 32px; height: 32px; padding: 0; border: 1px solid var(--rule); background: var(--sheet); color: var(--ink2); border-radius: 50%; cursor: pointer; font-variant-numeric: tabular-nums; }
.pip[aria-current="step"] { background: var(--ink); color: var(--sheet); border-color: var(--ink); }
.step-text h2 { font-size: 22px; margin: 2px 0 8px; }
.step-text .prose { font-size: 16.5px; max-width: 80ch; }
.step-refs details.fold:first-of-type { margin-top: 4px; }
.step-node { margin-top: 14px; padding: 8px 12px; border-left: 3px solid var(--ink); background: var(--headbg); max-width: 80ch; font-size: 15.5px; line-height: 1.5; }
.step-node .pt, .step-pick .pt { font: 650 16px var(--f-ui); font-stretch: 90%; display: block; margin-bottom: 2px; }
.step-node p, .step-pick p { margin: 0; }
.step-pick { margin-top: 10px; padding: 8px 12px; border-left: 3px solid var(--rule); max-width: 80ch; font-size: 15.5px; line-height: 1.5; }
.where-label { margin: 16px 0 6px; padding-top: 12px; border-top: 1px solid var(--rule); color: var(--ink3); }

/* ---- small multiples ---------------------------------------------------------- */
.mult-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.mult-grid figure { margin: 0; min-width: 0; cursor: pointer; border-radius: 4px; }
.mult-grid .sheet { padding: 8px; }
.mult-grid figcaption { font-size: 14.5px; margin-top: 6px; }
.mult-grid figure:hover .sheet { border-color: var(--ink); }
.mult-grid figure:focus { outline: none; }
.mult-grid figure:focus-visible .sheet { outline: 2px solid var(--data); outline-offset: 2px; }
@media (max-width: 400px) { .mult-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---- sequence ----------------------------------------------------------------- */
.seq .life { stroke: var(--ink3); stroke-width: 1; stroke-dasharray: 3 4; }
.seq .hdr rect { fill: var(--sheet); stroke: var(--ink); stroke-width: 1.25; }
.seq .hdr.out rect { stroke: var(--out); stroke-dasharray: 4 2; }
.seq .row { cursor: pointer; }
.seq .row .hit { fill: transparent; }
.seq .row:hover .hit { fill: var(--grid); }
.seq .row:focus-visible .hit { stroke: var(--data); stroke-width: 2; }
.seq .row.cur .hit { fill: var(--hot); }
.seq .num { fill: var(--ink); font-size: 12px; font-weight: 700; }
.seq .numc { fill: var(--sheet); stroke: var(--ink); stroke-width: 1.25; }
.seq .row.cur .numc { fill: var(--ink); }
.seq .row.cur .num { fill: var(--sheet); }
.seq .dot { stroke: none; }
.dot.data { fill: var(--data); } .dot.trigger { fill: var(--trig); } .dot.timing { fill: var(--time); } .dot.control { fill: var(--ctrl); } .dot.monitoring { fill: var(--mon); }

/* ---- the reference divider and the matrix card -------------------------------- */
.ref-divider { display: flex; align-items: center; gap: 12px; margin-top: 64px; font: 650 12px var(--f-ui); letter-spacing: .14em; text-transform: uppercase; color: var(--ink3); }
.ref-divider::before, .ref-divider::after { content: ""; flex: 1; border-top: 1px solid var(--rule); }
.ref-card { margin-top: 20px; }
.ref-card .card-head { justify-content: flex-start; }
.matrix-intro .prose { margin: 0; max-width: 72ch; }
/* the table runs to the card's edges, so that it keeps the page's width */
.ref-card .card-body { padding-inline: 0; padding-bottom: 0; }
.ref-card .matrix-intro { padding-inline: var(--pad); }
.ref-card .figbar { padding-inline: var(--pad); margin: 0 0 6px; }
.ref-card .card-foot { margin-top: 0; }

.tbl { overflow-x: auto; margin-top: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 15px; line-height: 1.45; background: var(--sheet); }
th, td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid var(--rule); }
th { font: 650 12px var(--f-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--ink2); background: var(--paper); }
td:first-child { font-family: var(--f-ui); font-weight: 600; font-stretch: 90%; }
table.nsq { min-width: 980px; font-size: 13.5px; border-top: 1px solid var(--rule); }
table.nsq th { white-space: nowrap; }
table.nsq td { padding: 8px 9px; min-width: 110px; }
table.nsq td.diag { background: var(--paper); color: var(--ink3); text-align: center; }
table.nsq td.ctl { background: color-mix(in srgb, var(--ctrl) 7%, var(--sheet)); }
table.nsq .ni { display: flex; gap: 6px; align-items: baseline; font-family: var(--f-ui); font-stretch: 90%; line-height: 1.3; margin: 2px 0; }
table.nsq .ni svg { flex: none; width: 22px; height: 8px; overflow: visible; }
table.nsq .ni .ln { stroke-width: 2.5; }
/* the row headers (the sending part) stay in view while the table scrolls */
table.nsq tr > :first-child { position: sticky; left: 0; z-index: 1; background: var(--sheet); box-shadow: inset -1px 0 0 var(--rule); }
table.nsq thead tr > :first-child { background: var(--paper); }
/* Up to a tablet's width the matrix fits the card: narrow columns whose
   texts wrap (and hyphenate where a word is longer than its column). At a
   phone's width it still scrolls sideways inside its frame. */
@media (max-width: 1100px) {
  table.nsq { min-width: 0; table-layout: fixed; font-size: 12.5px; }
  table.nsq th { white-space: normal; padding: 6px 4px; font-size: 12px; letter-spacing: 0; text-transform: none; font-stretch: 85%; line-height: 1.2; hyphens: auto; -webkit-hyphens: auto; }
  table.nsq td { padding: 6px 4px; min-width: 0; hyphens: auto; -webkit-hyphens: auto; overflow-wrap: break-word; }
  table.nsq tr > :first-child { width: 11%; padding-left: 8px; }
  /* the line sample stays on the first line of its label; the label's
     further lines are indented under its start */
  table.nsq .ni { gap: 3px; margin: 3px 0; font-stretch: 85%; }
  table.nsq .ni svg { width: 13px; }
}
@media (max-width: 600px) { table.nsq { min-width: 600px; } }
/* the key under the matrix: what the shading means */
/* (on the sheet colour, as the cells are, so the swatches look like them) */
.nsq-key { font: 14px/1.5 var(--f-ui); font-stretch: 90%; color: var(--ink2); margin: 0; padding: 6px var(--pad); background: var(--sheet); }
.nsq-key .sw { display: inline-block; width: 22px; height: 15px; margin: 0 6px 0 0; vertical-align: -3px; border: 1px solid var(--rule); font-size: 11px; line-height: 13px; text-align: center; color: var(--ink3); }
.nsq-key .sw.ctl { background: color-mix(in srgb, var(--ctrl) 7%, var(--sheet)); }
.nsq-key .sw.diag { background: var(--paper); margin-left: 4px; }

/* ---- one-page view ------------------------------------------------------------- */
.read-page { margin-top: 28px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 4px; padding: 14px clamp(16px, 4vw, 40px) 40px; font-size: 16.5px; }
.read-page .prose { max-width: 72ch; }
.read-page .question { font-family: var(--f-ui); font-size: 20px; font-weight: 600; font-stretch: 90%; line-height: 1.35; color: var(--ink2); }
.read-note { font: 14px var(--f-ui); color: var(--ink2); }
.read-toc ol { columns: 2 220px; font-family: var(--f-ui); }
.read-node { border-top: 1px solid var(--rule); margin-top: 18px; padding-top: 4px; }
.read-node.depth-1 { border-top: 3px solid var(--ink); margin-top: 34px; }
.read-node.depth-2, .read-node.depth-3, .read-node.depth-4 { margin-left: 14px; }
.read-node .read-title { margin: 10px 0 2px; }
.read-node.depth-1 > .read-title { font-size: 26px; }
.read-node.depth-2 > .read-title { font-size: 20px; }
.read-node.depth-3 > .read-title { font-size: 17px; }
.read-path { font: 14px var(--f-ui); color: var(--ink2); margin: 0 0 8px; }
.read-node h3, .read-node h4, .read-node h5, .read-node h6 { font-size: 16px; margin: 14px 0 4px; }
.read-tour { border-top: 3px solid var(--ink); margin-top: 34px; }
.read-steps > li { margin: 10px 0 18px; }
.read-steps h3 { font-size: 17px; margin: 4px 0; }

/* ---- narrow screens ------------------------------------------------------------ */
@media (max-width: 600px) {
  body { font-size: 16px; }
  .wrap { padding-inline: 16px; }
  h2 { font-size: 23px; }
  .help { padding: 12px 14px; }
  .card-title h2, .step-count { font-size: 19px; }
}

/* lines, labels and ports are not click targets (boxes, groups and tags are) */
svg.map .ln, svg.map .port, svg.map .lab, svg.map .t-note, svg.detail .ln, svg.detail .lab { pointer-events: none; }
