/* Last updated: 2026-10-24 -- design system for ionospherelabs.com: tokens for both themes, type, shell, components. */

/* 1. Tokens. Dark is the default; light overrides under html[data-theme="light"].
   --line and --hair are decorative; anything that marks a control or a table edge uses --line-strong (3:1). */
:root {
    color-scheme: dark;
    --bg: #0f1117;
    --surface: #161a24;
    --card: #171b26;
    --fg: #f3f2ec;
    --mute: #9aa1ae;
    --line: #2b3140;
    --line-strong: #5c6680;
    --hair: #1e2330;
    --blue: #5b8de6;
    --orange: #f28c28;
    --red: #d9432f;
    --button-red: #c93622;
    --red-text: #e8503b;
    --link: #7aa2ec;
    --focus: #5b8de6;
    --stage-fg: #f3f2ec;
    --stage-mute: #9aa1ae;
    --stage-orange: #f28c28;
    --stage-chip-bg: rgba(0, 0, 0, .72);
    --shadow: none;
    --serif: "IBM Plex Serif", Georgia, "Times New Roman", serif;
    --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    --shell: 1080px;
    --gutter: 16px;
    --section: 40px;
}
html[data-theme="light"] {
    color-scheme: light;
    --bg: #f6f1e7;
    --surface: #fffdf8;
    --card: #efe8dc;
    --fg: #1b1f2a;
    --mute: #5b6472;
    --line: #d8d0c2;
    --line-strong: #7f7566;
    --hair: #e6dfd2;
    --blue: #2f63c9;
    --orange: #a5520b;
    --red: #b52a19;
    --button-red: #b52a19;
    --red-text: #b52a19;
    --link: #2f63c9;
    --focus: #2f63c9;
    --stage-fg: #f3f2ec;
    --stage-mute: #9aa1ae;
    --stage-orange: #f28c28;
    --stage-chip-bg: rgba(0, 0, 0, .72);
    --shadow: 0 1px 2px rgba(27, 31, 42, .06), 0 4px 12px rgba(27, 31, 42, .05);
}
@media (min-width: 640px) { :root { --gutter: 24px; --section: 48px; } }
@media (min-width: 960px) { :root { --gutter: 32px; --section: 64px; } }

/* 2. Base and type */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
@media (min-width: 640px) { html { font-size: 17px; } }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--sans); line-height: 1.6; }
a { color: var(--link); text-underline-offset: .15em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
main { display: block; padding-top: 24px; }
@media (min-width: 640px) { main { padding-top: 32px; } }
main:focus { outline: none; }
h1, h2 { font-family: var(--serif); font-weight: 600; margin: 0 0 .5em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); line-height: 1.15; }
h2 { font-size: clamp(1.35rem, 1.1rem + .8vw, 1.6rem); line-height: 1.25; margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); }
@media (min-width: 640px) { h2 { margin-top: 40px; } }
h2:first-child, .kicker + h2, .card h2, .box h2, .hero h2 { border-top: 0; padding-top: 0; margin-top: 0; }
section > .kicker:first-child { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 32px; }
@media (min-width: 640px) { section > .kicker:first-child { margin-top: 40px; } }
h3 { font-family: var(--sans); font-size: 1.125rem; font-weight: 600; line-height: 1.35; margin: 24px 0 .4em; }
h4 { font-family: var(--sans); font-size: 1rem; font-weight: 600; margin: 16px 0 .3em; }
p, ul, ol, dl { margin: 0 0 16px; }
li { margin-bottom: 4px; }
.lede { font-size: 1.125rem; line-height: 1.5; color: var(--mute); max-width: 60ch; }
.kicker { font-family: var(--sans); font-size: .75rem; font-weight: 600; line-height: 1.2; letter-spacing: .1em; text-transform: uppercase; color: var(--orange); margin: 0 0 8px; }
small, .small, .meta { font-size: .875rem; line-height: 1.5; }
.small { color: var(--mute); }
.meta { color: var(--mute); }
code, kbd, .hash { font-family: var(--mono); font-size: .9em; }
code { background: var(--card); padding: .1em .35em; border-radius: 3px; }
pre { font-family: var(--mono); font-size: .875rem; line-height: 1.5; background: var(--card); border: 1px solid var(--line); border-radius: 4px; padding: 16px; overflow-x: auto; margin: 0 0 16px; }
pre code { background: none; padding: 0; font-size: inherit; }
.hash { overflow-wrap: anywhere; }
hr { border: 0; border-top: 1px solid var(--line); margin: 32px 0; }
.shell { max-width: var(--shell); margin: 0 auto; padding: 0 var(--gutter); }
.prose { max-width: 72ch; }
.prose img, .shell img { max-width: 100%; height: auto; }
section { margin-bottom: var(--section); }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.visually-hidden-canvas { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }

/* 3. Shell: skip link, header, nav, menu, theme toggle, footer */
.skip-link { position: absolute; left: 8px; top: -100px; z-index: 100; background: var(--surface); color: var(--fg); border: 1px solid var(--line-strong); border-radius: 4px; padding: 8px 12px; }
.skip-link:focus { top: 8px; }
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
@media (min-width: 960px) { .site-header { position: sticky; top: 0; z-index: 50; } }
.site-nav { max-width: var(--shell); margin: 0 auto; padding: 12px var(--gutter); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; font-size: .9375rem; font-weight: 500; }
@media (min-width: 640px) { .site-nav { padding: 16px var(--gutter); } }
@media (min-width: 640px) and (max-width: 959.98px) { .site-nav, .site-menu { gap: 4px 14px; font-size: .875rem; } }
.site-nav a { display: inline-flex; align-items: center; min-height: 44px; color: var(--mute); text-decoration: none; border-bottom: 2px solid transparent; }
.site-nav a:hover { color: var(--fg); }
.site-nav a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--orange); }
.wordmark, .site-nav a.wordmark { font-family: var(--serif); font-size: 1.125rem; font-weight: 600; color: var(--fg); margin-right: auto; }
.site-nav a.wordmark[aria-current="page"] { border-bottom-color: transparent; }
.site-menu { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; }
.menu-button, .theme-toggle { font: inherit; font-size: .9375rem; font-weight: 500; line-height: 1; background: transparent; color: var(--mute); border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 12px; min-height: 36px; cursor: pointer; display: inline-flex; align-items: center; }
.menu-button:hover, .theme-toggle:hover { color: var(--fg); border-color: var(--fg); }
.menu-button { display: none; color: var(--fg); min-height: 44px; }
.theme-toggle::before { content: ""; display: inline-block; width: .7em; height: .7em; border-radius: 50%; border: 2px solid currentColor; margin-right: .45em; }
.theme-toggle[aria-pressed="true"]::before { background: currentColor; }
@media (max-width: 639.98px) {
    .menu-button { display: inline-flex; }
    .site-menu { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 0; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 4px; }
    .site-menu.open { display: flex; }
    .theme-toggle { align-self: flex-start; margin: 8px 0 4px; min-height: 44px; }
}
.site-footer { border-top: 1px solid var(--line); margin-top: var(--section); padding: 24px 0 40px; color: var(--mute); font-size: .875rem; }
.site-footer p { margin: 0 0 6px; }
.site-footer a { color: var(--mute); }
.site-footer a:hover { color: var(--fg); }

/* 4. Buttons, status line, cards, boxes, tables, forms */
.button, .stage-play, .stage-render { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 20px; border-radius: 4px; font: inherit; font-size: 1rem; font-weight: 500; line-height: 1; text-decoration: none; color: var(--fg); background: var(--surface); border: 1px solid var(--line-strong); cursor: pointer; }
.button:hover, .stage-play:hover, .stage-render:hover { border-color: var(--fg); }
.button.primary { background: var(--button-red); color: #fff; border-color: var(--button-red); }
.button.primary:hover { filter: brightness(1.08); }
.button.quiet { background: transparent; border-color: transparent; padding: 0 8px; text-decoration: underline; text-underline-offset: .2em; }
.button[disabled], button[disabled] { opacity: .5; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 24px 0 0; }

.status-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; color: var(--orange); font-weight: 500; margin: 0 0 12px; }
.status-marker { display: inline-block; width: 10px; height: 10px; background: currentColor; flex: none; align-self: center; }
.status-link[hidden] { display: none; }

.card-grid { display: grid; gap: 16px; grid-template-columns: 1fr; margin: 0 0 16px; }
@media (min-width: 640px) { .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 960px) { .card-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 16px; box-shadow: var(--shadow); }
/* Your patterns (js/favourites.js): up to three favourites without an account, five with one. */
.your-patterns { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 16px; margin: 24px 0 0; }
.your-patterns-intro { margin: 0 0 12px; font-size: .9375rem; color: var(--mute); }
.your-patterns-list { border: 0; padding: 0; margin: 0; }
.your-patterns-list legend { font-weight: 600; padding: 0; margin-bottom: 8px; }
.your-patterns-row { display: flex; align-items: flex-start; gap: 12px; min-height: 44px; padding: 6px 0; border-bottom: 1px solid var(--hair); }
.your-patterns-row:last-child { border-bottom: 0; }
.your-patterns-row input { width: 20px; height: 20px; margin: 4px 0 0; flex: 0 0 auto; accent-color: var(--blue); }
.your-patterns-row label { cursor: pointer; }
.your-patterns-row .desc { display: block; font-size: .875rem; color: var(--mute); }
.your-patterns .field-note { margin: 12px 0 0; font-size: .875rem; color: var(--mute); }
@media (min-width: 640px) { .card { padding: 20px; } }
.card h3 { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card-links { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.card-links li { margin: 0; }
.box { background: var(--card); border: 1px solid var(--line); border-left-width: 4px; border-radius: 0 4px 4px 0; padding: 12px 16px; margin: 24px 0; }
.box-definition { border-left-color: var(--orange); }
.box-caution { border-left-color: var(--blue); }
.box-caution .kicker { color: var(--blue); }
.box .kicker { margin-bottom: 4px; }
.box > :last-child { margin-bottom: 0; }

.table-scroll { overflow-x: auto; border: 1px solid var(--line-strong); border-radius: 4px; margin: 16px 0 24px; }
table.data { width: 100%; border-collapse: collapse; font-size: .875rem; }
table.data caption { caption-side: top; text-align: left; padding: 12px 12px 8px; color: var(--mute); }
table.data th { text-align: left; font-weight: 600; padding: 8px 12px; border-bottom: 2px solid var(--line-strong); white-space: nowrap; }
table.data td { padding: 8px 12px; border-bottom: 1px solid var(--hair); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data code { background: none; padding: 0; }

.form-field { margin: 0 0 16px; max-width: 34rem; }
.form-field label { display: block; font-weight: 500; margin-bottom: 6px; }
input[type="text"], input[type="email"], textarea { width: 100%; font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 4px; padding: 12px 14px; }
textarea { min-height: 8rem; resize: vertical; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--red-text); }
.form-status { color: var(--mute); margin: 12px 0 0; min-height: 1.6em; }
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* 5. The stage: shared by the home hero, the live page and the patterns page.
   State classes on .stage-host come from js/site.js: state-live, state-offline, state-paused, is-paused. */
.live-layout { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.live-stage { position: relative; width: 100%; max-width: 520px; flex: 0 1 520px; aspect-ratio: 1 / 1; background: #000; border: 1px solid var(--line-strong); overflow: hidden; }
#liveCanvas, .engine-mount { position: absolute; inset: 0; width: 100%; height: 100%; }
#liveCanvas { display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
.engine-mount .pv-wrapper { gap: 0; width: 100%; height: 100%; }
.engine-mount .pv-canvas-wrap { width: 100%; height: 100%; max-width: none; border: 0; border-radius: 0; }
.engine-mount .pv-controls { display: none; }
.state-offline #liveCanvas { visibility: hidden; }
.state-live .engine-mount { display: none; }
/* The viewer's own rendering of the live signal (js/site.js section 7): the live canvas keeps painting underneath. */
.state-live.render-own .engine-mount { display: block; }
.state-live.render-own #liveCanvas { visibility: hidden; }
.engine-mount[hidden] { display: none; }
.stage-render[hidden] { display: none; }
.stage-poster { display: none; position: absolute; inset: 0; z-index: 1; background: #000; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 16px; gap: 8px; }
.stage-poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .5; image-rendering: pixelated; }
.stage-poster p { position: relative; margin: 0; font-size: .875rem; line-height: 1.5; color: var(--stage-fg); background: var(--stage-chip-bg); padding: 8px 12px; border-radius: 4px; max-width: 30ch; }
.state-offline .live-stage:not([data-engine-src]) .stage-poster, .state-paused .stage-poster, .is-paused .stage-poster { display: flex; }
.state-paused .engine-mount, .is-paused .engine-mount, .is-paused #liveCanvas, .state-paused #liveCanvas { visibility: hidden; }
.stage-chip { position: absolute; top: 10px; left: 10px; z-index: 2; display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 600; letter-spacing: .02em; color: var(--stage-fg); background: var(--stage-chip-bg); padding: 4px 8px; border-radius: 3px; }
.stage-chip::before { content: ""; width: 9px; height: 9px; border: 2px solid var(--stage-fg); }
.stage-chip.dot-filled::before { border-radius: 50%; background: var(--stage-orange); border-color: var(--stage-orange); }
.stage-chip.bars::before { border-width: 0 2px; height: 11px; }
@media (max-width: 639.98px) { .stage-chip { top: 8px; left: 8px; } }
.stage-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 12px 0 0; }
.stage-play, .stage-render, .stage-bar .button { min-height: 40px; font-size: .9375rem; padding: 0 16px; }
.stage-play[hidden] { display: none; }
.stream-note { font-size: .8125rem; color: var(--mute); margin: 8px 0 0; }
.stage-caption { font-size: .875rem; color: var(--mute); margin: 12px 0 0; }
.state-live .stage-caption[data-when="offline"] { display: none; }

.live-readout { flex: 1 1 280px; min-width: 0; }
.live-stats { display: grid; gap: 6px; margin: 0 0 16px; }
.live-stats > div { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--hair); padding-bottom: 4px; font-size: .875rem; }
.live-stats dt { color: var(--mute); margin: 0; }
.live-stats dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
/* Focus window: a shape as well as a colour. Open = filled square, resting = hollow square, unknown = hollow diamond. */
.live-stats dd.focus-on::before, .live-stats dd.focus-off::before, .live-stats dd.focus-unknown::before { content: ""; display: inline-block; width: .6em; height: .6em; margin-right: .4em; border: 2px solid currentColor; vertical-align: baseline; }
.live-stats dd.focus-on { color: var(--red-text); }
.live-stats dd.focus-on::before { background: currentColor; }
.live-stats dd.focus-off { color: var(--mute); font-weight: 400; }
.live-stats dd.focus-unknown { color: var(--orange); font-weight: 400; }
.live-stats dd.focus-unknown::before { transform: rotate(45deg); }
#zCanvas { width: 100%; max-width: 360px; height: auto; display: block; background: #000; border: 1px solid var(--line-strong); }
.live-zvals { display: flex; justify-content: space-between; gap: 16px; margin-top: 8px; font-size: .875rem; color: var(--mute); }
.live-zvals b { color: var(--fg); }
.state-offline .live-readout:not(.live-readout--compact) { opacity: .5; }
.live-readout--compact { display: none; }
.state-live .live-readout--compact { display: block; }
.live-readout--compact .readout-extra, .live-readout--compact #zCanvas, .live-readout--compact .live-zvals { display: none; }
body.aud-blind .live-readout { display: none; }

/* Audience caption, consent box and participate controls (markup from js/audience.js, styled here only). */
.aud-caption { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 12px 0 0; padding-top: 8px; border-top: 1px solid var(--line); font-size: .875rem; line-height: 1.5; color: var(--mute); }
.aud-caption p { margin: 0; flex: 1 1 24rem; }
.aud-caption button, .aud-box button { font: inherit; font-size: .9375rem; font-weight: 500; line-height: 1; min-height: 40px; padding: 0 16px; border-radius: 4px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg); cursor: pointer; margin: 4px 8px 4px 0; }
.aud-caption button:hover, .aud-box button:hover { border-color: var(--fg); }
.aud-box { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 16px; margin: 16px 0; }
.aud-box h3 { margin-top: 0; }
.aud-box h3:focus { outline: none; }
.aud-box details { margin: 4px 0 16px; }
.aud-box summary { cursor: pointer; color: var(--link); margin-bottom: 12px; }
.aud-box p { margin: 0 0 12px; }
.aud-box textarea { display: block; width: 100%; margin: 8px 0; }
.aud-reply, .aud-hint, .aud-code { font-size: .875rem; color: var(--mute); }
.aud-code code { overflow-wrap: anywhere; }
.aud-switch { display: inline-block; margin-top: 8px; font-size: .875rem; }

/* 6. Home hero: words beside the grid; grid first on phones. */
.hero { display: grid; gap: 24px; padding: 24px 0 0; margin-bottom: var(--section); }
.hero-words { order: 2; }
.hero-stage { order: 1; }
.hero h1 { margin: 0 0 12px; }
.hero .lede { margin: 0; max-width: 58ch; }
.hero-stage .live-layout { flex-direction: column; align-items: stretch; }
.hero-stage .live-stage { flex-basis: auto; }
@media (max-width: 639.98px) {
    /* Phones: the grid first, then the words and the three buttons inside the first screen, then the rest of the
       stage column. The stage column's children join the hero grid directly so they can be ordered around the words. */
    .hero-stage { display: contents; }
    .hero-stage > * { order: 3; }
    .hero-stage > .live-layout { order: 1; }
    .hero-words { order: 2; display: flex; flex-direction: column; }
    .hero-words .status-line { order: 1; }
    .hero-words h1 { order: 2; }
    .hero-words .actions { order: 3; margin-top: 16px; }
    .hero-words .lede { order: 4; margin-top: 16px; }
    .hero-stage .live-stage { max-width: 220px; margin: 0 auto; }
    .hero .stage-bar, .hero .stage-caption, .hero .stream-note, .hero .aud-caption, .hero .aud-box { margin-top: 0; }
    .wordmark, .site-nav a.wordmark { font-size: 1rem; }
}
@media (min-width: 640px) {
    .hero { grid-template-columns: 7fr 5fr; gap: 32px; padding-top: 32px; }
    .hero-words { order: 1; }
    .hero-stage { order: 2; }
    .hero-stage .live-stage { max-width: 320px; }
    .live-readout--compact .live-stats { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 960px) {
    .hero { grid-template-columns: 58fr 42fr; padding-top: 40px; }
    .hero-stage .live-stage { max-width: 380px; }
}

/* 7. The engine's own viewer on /patterns/ (styles it injects are overridden here, never edited there). */
.engine-stage { position: relative; }
.stage-chip--inline { position: static; }
.engine-stage .status-line { display: none; }
.engine-stage .stage-poster { position: relative; width: 100%; max-width: 520px; aspect-ratio: 1 / 1; margin: 0 auto 16px; }
.engine-stage.is-paused .pv-canvas-wrap { display: none; }
#patternsViewer .pv-wrapper, #patternsViewer .pv-control-group label, #patternsViewer .pv-btn, #patternsViewer .pv-description, #patternsViewer .pv-slider-val, #patternsViewer .pv-mech-empty { font-family: var(--sans); }
#patternsViewer .pv-wrapper { align-items: flex-start; }
#patternsViewer .pv-canvas-wrap { border: 1px solid var(--line-strong); border-radius: 0; background: #000; }
#patternsViewer .pv-btn { background: var(--surface); color: var(--fg); border: 1px solid var(--line-strong); border-radius: 4px; font-size: .875rem; }
#patternsViewer .pv-btn:hover { border-color: var(--fg); }
#patternsViewer .pv-btn.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
#patternsViewer .pv-control-group label { color: var(--mute); text-transform: none; letter-spacing: 0; font-size: .875rem; }
#patternsViewer .pv-description { color: var(--mute); }
#patternsViewer input[type="range"] { accent-color: var(--orange); }

/* 8. Motion: nothing animates for anyone who asked for less of it; the site uses no transitions of its own. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
