/* pod.0x13d.com — every episode of The Narrative Networks Podcast.
 *
 * Colour is the 0x13D Research web theme (_community/0x13d/brand/theme.css, rules in
 * THEME.md): light by default, dark only when the reader picks it with the header toggle
 * (html[data-theme="dark"], set by /theme.js before first paint). The token block below is a
 * verbatim copy of the brand file — change it there first. Components use the semantic tokens,
 * never literals. Fonts are this site's own (Archivo); only colour is shared.
 */

:root {
  color-scheme: light;

  /* paper and surfaces */
  --bg: #faf7f1;          /* paper */
  --bg-soft: #f3eee4;     /* paper-soft: side columns, bands */
  --surface: #fffdf8;     /* cards, panels, inputs */
  --surface-2: #f3eee4;   /* raised or hovered surface */
  --banner: #b7beaf;      /* the sage banner (workbook .page-banner) */
  --banner-ink: #11120f;
  --header-bg: #b7beaf;
  --header-ink: #11120f;
  --header-shadow: 0px 0px 25px 0px;

  /* ink */
  --ink: #11120f;         /* headings, primary text */
  --ink-2: #2b2a26;       /* body text */
  --ink-soft: #5d5b54;    /* secondary text (≥ 4.5:1 on --bg) */
  --ink-faint: #6b6860;   /* micro labels, captions (≥ 4.5:1 on --bg and --bg-soft) */
  --rule: #e2ddd2;        /* hairlines */
  --rule-strong: #c9c2b4; /* control borders */

  /* accents */
  --accent: #3a3a3a;      /* charcoal: primary buttons, selected state */
  --accent-ink: #faf7f1;  /* text on --accent */
  --brass: #8a6d3b;       /* the one warm accent: focus, emphasis */
  --link: #6f5528;        /* brass, darkened for text contrast */
  --link-hover: #11120f;
  --focus: #8a6d3b;

  /* the footer is constant across themes (portfolio web standard) */
  --footer-bg: #3a3a3a;
  --footer-ink: #faf7f1;
  --footer-accent: #cbb88f;

  /* status (fact-check and fidelity codes) — always with a glyph or label */
  --good: #3f7a3a;
  --warn: #b07a1a;
  --bad: #b8412c;
  --neutral: #8e8b82;

  /* data: who acted (categorical, validated on --surface), and our own research */
  --side-gop: #c94f4f;
  --side-dem: #2f6fc4;
  --side-courts: #157d59;
  --side-agency: #b07a1a;
  --side-foreign: #a2479a;
  --research: #6a5fd0;
  --hatch: #d9d3c6;

  --shadow: 0 1px 12px rgba(17, 18, 15, 0.06);
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #14130f;
  --bg-soft: #1b1a16;
  --surface: #201f1a;
  --surface-2: #28271f;
  --banner: #3a4036;
  --banner-ink: #ece8de;
  --header-bg: #3a4036;
  --header-ink: #ece8de;
  --header-shadow: 0px 0px 25px 0px rgba(0, 0, 0, 0.6);

  --ink: #ece8de;
  --ink-2: #d6d1c5;
  --ink-soft: #aba699;
  --ink-faint: #908b7f;
  --rule: #2e2c26;
  --rule-strong: #46433a;

  --accent: #e6e0d2;
  --accent-ink: #14130f;
  --brass: #c9a86a;
  --link: #d8bc84;
  --link-hover: #ece8de;
  --focus: #c9a86a;

  --footer-bg: #3a3a3a;
  --footer-ink: #faf7f1;
  --footer-accent: #cbb88f;

  --good: #6fae63;
  --warn: #d9a441;
  --bad: #e2694f;
  --neutral: #8a8579;

  --side-gop: #e66767;
  --side-dem: #3987e5;
  --side-courts: #199e70;
  --side-agency: #b8801c;
  --side-foreign: #c15fb0;
  --research: #9085e9;
  --hatch: #3a3831;

  --shadow: 0 1px 12px rgba(0, 0, 0, 0.35);
}

/* project tokens — layout and type only, plus one colour derived from the constant footer */
:root {
  --measure: 42rem;
  --display: "Archivo Black", "Arial Black", Impact, sans-serif;
  --text: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --footer-muted: color-mix(in srgb, var(--footer-ink) 72%, var(--footer-bg));
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink-2);
  font-family: var(--text);
  font-size: 17px;
  line-height: 1.6;
}

a { color: inherit; text-decoration-color: var(--brass); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--link-hover); text-decoration-color: var(--link-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── site header ──────────────────────────────────────────────────────────────
   The shared 0x13d::Research bar: /brand/brand.css, copied from _community/0x13d/brand/web by
   scripts/sync-brand.mjs. Nothing about the bar is styled here. */

/* ── masthead ─────────────────────────────────────────────────────────────── */

.masthead {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: clamp(1.25rem, 4vw, 2.5rem);
  align-items: center;
  max-width: 64rem;
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 3.5rem) 16px clamp(1.5rem, 4vw, 2.5rem);
}
.masthead__cover {
  width: clamp(96px, 20vw, 168px); height: auto; aspect-ratio: 1;
  border-radius: 6px; display: block;
}
.masthead__kicker {
  margin: 0 0 .35rem;
  font-weight: 700; font-size: .75rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink-faint);
}
.masthead__title {
  margin: 0;
  font-family: var(--display); font-weight: 400;
  font-size: clamp(1.9rem, 6vw, 3.4rem); line-height: 1.02; letter-spacing: -0.015em;
  color: var(--ink);
}
.masthead__line { margin: .8rem 0 0; max-width: var(--measure); color: var(--ink-soft); }

.subscribe { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.1rem; }
.subscribe a {
  font-weight: 700; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase;
  text-decoration: none;
  padding: .45rem .8rem; border: 1px solid var(--rule-strong); border-radius: 999px;
  color: var(--ink);
}
.subscribe a:first-child { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.subscribe a:hover { border-color: var(--brass); color: var(--ink); }
.subscribe a:first-child:hover { background: var(--ink); border-color: var(--ink); color: var(--accent-ink); }

@media (max-width: 560px) {
  .masthead { grid-template-columns: 1fr; }
}

/* ── filter ───────────────────────────────────────────────────────────────── */

main { max-width: 64rem; margin: 0 auto; padding: 0 16px; }

.filter {
  position: sticky; top: var(--x13-sticky, 0px); z-index: 2;
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem;
  padding: .9rem 0; margin-bottom: .5rem;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.filter input {
  flex: 1 1 18rem; min-width: 0;
  font: inherit; font-size: 1rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: 6px;
  padding: .55rem .8rem;
}
.filter input::placeholder { color: var(--ink-faint); }
.filter input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.filter__kinds { display: flex; flex-wrap: wrap; gap: .35rem; }
.filter__kinds button {
  font: inherit; font-weight: 700; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-soft); background: none; cursor: pointer;
  border: 1px solid var(--rule-strong); border-radius: 999px; padding: .35rem .7rem;
}
.filter__kinds button:hover { color: var(--ink); border-color: var(--ink-soft); }
.filter__kinds button[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.filter__count { margin: 0; flex-basis: 100%; font-size: .8rem; color: var(--ink-faint); }

/* ── the list ─────────────────────────────────────────────────────────────── */

.episodes { list-style: none; margin: 0; padding: 0; }

.ep {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 1.25rem;
  padding: 1.6rem 0;
  border-bottom: 1px solid var(--rule);
}
.ep[hidden] { display: none; }
.ep__art img { display: block; width: 112px; height: 112px; object-fit: cover; border-radius: 4px; background: var(--surface-2); }
.ep__body { min-width: 0; }

.ep__meta {
  margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .15rem .45rem;
  font-size: .8rem; color: var(--ink-soft); font-variant-numeric: tabular-nums;
}
.ep__num { font-weight: 700; color: var(--ink); }
.dot { color: var(--ink-faint); }
.chip {
  font-weight: 700; font-size: .68rem; letter-spacing: .12em; text-transform: uppercase;
  padding: .1rem .45rem; border-radius: 3px; border: 1px solid var(--rule-strong); color: var(--ink);
}
.chip--pulse { border-color: var(--brass); }
.chip--founding { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.ep__title {
  margin: .35rem 0 0;
  font-family: var(--display); font-weight: 400;
  font-size: clamp(1.1rem, 2.6vw, 1.35rem); line-height: 1.22; letter-spacing: -0.005em;
  overflow-wrap: anywhere;
  color: var(--ink);
}
.ep__title a { text-decoration: none; }
.ep__title a:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--brass); }

.ep__checked, .episode .ep__checked { margin: .35rem 0 0; font-size: .85rem; color: var(--ink-soft); }
.ep__checked strong { color: var(--ink); font-weight: 600; }

.ep__lede { margin: .55rem 0 0; max-width: var(--measure); color: var(--ink-2); }
/* feed notes can carry bare URLs; let them wrap instead of widening the page */
.ep__lede, .episode__notes { overflow-wrap: anywhere; }

.ep__audio { display: block; width: 100%; max-width: 32rem; height: 36px; margin-top: .9rem; }

@media (max-width: 560px) {
  .ep { grid-template-columns: 64px 1fr; gap: .9rem; }
  .ep__art img { width: 64px; height: 64px; }
  .ep__lede { font-size: .95rem; }
}

/* ── episode page ─────────────────────────────────────────────────────────── */

.crumb {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  max-width: 48rem; margin: 0 auto; padding: 1.5rem 16px 0; font-size: .85rem;
}
.crumb > a { min-width: 0; text-decoration: none; color: var(--ink-soft); }
.crumb > a:hover { color: var(--ink); }

.episode { max-width: 48rem; padding-top: 1.5rem; }
.episode__head { display: grid; grid-template-columns: auto 1fr; gap: 1.5rem; align-items: end; }
.episode__cover { width: clamp(112px, 26vw, 240px); height: auto; aspect-ratio: 1; border-radius: 6px; display: block; }
.episode__title {
  margin: .4rem 0 0;
  font-family: var(--display); font-weight: 400;
  font-size: clamp(1.5rem, 4.5vw, 2.4rem); line-height: 1.08; letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  color: var(--ink);
}
.episode .ep__audio { max-width: none; margin-top: 1.75rem; height: 44px; }
.episode__links { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; margin: 1rem 0 0; font-size: .9rem; }
.episode__links a, .episode__notes a, .episode__voice a { color: var(--link); }
.episode__links a:hover, .episode__notes a:hover, .episode__voice a:hover { color: var(--link-hover); }
.episode__notes { margin-top: 2rem; max-width: var(--measure); }
.episode__notes p { margin: 0 0 1.05em; }
.episode__notes p:first-child { font-size: 1.12rem; color: var(--ink); }
.episode__voice { margin: 2rem 0 0; font-size: .9rem; color: var(--ink-soft); }

@media (max-width: 560px) {
  .episode__head { grid-template-columns: 1fr; }
}

.pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
  margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--rule);
}
.pager a { text-decoration: none; font-size: .9rem; line-height: 1.35; color: var(--ink-soft); }
.pager a span { display: block; font-weight: 700; font-size: .75rem; letter-spacing: .1em; color: var(--ink); margin-bottom: .2rem; }
.pager a:hover { color: var(--ink); }
.pager__newer { text-align: right; }

/* ── colophon ─────────────────────────────────────────────────────────────── */

/* The footer is the portfolio's constant: #3a3a3a in both themes (THEME.md). It runs full
   width; the inner measure comes from padding so its text lines up with the page above. */
.colophon {
  margin: 3rem 0 0; padding: 2rem max(16px, calc((100% - 64rem) / 2 + 16px)) 3rem;
  background: var(--footer-bg); color: var(--footer-muted);
  font-size: .85rem;
}
.page-episode .colophon { padding-left: max(16px, calc((100% - 48rem) / 2 + 16px)); padding-right: max(16px, calc((100% - 48rem) / 2 + 16px)); }
.colophon > p { margin: 0 0 .5rem; max-width: var(--measure); }
.colophon a { color: var(--footer-ink); text-decoration-color: var(--footer-accent); }
.colophon a:hover { color: var(--footer-accent); text-decoration-color: var(--footer-accent); }
.colophon__imprint { font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--footer-accent); font-size: .72rem; }
.colophon__stamp { color: var(--footer-muted); font-size: .75rem; margin-top: 1rem !important; }

/* ── theme toggle ─────────────────────────────────────────────────────────── */
/* It lives in the shared bar, which draws it (brand.css); this is the fallback look. */

/* The toggle: one button, the same on every surface. Markup:
 *   <button type="button" class="theme-toggle" data-theme-toggle aria-label="Switch to dark theme">
 *     <span class="theme-toggle__icon" aria-hidden="true"></span><span class="theme-toggle__label">Dark</span>
 *   </button>
 * theme.js keeps aria-label, aria-pressed and the label in sync. */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 0 10px; border-radius: 6px;
  border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink-2);
  font: inherit; font-size: 12px; cursor: pointer;
}
.theme-toggle:hover { border-color: var(--ink-soft); color: var(--ink); }
.theme-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.theme-toggle__icon { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid currentColor; background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
