/* Shared page styles: the front page's server-rendered parts, channel pages and project pages.
   The scope screen itself is styled in scope.css. Colours come only from tokens.css. */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--page); color: var(--pagetext); font-family: var(--sans); }
body { line-height: 1.5; }
a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
img { max-width: 100%; height: auto; }

.skip { position: absolute; left: 8px; top: -40px; background: var(--btn); color: var(--btntext);
        border: 1px solid var(--btnedge); border-radius: 6px; padding: 6px 10px; z-index: 10; }
.skip:focus { top: 8px; }

main { max-width: 1100px; margin: 0 auto; padding: 28px 16px 8px; }

/* Type roles: serif for the headline only, mono for instrument readouts, sans for content. */
.head { font-family: var(--serif); font-size: 20px; font-weight: 400; margin: 0; }
.sub { color: var(--paneldim); font-size: 13px; margin: 4px 0 0; }
/* One kicker style for every small section label. */
.k, .kicker { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
              color: var(--paneldim); margin: 0; }

/* Channel colour: one token per channel, set from data-channel (inline styles are blocked by the CSP). */
.tag { font-family: var(--mono); font-size: 12px; color: var(--paneldim); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--cc, var(--dig)); }
.dot.dg { background: var(--dig); border-radius: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.lbl { display: inline-block; font: 600 10px/1 var(--sans); letter-spacing: .06em; text-transform: uppercase;
       color: var(--paneldim); border: 1px solid currentColor; border-radius: 3px; padding: 2px 4px; }

/* Front page, before the scope script runs (and all of it without JavaScript). */
.intro { margin-bottom: 12px; }
.scope { display: flex; flex-direction: column; gap: 10px; }
.strip { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: var(--panel);
         border-radius: 10px; padding: 8px 10px; color: var(--btntext); }
.chb { font: 12px var(--sans); white-space: nowrap; color: var(--btntext); background: var(--btn);
       border: 1px solid var(--cc, var(--btnedge)); border-radius: 6px; padding: 5px 9px; text-decoration: none; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; row-gap: 2px; align-content: start;
        color: var(--pagetext); text-decoration: none; border: 1px solid var(--grid);
        border-left: 3px solid var(--cc, var(--grid)); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.tile img { grid-column: 1 / -1; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 6px; margin-bottom: 6px; }
.tile .ttl { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.tile .dt { grid-column: 2; font-size: 13px; color: var(--paneldim); }
.tile:hover .ttl { text-decoration: underline; }
.now { font-size: 13px; color: var(--paneldim); margin: 12px 4px 0; }

/* The All projects list, and the project lists on channel pages. */
.all { margin: 24px 0 64px; }
.all h2 { font-size: 18px; font-weight: 500; }
.year, .older summary { font: 12px var(--mono); text-transform: uppercase; letter-spacing: .08em;
                        color: var(--paneldim); margin: 18px 0 4px; }
.older summary { cursor: pointer; }
.rows { list-style: none; padding: 0; margin: 0; }
.row { display: grid; grid-template-columns: 10px 2.6em minmax(0, 17em) 9em minmax(0, 1fr); gap: 4px 12px;
       padding: 10px 0; border-bottom: 1px solid var(--grid); font-size: 14px; align-items: baseline; }
.row .lbl { justify-self: start; }
.row .dt, .row .kinds { font-size: 13px; color: var(--paneldim); }
.find input { font: inherit; color: var(--btntext); background: var(--btn); border: 1px solid var(--btnedge);
              border-radius: 6px; padding: 4px 8px; }

/* Project, part and channel pages. */
.crumbs { font-size: 13px; color: var(--paneldim); margin-bottom: 16px; }
.phead h1 { font-size: 28px; line-height: 1.2; margin: 6px 0 4px; }
.lede { font-size: 17px; margin: 0 0 16px; max-width: 46em; }
.hero { margin: 0 0 24px; }
.hero img { width: 100%; max-height: 70vh; object-fit: cover; border-radius: 10px; }
.pbody { display: grid; grid-template-columns: 14rem minmax(0, 1fr); gap: 32px; align-items: start; }
.toc { position: sticky; top: 16px; font-size: 14px; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--grid); }
.toc li a { display: block; padding: 3px 12px; text-decoration: none; color: var(--paneldim); }
.toc li a:hover { color: var(--pagetext); text-decoration: underline; }
.prose { max-width: 46em; }
.prose h2 { font-size: 20px; margin: 28px 0 8px; }
.prose h2:first-child { margin-top: 0; }
.fig { margin: 16px 0; }
.fig img { border-radius: 8px; max-height: 70vh; width: auto; }
.prose table { border-collapse: collapse; margin: 12px 0 16px; font-size: 14px; }
.prose th, .prose td { text-align: left; vertical-align: top; padding: 5px 16px 5px 0; border-bottom: 1px solid var(--grid); }
.fig figcaption { font-size: 13px; color: var(--paneldim); margin-top: 4px; }
/* Charts from tools/make_charts.py: each colour is a class, so they follow the theme. */
.chartfig { background: var(--screen); border-radius: 12px; padding: 12px 14px 10px; max-width: 548px; }
.chartbox { max-width: 520px; }
.chart { display: block; width: 100%; height: auto; font-family: var(--sans); }
.chart .s-grid { stroke: var(--grid); }
.chart .f-trace { fill: var(--trace); }   .chart .s-trace { stroke: var(--trace); }
.chart .f-fg { fill: var(--pagetext); }   .chart .s-fg { stroke: var(--pagetext); }
.chart .f-dim { fill: var(--paneldim); }  .chart .s-dim { stroke: var(--paneldim); }
.chart .f-c5 { fill: var(--c5); }         .chart .s-c5 { stroke: var(--c5); }
.chart .f-c4 { fill: var(--c4); }         .chart .s-c4 { stroke: var(--c4); }
.chart .f-c2 { fill: var(--c2); }         .chart .s-c2 { stroke: var(--c2); }
.chart .f-c3 { fill: var(--c3); }         .chart .s-c3 { stroke: var(--c3); }
@media (forced-colors: active) {
  .chart [class*="f-"] { fill: CanvasText; }
  .chart [class*="s-"] { stroke: CanvasText; }
  .chart .s-grid { stroke: GrayText; }
  .chartfig { border: 1px solid CanvasText; }
}
.skills { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.skills li { background: var(--tagbg); color: var(--zdim); border-radius: 4px; padding: 2px 8px; font-size: 13px; }
.proof { list-style: none; padding: 0; }
.proof li { padding: 4px 0; }
.proof .kind { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
               color: var(--zdim); background: var(--tagbg); border-radius: 4px; padding: 1px 6px; margin-right: 6px; }
.proof .req { font-size: 12px; color: var(--paneldim); }
.parts li { margin: 4px 0; }
.next { margin: 32px 0 0; padding-top: 12px; border-top: 1px solid var(--grid); }
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 0 0 20px; }
.figures div { background: var(--panel); border-left: 3px solid var(--cc, var(--dim)); border-radius: 0 4px 4px 0;
               padding: 6px 10px; min-width: 0; }
.figures dt { font: 11px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--paneldim); }
.figures dd { margin: 0; font-family: var(--mono); color: var(--btntext); overflow-wrap: anywhere; }
.empty { color: var(--paneldim); }

/* Panel layout (front matter panel = true): a header with a readout screen, two short cards, figures
   two to a row, support matrices, stat tiles and folded detail. Body text stays sans at its usual size;
   mono and glow are only for labels and readout numbers. */
.panelhead { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: stretch;
             background: var(--panel); border: 1px solid var(--grid); border-radius: 14px; padding: 12px; margin-bottom: 16px; }
.panelhead .pttl { padding: 4px 6px; min-width: 0; }
.panelhead h1 { font-size: 28px; line-height: 1.2; margin: 6px 0 4px; }
.panelhead .lede { margin: 0; }
.lcd { width: 380px; margin: 0; background: var(--screen); border-radius: 8px; padding: 12px;
       display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; align-content: center;
       background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
       background-size: 38px 38px; }
.lcd .ro, .stiles div { display: flex; flex-direction: column-reverse; justify-content: flex-end; min-width: 0; }
.lcd dd, .stiles dd { margin: 0; font: 600 24px/1.15 var(--mono); color: var(--text); text-shadow: var(--glow); overflow-wrap: anywhere; }
.lcd dt { font: 11px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--dim); }
.duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0 0 24px; }
.pcard { border: 1px solid var(--grid); border-left: 3px solid var(--cc, var(--grid)); border-radius: 10px; padding: 12px 14px; }
.pcard h2 { margin: 0; font-weight: 400; }
.pcard p { margin: 4px 0 0; }
.panel .prose { max-width: none; display: flex; flex-wrap: wrap; column-gap: 16px; align-items: flex-start; }
.panel .prose > * { flex: 1 1 100%; min-width: 0; }
.panel .prose > :is(p, ul, ol, h2, h3, table) { max-width: 46em; }
.panel .prose > p { margin: 0 0 1em; }
.panel .prose > .fig { flex: 0 1 calc(50% - 8px); max-width: none; margin: 4px 0 16px; }  /* charts and photos, two to a row */
.panel .chartbox { max-width: none; }
.mx { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 12px; margin: 4px 0 0; }
.mcard { background: var(--panel); border: 1px solid var(--grid); border-top: 3px solid var(--cc, var(--grid));
         border-radius: 12px; padding: 12px 14px; min-width: 0; }
.mcard h3 { margin: 0 0 8px; font-size: 15px; }
.mcard table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 0; }
.mcard th, .mcard td { padding: 6px 4px; border: 0; border-top: 1px solid var(--page); vertical-align: top; overflow-wrap: break-word; }
.mcard td { min-width: 5.5em; }
.mcard thead th { border-top: 0; font: 11px var(--mono); color: var(--paneldim); text-align: center; padding-top: 0; white-space: nowrap; }
.mcard thead th:first-child, .mcard tbody th { text-align: left; font-weight: 400; }
.mcard td { text-align: center; }
.mnote { font-size: 13px; color: var(--paneldim); margin: 8px 0 0; }
.dot-on, .dot-off { display: inline-block; width: 11px; height: 11px; border-radius: 50%; vertical-align: -1px; }
.dot-on { background: var(--cc, var(--trace)); box-shadow: var(--glow); }
.dot-off { border: 1.5px solid var(--paneldim); }
.na { color: var(--paneldim); }
.mxkey { font-size: 13px; color: var(--paneldim); margin: 8px 0 20px; }
.mxkey .dot-on, .mxkey .dot-off, .mxkey .na { margin-left: 10px; }
.mxkey .dot-on:first-child { margin-left: 0; }
.stiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 10px; margin: 4px 0 16px; }
.stiles div { background: var(--screen); border: 1px solid var(--grid); border-radius: 10px; padding: 10px 12px; }
.stiles dt { font-size: 13px; color: var(--paneldim); }
.prose details.fold { margin: 0 0 8px; }
.prose details.fold > summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between;
                                align-items: baseline; gap: 12px; background: var(--panel); border: 1px solid var(--grid);
                                border-radius: 8px; padding: 10px 14px; }
.prose details.fold > summary::-webkit-details-marker { display: none; }
.prose details.fold > summary::after { content: "+"; font: 16px var(--mono); color: var(--paneldim); }
.prose details.fold[open] > summary::after { content: "−"; }
.prose details.fold > summary h2 { display: inline; font-size: 16px; font-weight: 600; margin: 0; }
.prose details.fold > :not(summary) { max-width: 46em; margin-left: 14px; margin-right: 14px; }
@media (max-width: 820px) {
  .panelhead, .duo { grid-template-columns: minmax(0, 1fr); }
  .lcd { width: auto; }
  .panel .prose > .fig { flex-basis: 100%; }
  .stiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* On a phone a chart keeps enough width for its text to read (10 px or more) and scrolls inside its box;
   the page itself never scrolls sideways. Matrix cells give up their minimum width. */
@media (max-width: 560px) {
  .chartbox { overflow-x: auto; }
  .chartbox > .chart { min-width: 480px; }
  .mcard td { min-width: 0; }
  .mcard tbody th { overflow-wrap: anywhere; }
}
@media (forced-colors: active) {
  .panelhead, .lcd, .pcard, .mcard, .stiles div, .prose details.fold > summary { border: 1px solid CanvasText; }
  .dot-on { forced-color-adjust: none; background: CanvasText; box-shadow: none; }
  .dot-off { border-color: CanvasText; }
}

.foot { max-width: 1100px; margin: 0 auto; padding: 16px 16px 40px; font-size: 13px; color: var(--paneldim); }

@media (max-width: 820px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row { grid-template-columns: 10px auto minmax(0, 1fr); }
  .row .dt, .row .kinds { grid-column: 3; }
  .pbody { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .toc { position: static; }
  .toc ul { display: flex; flex-wrap: wrap; gap: 4px 0; border-left: 0; }
  .toc li a { padding: 2px 10px 2px 0; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .tiles, .figures { grid-template-columns: minmax(0, 1fr); }
}
@media (forced-colors: active) {
  .tile, .chb, .figures div { border: 1px solid CanvasText; }
  .dot { forced-color-adjust: none; background: CanvasText; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* Work-in-progress sign (templates/components/wip.html). A crash plays once, then SERVICE MODE stays.
   Layers switch with visibility, like a scope screen, never by fading. With no animation (reduced
   motion, high contrast, forced colours, or no CSS animation at all) the checklist is what shows.
   Every animation has ended by 4.9 s (WCAG 2.2.2). Times: trace 0-1.0 s, glitch 1.0-1.5 s, signal lost
   1.5-2.1 s, self-calibration 2.1-3.4 s, then SERVICE MODE with the trigger armed; WAIT pulses three
   times and holds at 4.9 s. */
.wip-sign { max-width: 520px; margin: 0 0 24px; display: grid; gap: 8px; }
.wip-scr { background: var(--bezel); padding: 6px; border-radius: 8px; }
.wip-svg { display: block; width: 100%; height: auto; background: var(--screen); border-radius: 4px; }
.wip-svg text { font: 10px var(--mono); fill: var(--text); }
.wip-svg .wip-s, .wip-svg .wip-n, .wip-svg .wip-st { text-anchor: end; }
.wip-svg .wip-m { font-size: 12px; font-weight: 500; letter-spacing: .08em; text-anchor: middle; }
.wip-svg .wip-h { font-weight: 500; }
.wip-svg .wip-lost, .wip-svg .wip-s-fault, .wip-svg .wip-s-cal, .wip-svg .wip-st.wait { fill: var(--accent); }
.wip-gl { fill: none; stroke: var(--grid); stroke-width: 1; }
.wip-dots { fill: none; stroke: var(--dim); stroke-width: 1; stroke-dasharray: 1 4; }
.wip-tr { fill: none; stroke: var(--trace); stroke-width: 1.6; stroke-linejoin: round; }
.wip-bad { stroke: var(--accent); }
.wip-frame { fill: none; stroke: var(--dim); stroke-width: 1; }
.wip-bar { fill: var(--trace); transform-box: fill-box; transform-origin: left center; }
.wip-cur { fill: var(--accent); }
.wip-svg .wip-armed { fill: var(--dim); text-anchor: middle; }
.wip-svg .wip-t { fill: var(--accent); }
.wip-trig { fill: none; stroke: var(--accent); stroke-width: 1; stroke-dasharray: 4 3; }
.wip-note { margin: 0; font-size: 15px; }
.lbl.wip { color: var(--accent); }

.wip-crash { visibility: hidden; animation: wip-crash 4.9s both; }
.wip-list { animation: wip-list 4.9s both; }
.wip-run { animation: wip-run 4.9s both, wip-scroll 1s linear both; }
.wip-bad { animation: wip-bad 4.9s both, wip-jolt .5s steps(1) 1s both; }
.wip-flat { animation: wip-flat 4.9s both; }
.wip-lost { animation: wip-lost 4.9s both; }
.wip-cal, .wip-svg .wip-s-cal { animation: wip-cal 4.9s both; }
.wip-bar { animation: wip-fill 4.9s linear both; }
.wip-svg .wip-s-run { animation: wip-run 4.9s both; }
.wip-svg .wip-s-fault { animation: wip-fault 4.9s both; }
.wip-svg .wip-st.wait, .wip-cur { animation: wip-pulse 4.9s both; }
@keyframes wip-crash { 0%, 69.3% { visibility: visible; } 69.4%, 100% { visibility: hidden; } }
@keyframes wip-list { 0%, 69.3% { visibility: hidden; } 69.4%, 100% { visibility: visible; } }
@keyframes wip-run { 0%, 20.3% { visibility: visible; } 20.4%, 100% { visibility: hidden; } }
@keyframes wip-scroll { from { transform: translateX(0); } to { transform: translateX(-80px); } }
@keyframes wip-bad { 0%, 20.3% { visibility: hidden; } 20.4%, 30.5% { visibility: visible; } 30.6%, 100% { visibility: hidden; } }
@keyframes wip-jolt { 0%, 49% { transform: translate(0, 0); } 50%, 100% { transform: translate(-5px, 3px); } }
@keyframes wip-flat { 0%, 30.5% { visibility: hidden; } 30.6%, 69.3% { visibility: visible; } 69.4%, 100% { visibility: hidden; } }
@keyframes wip-lost { 0%, 30.5% { visibility: hidden; } 30.6%, 42.8% { visibility: visible; } 42.9%, 100% { visibility: hidden; } }
@keyframes wip-fault { 0%, 20.3% { visibility: hidden; } 20.4%, 42.8% { visibility: visible; } 42.9%, 100% { visibility: hidden; } }
@keyframes wip-cal { 0%, 42.8% { visibility: hidden; } 42.9%, 69.3% { visibility: visible; } 69.4%, 100% { visibility: hidden; } }
@keyframes wip-fill { 0%, 42.9% { transform: scaleX(0); } 67%, 100% { transform: scaleX(1); } }
/* WAIT and its cursor pulse three times by colour (no fading), then hold the accent. */
@keyframes wip-pulse { 0%, 69.4% { fill: var(--accent); } 74.5% { fill: var(--dim); } 79.6% { fill: var(--accent); }
  84.7% { fill: var(--dim); } 89.8% { fill: var(--accent); } 94.9% { fill: var(--dim); } 100% { fill: var(--accent); } }

/* No crash: the checklist from the start. */
@media (prefers-reduced-motion: reduce) { .wip-crash { display: none; } .wip-sign * { animation: none !important; } }
html[data-style=hc] .wip-crash { display: none; }
html[data-style=hc] .wip-sign * { animation: none !important; }
@media (prefers-contrast: more) {
  html:not([data-style]) .wip-crash { display: none; }
  html:not([data-style]) .wip-sign * { animation: none !important; }
}
@media (forced-colors: active) {
  .wip-crash { display: none; }
  .wip-sign * { animation: none !important; }
  .wip-scr { border: 1px solid CanvasText; }
  .wip-svg { background: Canvas; }
  .wip-svg text, .wip-svg .wip-st.wait, .wip-cur { fill: CanvasText; }
  .wip-gl, .wip-dots, .wip-trig, .wip-tr { stroke: CanvasText; }
  .wip-svg .wip-armed, .wip-svg .wip-t { fill: CanvasText; }
}

/* Profile cards under the front-page headline (data/site.toml [[profiles]]). Text sits on the page colour,
   so the contrast pairs pagetext/page and paneldim/page cover it. */
.profiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 14px 0 0; }
.pcard { display: grid; gap: 2px; align-content: start; min-width: 0; padding: 10px 12px; border: 1px solid var(--bezel);
         border-radius: 8px; color: var(--pagetext); text-decoration: none; }
.pcard:hover { border-color: var(--accent); }
.pcard:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pcard .pn { font-weight: 700; font-size: 14px; }
.pcard .ph { font: 11px var(--mono); color: var(--paneldim); overflow-wrap: anywhere; }
.pcard .pl { font-size: 13px; color: var(--paneldim); }
@media (max-width: 820px) { .profiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (forced-colors: active) { .pcard { border-color: CanvasText; } }
/* The "Try it" card after the Now line, styled like a profile card. */
.pcard.tryit { max-width: 360px; margin: 10px 0 0; }
/* Logos on the cards (templates/components/icons.html): the card's text colour, sized to the name. */
.pico { width: 15px; height: 15px; margin-right: 6px; vertical-align: -2px; fill: currentColor; flex: none; }
.pico-line { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
