/* The two standalone help pages (how-to-use.html, licenses.html) — ONE sheet, on the studio's terminal
   tokens. Until 0611 each page carried its own near-identical inline sheet on the pre-#55 neutral
   palette (#141413 ground, #faf9f5 text, rounded corners, grey ghost buttons), so the first click out
   of the green landing ("tldr how to use") landed on a grey page, and three of its text colours
   failed AA: #727272 on #0b0b0b 4.09:1 (.crt-chrome — the failure #55 fixed in index.html and never
   ported), #6f6e66 on #0b0b0b 3.84:1 (code comments), #57564f on #141413 2.50:1 (the footer and
   every `## `). plans/0611-theme-improvements-plan.md item 1; plans/tools/theme-audit.mjs measures it.

   The TOKENS MIRROR client/index.html's :root — keep the two in step (the signaling.ts RATE_MAX
   idiom). The studio's sheet stays inline in index.html on purpose: the Document-PiP portal copies
   its cssText, and these pages have no portal. This file is a fixed-name root asset, so the server's
   cacheControl gives it `no-cache` (revalidated on every load) — never move it under assets/, which
   is cached for a year. Same origin, so `style-src 'self'` already allows it (constraint 6).
   Ratios are WCAG 2.x, measured against the ground each colour actually sits on. */
:root {
  color-scheme: dark;
  --green-hi: #33ff66;   /* 14.56 on --bg */
  --green: #2bd15f;
  --green-hover: #25b954;
  --bg: #060e07;         /* page ground */
  --bg-chrome: #030904;  /* code blocks, table head, notes */
  --bg-raise: #0a1a0e;   /* control fill, code chips */
  --bg-raise-hi: #0d2011;
  --fg: #65e287;         /* 11.91 bg / 12.23 chrome */
  --fg-dim: #519160;     /*  5.19 bg /  5.33 chrome / 5.22 #0b0b0b */
  --line-ui: #2f7a42;    /* control boundaries: 3.71 bg / 3.41 raise */
  --line: #1c4a2a;       /* decorative rules only */
  --on-accent: #0b1a10;  /* text on the --green fill: 8.88 */
  --green-hi-rgb: 51, 255, 102;
  --amber: #d29922;
  --bg-popup: #0b0b0b;
  /* The decorative layers, named as in index.html so the light theme can thin them (same values). */
  --scan-crt: rgba(0,0,0,.18);
  --vignette-crt: rgba(0,0,0,.55);
  --scan-card: rgba(0,0,0,.14);
  --crt-card-shadow: inset 0 0 120px rgba(0,0,0,.5), 0 12px 48px rgba(0,0,0,.55);
  --code-inset: rgba(0,0,0,.4);
  --glow-text: 0 0 8px rgba(var(--green-hi-rgb), .45), 0 0 24px rgba(var(--green-hi-rgb), .18);
}
/* LIGHT TERMINAL — the studio's light theme, mirrored (index.html `:root[data-theme="light"]` carries
   the measurements; theme.test.ts fails if a token here differs from that block). Set before first
   paint by /theme.js, which reads the same per-device choice the studio's ☀ theme switch writes;
   these pages have no switch of their own. */
:root[data-theme="light"] {
  color-scheme: light;
  --green-hi: #0b5e28;
  --green: #136d33;
  --green-hover: #0f5a2a;
  --bg: #e6ede3;
  --bg-chrome: #dae4d6;
  --bg-raise: #f2f6f0;
  --bg-raise-hi: #e3ecdf;
  --fg: #1b5530;
  --fg-dim: #46684f;
  --line-ui: #557f5e;
  --line: #b4c8b5;
  --on-accent: #ffffff;
  --green-hi-rgb: 11, 94, 40;
  --amber: #8a5800;
  --bg-popup: #f7faf6;
  --scan-crt: rgba(0,0,0,.035);
  --vignette-crt: transparent;
  --scan-card: rgba(0,0,0,.03);
  --crt-card-shadow: 0 12px 40px rgba(16,40,22,.14);
  --code-inset: rgba(16,40,22,.06);
  --glow-text: none;
}
/* BLACK-RED-WHITE — the studio's third theme, mirrored the same way (index.html
   `:root[data-theme="black-red-white"]` carries the measurements; theme.test.ts fails if a token here
   differs from that block). A dark skin with the hue taken out; --amber keeps its hue, as there.
   --red is declared only for the decorative red this theme has: the title's glow and the cursor. */
:root[data-theme="black-red-white"] {
  --green-hi: #ffffff;
  --green: #ffffff;
  --green-hover: #d4d4d4;
  --bg: #000000;
  --bg-chrome: #000000;
  --bg-raise: #121212;
  --bg-raise-hi: #202020;
  --fg: #e8e8e8;
  --fg-dim: #999999;
  --line-ui: #7a7a7a;
  --line: #3a3a3a;
  --red: #ff4040;
  --on-accent: #000000;
  --red-rgb: 255, 64, 64;
  --green-hi-rgb: 255, 255, 255;
  --bg-popup: #0a0a0a;
  --scan-crt: rgba(255,255,255,.03);
  --vignette-crt: transparent;
  --scan-card: rgba(255,255,255,.03);
  --glow-text: 0 0 8px rgba(var(--red-rgb), .75), 0 0 24px rgba(var(--red-rgb), .4);
}
:root[data-theme="black-red-white"] .cursor::after { color: var(--red); }
* { box-sizing: border-box; }
/* 3270 (IBM 3270 terminal revival), Nerd Fonts patch — self-hosted, zero third-party requests.
   BSD-3 + OFL/MIT/etc; see /licenses.html and /fonts/. */
@font-face {
  font-family: "3270 Nerd Font Mono";
  src: url("/fonts/3270NerdFontMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
body {
  margin: 0;
  font-family: "3270 Nerd Font Mono", ui-monospace, SFMono-Regular, Consolas,
    "Liberation Mono", Menlo, monospace;
  background: var(--bg); color: var(--fg); min-height: 100dvh;
  display: flex; flex-direction: column; line-height: 1.55;
}
/* The studio's CRT ground (index.html `body:not(.view)::before`): fixed, because body is a flex
   column and an in-flow pseudo would become a flex item; z-index -1, so it paints only behind the
   content. There is no video on these pages, so nothing here is near a picture. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: repeating-linear-gradient(to bottom,
    rgba(0,0,0,0) 0 2px, var(--scan-crt) 2px 3px, rgba(0,0,0,0) 3px 4px);
  box-shadow: inset 0 0 160px var(--vignette-crt);
}
a { color: var(--green-hi); text-decoration: none; }
a:hover { color: var(--green-hi); }
/* Links inside the prose are UNDERLINED, and that is load-bearing: the prose is --fg green, and
   --green-hi against it is 1.22:1, so colour alone could not tell a link from the text around it
   (WCAG 1.4.1). The old neutral prose leaned on the hue difference. */
.content a { text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.glow { text-shadow: var(--glow-text); }

.page { flex: 1; width: 100%; max-width: 900px; margin: 0 auto;
  /* viewport-fit=cover: step out of the notch and the home indicator (C-50); 0 on desktop. */
  padding: 24px max(18px, env(safe-area-inset-right, 0px)) calc(40px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px)); }

/* top bar: back (+ how to use) + the create-a-room CTA */
.doc-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.doc-top .grow { flex: 1; }
/* The studio's control shapes: square, and ONE primary fill per page — the create-a-room CTA, the
   landing's [ CREATE ROOM ] treatment (#0b1a10 on --green 8.88:1). Every other button is the
   outline control the header uses (--green-hi on --bg-raise 13.40:1, --line-ui edge 3.71:1 on --bg). */
.btn {
  display: inline-block; background: var(--green); color: var(--on-accent); border: 1px solid var(--green);
  border-radius: 0; padding: 8px 14px; font: inherit; font-size: 13px; font-weight: 700;
  letter-spacing: .4px; cursor: pointer;
}
.btn:hover { background: var(--green-hover); color: var(--on-accent); }
.btn.ghost {
  background: var(--bg-raise); color: var(--green-hi); border-color: var(--line-ui); font-weight: 400;
}
.btn.ghost:hover { background: var(--bg-raise-hi); color: var(--green-hi); }

/* CRT hero — the landing terminal's look (index.html .crt) */
.crt {
  position: relative; overflow: hidden;
  background: var(--bg-popup); border: 1px solid var(--line); border-radius: 0;
  padding: 18px 24px 22px; margin-bottom: 30px;
  box-shadow: var(--crt-card-shadow);
}
.crt::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0 2px, var(--scan-card) 2px 3px);
}
.crt-chrome {
  color: var(--fg-dim); font-size: 12px; letter-spacing: .5px;
  border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 16px;
}
.banner {
  margin: 0 0 6px; color: var(--green-hi); font-size: clamp(6px, 1.15vw, 10px); line-height: 1.2;
  overflow: hidden; white-space: pre;
}
.wordmark { display: none; color: var(--green-hi); font-size: 24px; font-weight: 700; letter-spacing: 4px; margin: 0 0 6px; }
@media (max-width: 620px) { .banner { display: none; } .wordmark { display: block; } }
/* A wrapped `>` line hangs under its text, not the prompt (2ch: `> ` in the monospace face) — the
   landing page's `.type` and `$` lines carry the same rule in index.html. */
.type { margin: 12px 0 2px; color: var(--fg); font-size: 14px; padding-left: 2ch; text-indent: -2ch; }
.cursor::after { content: "▋"; color: var(--green-hi); margin-left: 2px; }
@media (prefers-reduced-motion: no-preference) {
  .cursor::after { animation: blink 1.1s steps(1) infinite; }
  @keyframes blink { 50% { opacity: 0; } }
}

/* document content */
.content h1 { font-size: 22px; font-weight: 700; letter-spacing: .3px; color: var(--green-hi); margin: 8px 0 6px; }
.content h2 {
  font-size: 18px; font-weight: 700; color: var(--green-hi); margin: 40px 0 10px;
  padding-bottom: 8px; border-bottom: 1px solid var(--line); letter-spacing: .3px;
}
.content h2::before { content: "## "; color: var(--fg-dim); }
.content h3 { font-size: 15px; font-weight: 700; color: var(--green-hi); margin: 26px 0 8px; }
.content h3::before { content: "› "; color: var(--fg-dim); }
.content p { margin: 12px 0; }
.content ul { margin: 12px 0; padding-left: 0; list-style: none; }
.content ul li { position: relative; margin: 8px 0; padding-left: 20px; }
.content ul li::before { content: "–"; position: absolute; left: 4px; color: var(--fg-dim); }
strong { color: var(--green-hi); font-weight: 700; }
em { color: var(--fg-dim); font-style: italic; }

code {
  background: var(--bg-raise); color: var(--green-hi); border: 1px solid var(--line); border-radius: 0;
  padding: 1px 5px; font-family: inherit; font-size: .92em; overflow-wrap: anywhere;
}
pre.code {
  background: var(--bg-chrome); border: 1px solid var(--line); border-radius: 0;
  padding: 14px 16px; margin: 14px 0; overflow-x: auto; font-size: 13px; color: var(--fg);
  box-shadow: inset 0 0 60px var(--code-inset); white-space: pre-wrap; overflow-wrap: anywhere;
}
pre.code code { background: none; border: 0; padding: 0; color: inherit; }
pre.code .cmt { color: var(--fg-dim); } /* 5.33 on --bg-chrome (was #6f6e66, 3.84:1) */

/* tables — the reference lives here, so make them readable */
.table-wrap { overflow-x: auto; margin: 16px 0; border: 1px solid var(--line); border-radius: 0; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; vertical-align: top; padding: 9px 12px; border-bottom: 1px solid var(--line); }
thead th { background: var(--bg-chrome); color: var(--green-hi); font-weight: 700; letter-spacing: .3px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) { background: rgba(var(--green-hi-rgb), .03); }
td:first-child { color: var(--green-hi); }
/* Per page, as each inline sheet had it: the reference keeps its param column (and the head) on one
   line; the credits table keeps its license column on one line, in the accent green. */
body.doc-howto thead th, body.doc-howto td:first-child { white-space: nowrap; }
body.doc-licenses td:last-child { white-space: nowrap; color: var(--green); }

/* callouts (the doc's blockquotes) */
.note {
  border-left: 3px solid var(--green); background: var(--bg-chrome);
  padding: 10px 14px; margin: 16px 0; border-radius: 0; font-size: 13px;
}
.note.caution { border-left-color: var(--amber); } /* the studio's warning amber (index.html) */
.note p { margin: 8px 0; color: inherit; }
.note p:first-child { margin-top: 0; } .note p:last-child { margin-bottom: 0; }

/* footer — every word in it is a link except the `·` between them */
.doc-foot {
  margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line);
  display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap;
  color: var(--fg-dim); font-size: 12px;
}
.doc-foot a { color: var(--fg-dim); }
.doc-foot a:hover { color: var(--green-hi); }

/* Selection in reverse video, and the studio's increased-contrast mode (index.html's last block,
   0611 items 8 and 10): brighter dim text and rules, no scanline texture behind the prose. */
::selection { background: var(--green-hi); color: var(--on-accent); }
:root { scrollbar-color: var(--line-ui) var(--bg-chrome); }
@media (prefers-contrast: more) {
  :root { --line-ui: #4caf68; --line: #2f7a42; --fg-dim: #7cc48e; }
  :root[data-theme="light"] { --line-ui: #3d6646; --line: #8fae93; --fg-dim: #2f5338; }
  :root[data-theme="black-red-white"] { --line-ui: #b0b0b0; --line: #7a7a7a; --fg-dim: #c4c4c4; }
  body::before, .crt::after { content: none; }
}
