/* ==========================================================================
   thrash.dev / Notebook
   One stylesheet, no build step. Order: fonts → tokens → base → shell →
   components → page types → responsive → print.
   Rule: --accent (orange) is a RULE or FILL colour; as text only on the dark theme.
   ========================================================================== */

/* ---- fonts (self-hosted, OFL; see /fonts/OFL-*.txt) ---------------------- */
@font-face {
  font-family: "Archivo";
  src: url("/fonts/archivo.woff2") format("woff2-variations"), url("/fonts/archivo.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono.woff2") format("woff2-variations"), url("/fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

/* ---- tokens ------------------------------------------------------------ */
/* Dark is the default (also without JS). panel.js sets data-theme="light" | "auto". */
:root {
  --bg: #141517;
  --raised: #1c1d20;     /* table heads, boxes */
  --well: #0b0c0d;       /* code */
  --ink: #ececea;
  --body: #c4c4c8;
  --muted: #a1a1a6;
  --rule: #2a2b2f;
  --rule-2: #3a3b40;
  --accent: #ff6a33;
  --accent-text: #ff6a33; /* numbers on H2s; ink on the light theme */
  --on-accent: #1a0e08;
  --ok: #4cc38a;
  --warn: #e3b341;
  --code-ink: #e6e6e3;

  --sans: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --width: 760px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #ffffff; --raised: #f4f4f5; --well: #16171a;
  --ink: #111113; --body: #3a3a40; --muted: #55555c;
  --rule: #e4e4e7; --rule-2: #c9c9ce;
  --accent-text: #111113; --ok: #1f8a57; --warn: #9a6a00;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg: #ffffff; --raised: #f4f4f5; --well: #16171a;
    --ink: #111113; --body: #3a3a40; --muted: #55555c;
    --rule: #e4e4e7; --rule-2: #c9c9ce;
    --accent-text: #111113; --ok: #1f8a57; --warn: #9a6a00;
    color-scheme: light;
  }
}

/* ---- base -------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 1.0625rem/1.7 var(--sans); font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
}
img, svg, video, audio { max-width: 100%; }
img, video { height: auto; border-radius: 6px; }
p { margin: 0 0 1rem; }

a { color: inherit; text-decoration: underline; text-decoration-color: var(--rule-2); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

.skip { position: absolute; left: -999px; top: 0; z-index: 10; background: var(--accent); color: var(--on-accent); padding: 0.5rem 1rem; }
.skip:focus { left: 1rem; top: 1rem; }

h1, h2, h3, h4 { line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; margin: 2.5rem 0 1rem; }
h1 { font-size: clamp(2rem, 6vw, 2.6rem); letter-spacing: -0.02em; margin: 0 0 0.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }

/* Small mono label: "01 apps", "on this page", panel titles. */
.label { font: 500 0.875rem/1.4 var(--mono); color: var(--muted); letter-spacing: 0; margin: 0 0 1.25rem; }
.label b { color: var(--ink); font-weight: 700; }
.label a { text-decoration: none; }
.label a:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.meta, .crumbs, time { font: 400 0.8125rem/1.5 var(--mono); color: var(--muted); }
.meta a, .crumbs a { color: var(--muted); }
.lede { font-size: 1.2rem; color: var(--body); margin: 0 0 1.25rem; }
.empty { color: var(--muted); font-family: var(--mono); font-size: 0.875rem; }
.boxed { border: 1px dashed var(--rule-2); border-radius: 8px; padding: 1.1rem 1.25rem; }

/* ---- shell ------------------------------------------------------------- */
.page { max-width: var(--width); margin: 0 auto; padding: 3.5rem 1.5rem 4rem; }

.site-head {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline;
  gap: 0.75rem 1.5rem; padding-bottom: 1.25rem; border-bottom: 2px solid var(--ink);
}
.brand { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; font: 700 1.125rem/1 var(--mono); }
.mark { width: 22px; height: 14px; fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linejoin: round; }
.site-nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; font: 400 0.875rem/1.6 var(--mono); }
.site-nav a { padding: 0.35rem 0; }
.site-nav a[aria-current="page"] { text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 0.35em; }

main { padding-top: 2rem; }

.site-foot {
  margin-top: 3rem; padding-top: 1.25rem; border-top: 2px solid var(--ink);
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem 1.5rem;
  font: 400 0.8125rem/1.5 var(--mono); color: var(--muted);
}
.foot-links { display: flex; gap: 1rem; }
.site-foot a { color: var(--muted); }
.theme-switch { display: flex; border: 1px solid var(--rule-2); border-radius: 6px; overflow: hidden; }
.theme-switch[hidden] { display: none; }
.theme-switch button {
  font: 400 0.75rem/1 var(--mono); color: var(--muted); background: none; border: 0;
  padding: 0.5rem 0.65rem; cursor: pointer; min-height: 32px;
}
.theme-switch button + button { border-left: 1px solid var(--rule-2); }
.theme-switch button[aria-pressed="true"] { background: var(--raised); color: var(--ink); }

/* ---- components -------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 1.25rem;
  border-radius: 6px; border: 1px solid var(--rule-2);
  font: 600 0.9375rem/1 var(--sans); text-decoration: none;
}
.btn:hover { border-color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: #ff7f4f; border-color: #ff7f4f; }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1.5rem 0 0; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 0.4rem; background: var(--muted); vertical-align: 0.05em; }
.dot-beta, .dot-alpha { background: var(--warn); }
.dot-stable { background: var(--ok); }

.panel, .block { padding: 2rem 0; border-top: 1px solid var(--rule); }
.panel > :last-child, .block > :last-child { margin-bottom: 0; }
.block > p { color: var(--body); }

.specs { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.5rem 1.5rem; font-size: 0.9375rem; }
.spec { display: contents; }
.spec dt { font: 400 0.8125rem/1.6 var(--mono); color: var(--muted); padding-top: 0.1rem; }
.spec dd { margin: 0; color: var(--body); }

.chips { display: inline-flex; flex-wrap: wrap; gap: 0.35rem; }
.chip { font: 400 0.75rem/1 var(--mono); color: var(--muted); border: 1px solid var(--rule-2); border-radius: 999px; padding: 0.3rem 0.6rem; text-decoration: none; }
a.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip-lg { font-size: 0.875rem; padding: 0.45rem 0.8rem; }

.dated { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.85rem; }
.dated li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 1.25rem; }
.dated time { flex: 0 0 6.5rem; font-size: 0.875rem; }
.dated .row-main { flex: 1 1 18rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.75rem; }

.plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.plain .meta { margin-left: 0.5rem; }

.app-entry + .app-entry { margin-top: 1.75rem; }
.app-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 1.25rem; margin: 0 0 0.35rem; }
.app-name { font-size: 1.375rem; font-weight: 600; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 0.25em; }
.app-desc { color: var(--body); margin: 0 0 0.6rem; }

/* ---- code -------------------------------------------------------------- */
/* Code blocks are always dark, in both themes. */
pre, .lcd {
  background: var(--well); color: var(--code-ink);
  border: 1px solid var(--rule); border-radius: 8px;
}
pre { position: relative; overflow-x: auto; padding: 1.1rem 1.25rem; margin: 1.5rem 0; font: 400 0.875rem/1.6 var(--mono); }
pre code { font: inherit; background: none; padding: 0; border: 0; color: inherit; }
pre code[data-lang]::before { /* language label; JS adds the copy button top-right */
  content: attr(data-lang); display: block; margin-bottom: 0.6rem;
  font: 400 0.75rem/1 var(--mono); color: #8d8d89;
}
.copy {
  position: absolute; top: 0.6rem; right: 0.6rem;
  font: 400 0.75rem/1 var(--mono); color: #a1a1a6; background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 4px; padding: 0.4rem 0.55rem; cursor: pointer;
}
.copy:hover { color: #ececea; border-color: var(--accent); }
.copy.done { color: #4cc38a; border-color: #4cc38a; }
:not(pre) > code { font: 400 0.88em/1 var(--mono); background: var(--raised); border: 1px solid var(--rule); padding: 0.12em 0.35em; border-radius: 4px; }
kbd { font: 500 0.85em/1 var(--mono); padding: 0.15em 0.4em; border-radius: 4px; border: 1px solid var(--rule-2); border-bottom-width: 2px; background: var(--raised); }

/* ---- prose ------------------------------------------------------------- */
.prose { color: var(--body); counter-reset: sec; }
.prose strong, .prose h2, .prose h3, .prose a { color: var(--ink); }
.prose > h2 { counter-increment: sec; display: flex; align-items: baseline; gap: 0.75rem; }
.prose > h2::before { content: counter(sec, decimal-leading-zero); font: 400 0.875rem/1 var(--mono); color: var(--accent-text); }
.prose a { text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 0.22em; }
.prose ul, .prose ol { padding-left: 1.5rem; }
.prose li { margin: 0.35rem 0; }
.prose ol li::marker { font: 400 0.85em var(--mono); color: var(--muted); }
blockquote { margin: 1.5rem 0; padding: 0.1rem 0 0.1rem 1.1rem; border-left: 2px solid var(--accent); color: var(--ink); }
blockquote p:last-child { margin: 0; }
table {
  width: 100%; border-collapse: separate; border-spacing: 0; margin: 1.5rem 0;
  font-size: 0.9375rem; line-height: 1.5; border: 1px solid var(--rule); border-radius: 8px;
}
thead tr { background: var(--raised); }
th { text-align: left; padding: 0.65rem 0.9rem; font-weight: 600; color: var(--ink); }
td { padding: 0.65rem 0.9rem; border-top: 1px solid var(--rule); vertical-align: top; color: var(--body); }
td a { color: var(--ink); }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }

/* ---- page types -------------------------------------------------------- */
.intro { padding: 2rem 0 1.5rem; }
.intro-copy { color: var(--body); }

.section-head, .entry-head { margin-bottom: 2rem; }
.crumbs { margin: 0 0 1rem; }
.entry-head .meta { margin: 0 0 1rem; }
.entry-head .chips { margin-top: 0.25rem; }

/* Chapter list: a <details> box at the top of every manual page. */
.chapters { margin: 0 0 2rem; border: 1px solid var(--rule); border-radius: 8px; background: var(--raised); }
.chapters summary { cursor: pointer; padding: 0.7rem 1rem; min-height: 44px; font: 400 0.875rem/1.7 var(--mono); color: var(--body); }
.chapters ol { margin: 0; padding: 0.25rem 1rem 0.75rem 3rem; font-size: 0.9375rem; line-height: 1.9; color: var(--muted); }
.chapters ol li::marker { font: 400 0.8em var(--mono); }
.chapters a { text-decoration: none; }
.chapters a:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.chapters a[aria-current="page"] { font-weight: 600; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
.chapters .meta { margin: 0; padding: 0 1rem 0.85rem; }

.toc { margin: 0 0 2rem; padding: 1rem 1.25rem; border-left: 2px solid var(--rule-2); }
.toc .label { margin-bottom: 0.5rem; }
.toc ol { margin: 0; padding-left: 1.25rem; font-size: 0.9375rem; }

.pager { margin-top: 3.5rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.75rem; }
.pager a { display: flex; flex-direction: column; gap: 0.1rem; padding: 1rem 1.1rem; border: 1px solid var(--rule); border-radius: 8px; text-decoration: none; font-weight: 600; }
.pager a:hover { border-color: var(--accent); }
.pager .next { text-align: right; }

.manuals li .manual-title { font-size: 1.25rem; font-weight: 600; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
.manuals li p { margin: 0.25rem 0 0; color: var(--body); }
.units > * + * { margin-top: 1.75rem; }

.providers td:last-child { white-space: nowrap; }
.tag-grid { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* Music: transport box and signal chain. */
.transport { padding: 1rem 1.25rem; margin: 0 0 2rem; }
.scope-legend { display: flex; justify-content: space-between; font: 400 0.75rem/1 var(--mono); color: #8d8d89; margin-bottom: 0.75rem; }
.transport audio { width: 100%; }
.no-signal { font: 700 1rem/1 var(--mono); letter-spacing: 0.2em; color: #8d8d89; margin: 0.5rem 0; }
.chain { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.cable { width: 1.25rem; border-top: 1px solid var(--rule-2); }

.nosig { padding: 2rem 0; }
.nosig-screen { display: grid; place-items: center; height: 8rem; margin-bottom: 2rem; }

/* ---- responsive -------------------------------------------------------- */
@media (max-width: 34rem) {
  .page { padding-top: 2rem; }
  table { display: block; overflow-x: auto; }
  .specs { grid-template-columns: 1fr; gap: 0 0; }
  .spec dd { margin-bottom: 0.6rem; }
}

/* ---- print: the manual, on paper -------------------------------------- */
@media print {
  :root { --bg: #fff; --ink: #000; --body: #111; --muted: #444; --rule: #bbb; --raised: #fff; }
  .site-nav, .theme-switch, .copy, .pager, .actions, .chapters { display: none !important; }
  pre, .lcd { background: #fff; color: #000; border-color: #999; }
  a { text-decoration: none; }
}
