/* Shared by the Books site and the tech site: structure and the
   parts both sites use (nav, footer, buttons, the video, the borrow and buy
   block). No color is named here. Every color is one of these custom
   properties, which each site's own stylesheet (books.css, tech.css) sets
   for the light theme on :root and for the dark theme on
   :root[data-theme="dark"]:

     --bg  --bg-2  --surface          the page, an alternate band, a panel
     --ink  --ink-2  --muted          text, from strongest to quietest
     --line                           hairlines
     --accent                         links and text that carries the color
     --accent-strong  --on-accent     a filled control and the text on it
     --mark  --on-mark                the highlight fill and the text on it
     --stage  --on-stage              the dark panel a video sits on
     --focus                          the focus ring
     --font-display  --font-read      headings; long passages

   tests/channel-client.test.mjs measures every text and background pair in
   both themes, so a new pairing here needs a line there.

   Nothing on these sites moves by itself, so there is no Pause animations
   button. Transitions answer a hover, a focus, or a press, and switch off
   under prefers-reduced-motion. */

:root {
  --font-ui:   'Space Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* A scale after Bringhurst's classic one: 13, 17, 20, 24, 32, then two
     display sizes that grow with the screen. */
  --step--1: .8125rem;
  --step-0:  1.0625rem;
  --step-1:  1.25rem;
  --step-2:  1.5rem;
  --step-3:  2rem;
  --step-4:  clamp(2.25rem, 1.35rem + 3.8vw, 3.75rem);
  --step-5:  clamp(2.6rem, 1.1rem + 6.4vw, 5.25rem);

  --gutter: clamp(16px, 4vw, 40px);
  --r: 14px;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 1.5rem;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
ul, ol { list-style: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; }

h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.12; text-wrap: balance; }
h1 { font-size: var(--step-4); letter-spacing: -.02em; }
h2 { font-size: var(--step-3); letter-spacing: -.015em; }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); }

::selection { background: var(--accent-strong); color: var(--on-accent); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ── helpers ────────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

.skip {
  position: absolute; left: 16px; top: -100px; z-index: 10;
  background: var(--accent-strong); color: var(--on-accent);
  padding: 10px 18px; border-radius: 999px; font-weight: 700;
}
.skip:focus { top: 12px; }

/* Controls that only work with scripts on stay out of the way without them.
   js/theme.js swaps the no-js class for js before the first paint. */
.no-js .needs-js { display: none !important; }

.wrap { width: 100%; max-width: 1180px; margin-inline: auto; padding-inline: var(--gutter); }
.wrap--wide { max-width: 1360px; }
.wrap--read { max-width: 47rem; }

.sect { padding-block: clamp(2.5rem, 6vw, 4.5rem); }
.sect--band { background: var(--bg-2); }
.sect__head { margin-bottom: 1.5rem; }
.sect__head p { color: var(--ink-2); max-width: 60ch; margin-top: .6rem; }
.sect h2 + .lede { margin-top: .75rem; }

.lede { font-size: var(--step-1); line-height: 1.5; color: var(--ink-2); max-width: 56ch; }

/* Small facts: a date, an episode number, an ISBN. */
.meta { font-family: var(--font-mono); font-size: var(--step--1); letter-spacing: .01em; color: var(--muted); }

.link, .prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: .18em;
}
.link:hover, .prose a:hover { text-decoration-thickness: 3px; }

/* A link that stands in a line of its own has to be a 24px target (WCAG
   2.5.8), and one line of text is not. Padding on an inline box makes the box
   taller without moving the lines around it. Every text link on these sites
   gets it, so none depends on where it happens to sit. */
.link, .prose a, .bb__more a, .bb__stores a, .ties a, .vid__alt a, .foot a,
.umap__skip a, .umap__in a,
.names a, .tl__more a, .sources a, .ep__title a { padding-block: .2em; }
/* This one is set in the small size, where .2em is not enough. */
.vid__alt a { padding-block: .45em; }

.prose { font-family: var(--font-read); max-width: 65ch; }
.prose > * + * { margin-top: 1em; }
.prose ul { list-style: disc; padding-left: 1.2em; }
.prose ol { list-style: decimal; padding-left: 1.4em; }
.prose li + li { margin-top: .45em; }
.prose h2 { margin-top: 2.2em; font-size: var(--step-2); }
.prose h3 { margin-top: 1.6em; font-size: var(--step-1); }

/* ── nav ────────────────────────────────────────────────────── */
.nav {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .5rem 1.5rem;
  padding: .85rem var(--gutter);
  border-bottom: 1px solid var(--line);
}
.nav__brand { display: flex; align-items: center; gap: .65rem; }
.nav__home {
  display: inline-flex; align-items: center; gap: .55rem;
  min-height: 44px;
  text-decoration: none; color: var(--accent);
}
.nav__name {
  font-family: var(--font-mono); font-weight: 700; font-size: .8rem; letter-spacing: .28em;
  color: var(--ink);
}
.nav__site {
  display: inline-flex; align-items: center; min-height: 44px;
  padding-left: .75rem; border-left: 1px solid var(--line);
  font-family: var(--font-display); font-weight: 600; font-size: var(--step-1);
  text-decoration: none;
}
.nav__end { display: flex; align-items: center; gap: .5rem 1.25rem; flex-wrap: wrap; }
.nav__links { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; }
.nav__links a {
  display: inline-flex; align-items: center; min-height: 44px;
  text-decoration: none; font-weight: 500;
  border-bottom: 2px solid transparent;
}
.nav__links a:hover, .nav__site:hover { color: var(--accent); }
.nav__links a[aria-current="page"] { border-bottom-color: var(--accent-strong); }

.themetog {
  position: relative; flex: none;
  width: 58px; height: 32px; border-radius: 999px;
  background: var(--bg-2); border: 1px solid var(--line);
  transition: border-color .2s;
}
.themetog::after { content: ''; position: absolute; inset: -7px 0; }   /* a 44px-tall target */
.themetog:hover { border-color: var(--accent-strong); }
.themetog__thumb {
  position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--mark); color: var(--on-mark);
  transition: transform .3s var(--ease);
}
.themetog__ico { grid-area: 1 / 1; }
.themetog__ico--moon { display: none; }
:root[data-theme="dark"] .themetog__thumb { transform: translateX(26px); }
:root[data-theme="dark"] .themetog__ico--sun { display: none; }
:root[data-theme="dark"] .themetog__ico--moon { display: block; }

/* ── buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: .55rem 1.15rem;
  border: 1.5px solid var(--ink); border-radius: 999px;
  font-weight: 600; text-decoration: none; text-align: center;
  transition: background-color .15s, color .15s, border-color .15s;
}
.btn:hover { background: var(--ink); color: var(--bg); }
.btn--primary { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }
.btn--primary:hover { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn[aria-pressed="true"] { background: var(--mark); border-color: var(--mark); color: var(--on-mark); }

/* ── video: a button until it is pressed ────────────────────── */
.vid {
  position: relative; aspect-ratio: 16 / 9;
  display: grid; align-content: center; justify-items: center; gap: .6rem;
  padding: 1.25rem;
  background: var(--stage); color: var(--on-stage);
  /* In the dark themes the panel is close to the page color; the line keeps
     its edge. */
  border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden; text-align: center;
}
.vid__play {
  display: grid; justify-items: center; gap: .8rem;
  padding: .5rem 1rem; border-radius: 12px;
  font-weight: 600; font-size: var(--step-1); line-height: 1.25;
}
.vid__icon {
  width: 76px; height: 76px; padding: 14px; border-radius: 50%;
  background: var(--mark); color: var(--on-mark);
  transition: transform .2s var(--ease);
}
.vid__play:hover .vid__icon { transform: scale(1.07); }
.vid__play:focus-visible { outline-color: var(--mark); }
.vid__note { font-size: var(--step--1); max-width: 34ch; }
.vid__alt { font-size: var(--step--1); }
.vid__alt a { text-decoration: underline; text-underline-offset: .18em; }
.vid__alt a:focus-visible { outline-color: var(--mark); }
.vid__frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ── borrow first, buy second ───────────────────────────────── */
.bb { display: grid; gap: 1.25rem; }
.bb__head { font-family: var(--font-ui); font-size: var(--step-1); font-weight: 700; letter-spacing: 0; }
.bb__borrow {
  padding: 1.35rem 1.4rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line); border-left: 6px solid var(--mark);
  border-radius: var(--r);
}
.bb__borrow > * + * { margin-top: .8rem; }
.bb__note { color: var(--ink-2); font-size: .95rem; max-width: 52ch; }
.bb__more { display: grid; gap: .5rem; font-size: .95rem; }
.bb__more a, .bb__stores a {
  color: var(--accent);
  text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: .18em;
}
.bb__buy { padding-inline: 1.4rem; }
.bb__buy > * + * { margin-top: .5rem; }
.bb__paid { font-weight: 500; color: var(--ink-2); }
.bb__disclosure { color: var(--ink-2); font-size: .95rem; max-width: 52ch; }
.bb__stores { display: grid; gap: .35rem; }
.bb__stores li, .bb__more li { line-height: 1.5; }

/* ── who is tied to what: a person and what is said about them ─ */
.ties { margin-top: 1.25rem; display: grid; }
.ties li { padding-block: 1rem; border-top: 1px solid var(--line); }
.ties__who { font-family: var(--font-ui); font-size: var(--step-0); font-weight: 700; letter-spacing: 0; }
.ties a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: .18em; }
.ties p { margin-top: .3rem; max-width: 60ch; }
.tag {
  display: inline-block; margin-right: .35rem; padding: .05rem .5rem;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 4px;
  font-family: var(--font-mono); font-size: .75rem; color: var(--ink-2);
}

/* ── footer ─────────────────────────────────────────────────── */
.foot {
  margin-top: clamp(2.5rem, 6vw, 5rem);
  padding-block: 2.25rem 2.75rem;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
  font-size: .95rem;
}
.foot .wrap { display: grid; gap: .6rem; }
.foot__sig { font-family: var(--font-display); font-weight: 600; font-size: var(--step-1); }
.foot__promise { color: var(--ink-2); }
.foot__links, .foot__contact { display: flex; flex-wrap: wrap; gap: .15rem 1.25rem; }
.foot a {
  display: inline-flex; align-items: center; min-height: 44px;
  color: var(--accent);
  text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: .18em;
}

/* ── the page that is not there ─────────────────────────────── */
.lost { padding-block: clamp(3rem, 10vw, 7rem); }
.lost > * + * { margin-top: 1rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media print {
  .nav__end, .skip, .vid, .needs-js { display: none !important; }
  .foot { background: none; }
}
