/* podcasts.kapps.dev — the family design system (ppll/DESIGN.md) with its own
   accent. Every value here is on DESIGN.md; do not add one that is not. */

:root {
  color-scheme: light dark;
  --bg: #ffffff; --fg: #0f1419; --muted: #536471;
  --line: #e1e8ed; --card: #f7f9f9;
  --accent: #b3501f;
  --danger: #b3261e; --tension: #8a6203;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --tag-fill: color-mix(in srgb, var(--fg) 8%, var(--bg));
  --tabs-h: 56px;
  --mini-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: 0.18s ease-out;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15202b; --fg: #f7f9f9; --muted: #8b98a5;
    --line: #38444d; --card: #1e2732;
    --accent: #f0a06a;
    --danger: #f2726a; --tension: #d4a336;
  }
}
:root[data-theme="dark"] {
  --bg: #15202b; --fg: #f7f9f9; --muted: #8b98a5;
  --line: #38444d; --card: #1e2732;
  --accent: #f0a06a;
  --danger: #f2726a; --tension: #d4a336;
}

@font-face {
  font-family: "Source Serif 4"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(/fonts/source-serif-4-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Source Serif 4"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(/fonts/source-serif-4-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ------------------------------------------------------------ base ---- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 400 0.95rem/1.6 var(--sans);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  padding-bottom: calc(var(--tabs-h) + var(--safe-b));
}
body[data-player] { padding-bottom: calc(var(--tabs-h) + var(--mini-h) + var(--safe-b)); }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
img { display: block; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg text { fill: currentColor; stroke: none; font: 600 7px var(--sans); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* THE RULE: what somebody wrote is set in the serif; what the site says is
   set in the sans. Episode and show titles, show notes and descriptions are
   theirs. Names of shows in meta rows, tags, times, chips, buttons are ours. */
.ep-title, .full-title, .notes, .show-desc, .hero-title, .ep-page h1 { font-family: var(--serif); }

/* ---------------------------------------------------------- header ---- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  height: 50px; padding: 0 0.7rem 0 1.25rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; font-size: 1.05rem; letter-spacing: -0.01em; }
.brand::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-right: 0.45rem; vertical-align: 0; }

/* -------------------------------------------------------- controls ---- */
/* Every control hits 44px whatever it looks like. */
.ctl {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 999px; color: var(--fg);
}
.ctl:active { background: var(--card); }
.ctl-lg { width: 56px; height: 56px; }
.ctl-lg svg { width: 32px; height: 32px; }
.ctl-lg svg text { font-size: 8px; }
.ctl-xl { width: 72px; height: 72px; background: var(--fg); color: var(--bg); }
.ctl-xl:active { background: var(--fg); opacity: 0.85; }
.ctl-xl svg { width: 36px; height: 36px; }
.ctl-xl svg path, .ctl svg .ic-play, .ctl svg .ic-pause { fill: currentColor; stroke: none; }
.ic-pause { display: none; }
[data-state="playing"] .ic-play { display: none; }
[data-state="playing"] .ic-pause { display: inline; }

.chip {
  display: inline-flex; align-items: center; gap: 0.3rem; height: 30px; padding: 0 0.75rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg);
  font-size: 0.85rem; font-weight: 500; white-space: nowrap; position: relative;
}
.chip::before { content: ""; position: absolute; inset: -7px 0; }
.chip[aria-pressed="true"], .chip.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.chip-row { display: flex; gap: 0.45rem; overflow-x: auto; padding: 0.65rem 1.25rem; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }

.tag {
  display: inline-block; padding: 0.1rem 0.4rem; border-radius: 4px; background: var(--tag-fill);
  font-size: 0.66rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; line-height: 1.3;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 44px; padding: 0 1.25rem; border-radius: 999px;
  background: var(--fg); color: var(--bg); font-weight: 600; font-size: 0.95rem;
}
.btn-ghost { background: var(--bg); color: var(--fg); border: 1px solid var(--line); }
.btn svg path { fill: currentColor; stroke: none; }
.btn:active { opacity: 0.85; }

/* ------------------------------------------------------------ art ---- */
.art { border-radius: 8px; background: var(--card); object-fit: cover; flex: none; }
.art-40 { width: 40px; height: 40px; }
.art-48 { width: 48px; height: 48px; }
.art-56 { width: 56px; height: 56px; }
.art-96 { width: 96px; height: 96px; }

/* ----------------------------------------------------------- lists ---- */
main { min-height: 60vh; }
.section-head { padding: 0.9rem 1.25rem 0.25rem; display: flex; align-items: baseline; justify-content: space-between; gap: 0.7rem; }
.section-head h1 { margin: 0; font-size: 1.5rem; font-weight: 600; letter-spacing: -0.015em; line-height: 1.2; }
.section-head .tag { position: relative; top: -2px; }

.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid; grid-template-columns: 48px 1fr 44px; gap: 0.7rem; align-items: center;
  padding: 0.65rem 0.7rem 0.65rem 1.25rem; border-bottom: 1px solid var(--line);
  position: relative;
}
.row-main { min-width: 0; }
.row-main a::after { content: ""; position: absolute; inset: 0; right: 60px; }
.ep-title {
  font-size: 1.05rem; font-weight: 500; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.meta { display: flex; flex-wrap: wrap; gap: 0 0.45rem; font-size: 0.78rem; color: var(--muted); line-height: 1.3; margin-top: 0.25rem; }
.meta b { font-weight: 600; color: var(--fg); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta .played { color: var(--accent); }
.row .ctl { justify-self: end; position: relative; z-index: 1; }
.row .ctl svg { width: 28px; height: 28px; }
.row .ctl .ic-play, .row .ctl .ic-pause { fill: currentColor; stroke: none; }
.row.is-playing .ctl { color: var(--accent); }
.row-bar { position: absolute; left: calc(1.25rem + 48px + 0.7rem); right: 0.7rem; bottom: 0; height: 2px; background: var(--line); }
.row-bar i { display: block; height: 100%; background: var(--accent); }
.row-done .ep-title { color: var(--muted); }

/* Shows list */
.show-row { grid-template-columns: 56px 1fr auto; }
.show-title { font-weight: 600; font-size: 0.95rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.show-row .chip { position: relative; z-index: 1; }

/* Show page hero */
.hero { display: grid; grid-template-columns: 96px 1fr; gap: 1.1rem; padding: 1.1rem 1.25rem 0.65rem; align-items: start; }
.hero-title { margin: 0; font-size: 1.5rem; line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; }
.hero-meta { margin-top: 0.25rem; font-size: 0.78rem; color: var(--muted); }
.hero-actions { display: flex; gap: 0.45rem; flex-wrap: wrap; padding: 0.45rem 1.25rem 0.7rem; }
.show-desc { padding: 0 1.25rem 0.7rem; margin: 0; font-size: 0.95rem; line-height: 1.6; color: var(--muted); }
.show-desc[data-clamp] { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.more { display: block; padding: 0 1.25rem 0.7rem; font-size: 0.85rem; color: var(--accent); font-weight: 500; min-height: 44px; }

/* Episode page */
.ep-page { padding: 1.1rem 1.25rem; }
.ep-page .art-96 { margin-bottom: 0.7rem; }
.ep-page h1 { margin: 0; font-size: 1.5rem; line-height: 1.25; font-weight: 500; }
.ep-page .meta { font-size: 0.85rem; margin: 0.45rem 0 0.9rem; }
.ep-page .meta a { font-weight: 600; color: var(--fg); }
.ep-actions { display: flex; gap: 0.45rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.notes { font-size: 1rem; line-height: 1.6; white-space: pre-line; overflow-wrap: anywhere; margin: 0; }
.notes a { color: var(--accent); }
.out { display: inline-flex; align-items: center; gap: 0.3rem; margin-top: 1.1rem; min-height: 44px; font-size: 0.85rem; color: var(--accent); font-weight: 500; }

/* Search */
.search-box { padding: 0.7rem 1.25rem; position: sticky; top: 50px; background: var(--bg); z-index: 4; }
.search-box input {
  width: 100%; height: 44px; padding: 0 1rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); font: inherit; font-size: 16px; /* 16px: iOS does not zoom */
}
.search-box input:focus { outline: 2px solid var(--fg); outline-offset: 1px; }
.sub-head { padding: 0.9rem 1.25rem 0.25rem; font-size: 0.72rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.dir-row { grid-template-columns: 56px 1fr auto; }

/* States */
.state { padding: 2.5rem 1.25rem; text-align: center; color: var(--muted); }
.state h2 { margin: 0 0 0.45rem; font-size: 1.05rem; font-weight: 600; color: var(--fg); }
.state p { margin: 0 0 1.1rem; }
.state.err h2 { color: var(--danger); }
.skel { padding: 0 1.25rem; }
.skel div { height: 72px; border-bottom: 1px solid var(--line); position: relative; }
.skel div::before { content: ""; position: absolute; left: 0; top: 12px; width: 48px; height: 48px; border-radius: 8px; background: var(--card); }
.skel div::after { content: ""; position: absolute; left: 60px; right: 60px; top: 18px; height: 12px; border-radius: 4px; background: var(--card); box-shadow: 0 22px 0 -2px var(--card); }
.load-more { display: flex; justify-content: center; padding: 1.1rem; }

/* ------------------------------------------------------------ tabs ---- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--bg); border-top: 1px solid var(--line);
}
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 0.66rem; font-weight: 600; color: var(--muted); }
.tabs a svg { width: 22px; height: 22px; }
.tabs a[aria-current="page"] { color: var(--fg); }
@media (min-width: 720px) {
  /* Desktop: the three sections sit in the header, centred over the column. */
  .tabs { top: 0; bottom: auto; left: 50%; right: auto; transform: translateX(-50%); height: 50px; padding: 0; border-top: 0; background: transparent; grid-template-columns: repeat(3, auto); gap: 1.5rem; z-index: 6; }
  .tabs a { flex-direction: row; gap: 0.45rem; font-size: 0.85rem; padding: 0 0.25rem; }
  .tabs a svg { display: none; }
  .tabs a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--accent); }
  body, body[data-player] { padding-bottom: calc(var(--mini-h) + 1rem); }
  .top-search { display: none; }
  main { max-width: 760px; margin: 0 auto; }
  .mini { max-width: 760px; margin: 0 auto; }
  .search-box { top: 50px; }
}

/* ---------------------------------------------------------- player ---- */
.player {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabs-h) + var(--safe-b)); z-index: 11;
  background: var(--bg); border-top: 1px solid var(--line);
}
@media (min-width: 720px) { .player { bottom: 0; } }
.player-progress { height: 2px; background: var(--line); }
.player-progress i { display: block; height: 100%; width: 0; background: var(--accent); }
.mini { display: grid; grid-template-columns: 40px 1fr 44px 44px; gap: 0.7rem; align-items: center; height: var(--mini-h); padding: 0 0.45rem 0 1.25rem; cursor: pointer; }
.mini-text { min-width: 0; }
.mini-title { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-sub { font-size: 0.78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-state="loading"] .mini-sub, [data-state="error"] .mini-sub { color: var(--tension); }
[data-state="error"] .mini-sub { color: var(--danger); }

.full { display: none; }
.player[data-open] .full {
  display: flex; flex-direction: column; align-items: center; gap: 1.1rem;
  position: fixed; inset: 0; background: var(--bg); padding: 1.1rem 1.25rem calc(1.5rem + var(--safe-b));
  overflow-y: auto; z-index: 12;
}
.player[data-open] .mini, .player[data-open] .player-progress { display: none; }
.full-close { align-self: flex-start; }
.full-art { width: min(280px, 70vw); height: min(280px, 70vw); border-radius: 12px; margin-top: auto; }
.full-text { text-align: center; max-width: 100%; }
.full-title { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-size: 1.05rem; font-weight: 500; line-height: 1.4; }
.full-show { display: block; margin-top: 0.25rem; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.scrub { width: 100%; max-width: 420px; }
.scrub input { width: 100%; margin: 0; accent-color: var(--accent); height: 44px; }
.times { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.transport { display: flex; align-items: center; gap: 1.5rem; }
.full-row { display: flex; align-items: center; gap: 0.7rem; margin-bottom: auto; }
.status { font-size: 0.78rem; color: var(--muted); min-width: 4rem; text-align: center; }
[data-state="error"] .status { color: var(--danger); }

@media (prefers-reduced-motion: no-preference) {
  .player-progress i, .row-bar i { transition: width var(--ease); }
}
