/* ═══════════════════════════════════════════════════════════════════
   RoboMatt — shared styles for the homepage and episode pages.

   Every colour here is sampled from the cover artwork: cream paper,
   marigold lettering, a periwinkle disc, warm charcoal line art.
   Light mode is the artwork's own palette; dark mode is the periwinkle
   disc darkened into a night ground, which keeps marigold complementary.

   Marigold never carries text — it fails contrast on cream at ~1.9:1.
   It is brand, active state, and fills only; --link carries anything
   readable or clickable.
   ═══════════════════════════════════════════════════════════════════ */

/* Elevation ladder, consistent across themes: inset < ground < panel <
   surface. Light steps darker from the ground, dark steps lighter. */
:root {
  --inset:      #F3EADA;
  --paper:      #FDF7EC;
  --panel:      #F7EFE0;
  --surface:    #FFFDF7;
  --ink:        #33302B;
  --ink-soft:   #6F6659;
  --muted:      #8C8275;
  --hairline:   #EDE3D1;
  --marigold:   #F2A32C;
  --marigold-wash: #FCEFD6;
  --periwinkle: #A4BBD8;
  --link:       #3F6489;
  --danger:     #A63D2F;
  --lift: 0 1px 1px rgba(120, 92, 46, .04), 0 10px 28px -12px rgba(120, 92, 46, .16);
  --lift-sm: 0 1px 2px rgba(120, 92, 46, .05);
  --cover-ring: transparent;

  --display: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", system-ui, -apple-system, sans-serif;
  --body: Charter, "Bitstream Charter", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --inset:      #151C27;
    --paper:      #1B2230;
    --panel:      #212A38;
    --surface:    #27313F;
    --ink:        #E6EBF2;
    --ink-soft:   #B9C4D4;
    --muted:      #93A0B4;
    --hairline:   #313C4D;
    --marigold:   #F6B455;
    --marigold-wash: rgba(246, 180, 85, .14);
    --periwinkle: #9FC0E4;
    --link:       #A9C7E8;
    --danger:     #F1907E;
    --lift: 0 1px 1px rgba(0, 0, 0, .22), 0 14px 32px -14px rgba(0, 0, 0, .55);
    --lift-sm: 0 1px 2px rgba(0, 0, 0, .25);
    --cover-ring: rgba(230, 238, 250, .12);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --inset:      #151C27;
  --paper:      #1B2230;
  --panel:      #212A38;
  --surface:    #27313F;
  --ink:        #E6EBF2;
  --ink-soft:   #B9C4D4;
  --muted:      #93A0B4;
  --hairline:   #313C4D;
  --marigold:   #F6B455;
  --marigold-wash: rgba(246, 180, 85, .14);
  --periwinkle: #9FC0E4;
  --link:       #A9C7E8;
  --danger:     #F1907E;
  --lift: 0 1px 1px rgba(0, 0, 0, .22), 0 14px 32px -14px rgba(0, 0, 0, .55);
  --lift-sm: 0 1px 2px rgba(0, 0, 0, .25);
  --cover-ring: rgba(230, 238, 250, .12);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --inset:      #F3EADA;
  --paper:      #FDF7EC;
  --panel:      #F7EFE0;
  --surface:    #FFFDF7;
  --ink:        #33302B;
  --ink-soft:   #6F6659;
  --muted:      #8C8275;
  --hairline:   #EDE3D1;
  --marigold:   #F2A32C;
  --marigold-wash: #FCEFD6;
  --periwinkle: #A4BBD8;
  --link:       #3F6489;
  --danger:     #A63D2F;
  --lift: 0 1px 1px rgba(120, 92, 46, .04), 0 10px 28px -12px rgba(120, 92, 46, .16);
  --lift-sm: 0 1px 2px rgba(120, 92, 46, .05);
  --cover-ring: transparent;
  color-scheme: light;
}

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s ease, color .3s ease;
}

a { color: var(--link); text-underline-offset: 3px; }

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

.page {
  max-width: 1020px;
  margin: 0 auto;
  padding: clamp(24px, 5vw, 56px) clamp(20px, 5vw, 40px) 64px;
  display: flex;
  flex-direction: column;
  gap: clamp(28px, 4vw, 44px);
}

.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;
}

/* ───────────────── Masthead ───────────────── */
.masthead {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2.5vw, 20px);
}

.masthead-text { flex: 1; min-width: 0; }

.wordmark {
  font-family: var(--display);
  font-size: clamp(30px, 6vw, 40px);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.05;
  color: var(--ink);
}

.home-link { color: inherit; text-decoration: none; }
.home-link:hover { color: var(--marigold); }

/* The one surviving piece of terminal: a mono tilde on a rounded wordmark. */
.wordmark .tilde {
  font-family: var(--mono);
  font-size: .52em;
  font-weight: 400;
  color: var(--marigold);
  letter-spacing: 0;
  vertical-align: .28em;
  margin-right: .1em;
}

.tagline {
  margin-top: 4px;
  font-family: var(--body);
  font-style: italic;
  font-size: clamp(15px, 2.5vw, 17px);
  color: var(--ink-soft);
}

.theme-toggle {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  box-shadow: var(--lift-sm);
  transition: color .2s ease, transform .2s ease;
}

.theme-toggle:hover { color: var(--marigold); transform: translateY(-1px); }
.theme-toggle svg { width: 18px; height: 18px; display: block; }

/* ───────────────── Section labels ───────────────── */
.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.eyebrow .tally { color: var(--periwinkle); font-variant-numeric: tabular-nums; }

/* ───────────────── Main grid ───────────────── */
.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr);
  gap: clamp(24px, 3.5vw, 40px);
  align-items: start;
}

/* ───────────────── Episode list ─────────────────
   No container, no border, no inner scroll. Rows on paper. */
.episodes { list-style: none; }

.ep {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: background .18s ease;
  position: relative;
}

.ep + .ep::before {
  content: "";
  position: absolute;
  top: 0;
  left: 14px;
  right: 14px;
  height: 1px;
  background: var(--hairline);
}

.ep:hover { background: var(--panel); }
.ep:hover::before,
.ep:hover + .ep::before { background: transparent; }

.ep[aria-current="true"] { background: var(--marigold-wash); }
.ep[aria-current="true"]::before,
.ep[aria-current="true"] + .ep::before { background: transparent; }

.ep-title {
  font-family: var(--display);
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -.005em;
  color: var(--ink);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.ep-title .label { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.ep-meta {
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .02em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.ep-meta .dot { color: var(--hairline); }
.ep[aria-current="true"] .ep-meta { color: var(--ink-soft); }

/* Resume progress — data already kept in localStorage, finally visible. */
.progress {
  margin-top: 8px;
  height: 2px;
  border-radius: 2px;
  background: var(--hairline);
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--periwinkle);
  border-radius: 2px;
}

/* Equalizer: visibility follows selection, motion follows playback. */
.eq {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 13px;
  flex-shrink: 0;
  padding-top: 3px;
}

.eq i {
  width: 2.5px;
  border-radius: 2px;
  background: var(--marigold);
  height: 5px;
}

.eq i:nth-child(2) { height: 8px; }
.eq i:nth-child(3) { height: 6px; }

@keyframes eq { 0%, 100% { height: 5px; } 50% { height: 13px; } }

.ep[aria-current="true"] .eq { display: flex; }

.ep[aria-current="true"][data-playing="true"] .eq i {
  animation: eq 1s ease-in-out infinite;
}

.ep[aria-current="true"][data-playing="true"] .eq i:nth-child(2) { animation-delay: .22s; }
.ep[aria-current="true"][data-playing="true"] .eq i:nth-child(3) { animation-delay: .44s; }

/* ───────────────── Player / episode card ─────────────────
   The only raised surface on the page. */
.player {
  background: var(--surface);
  border-radius: 20px;
  padding: clamp(20px, 3vw, 28px);
  box-shadow: var(--lift);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.player-head { display: flex; gap: 18px; align-items: flex-start; }

.player-cover {
  width: clamp(84px, 16vw, 104px);
  height: clamp(84px, 16vw, 104px);
  border-radius: 14px;
  flex-shrink: 0;
  display: block;
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--cover-ring), var(--lift-sm);
}

.player-headings { min-width: 0; flex: 1; }

.now-title {
  font-family: var(--display);
  font-size: clamp(21px, 3.4vw, 27px);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -.018em;
  color: var(--ink);
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.now-meta {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.now-meta .dot { color: var(--hairline); text-transform: none; }
.now-meta .error-value { color: var(--danger); }

.summary {
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink-soft);
  max-width: 62ch;
}

.summary p + p { margin-top: .8em; }
.summary a { color: var(--link); }

/* Transcript link belongs with the description, right-aligned above the
   player — keeping it out of .player-foot so its → doesn't collide with
   the ← on "All episodes". */
.description-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.transcript-link {
  align-self: flex-end;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .02em;
  color: var(--link);
  text-decoration: none;
}

.transcript-link:hover { text-decoration: underline; }

/* The native <audio> stays — it just gets seated so it reads as intentional. */
.transport {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--inset);
  border-radius: 14px;
  padding: 10px;
}

.transport audio { flex: 1; min-width: 0; height: 36px; }

.rate {
  flex-shrink: 0;
  min-width: 50px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  box-shadow: var(--lift-sm);
  transition: color .2s ease, transform .2s ease;
}

.rate:hover { color: var(--marigold); transform: translateY(-1px); }

.player-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .02em;
}

.player-foot a { color: var(--link); text-decoration: none; }
.player-foot a:hover { text-decoration: underline; }

/* Audio errors are the one status worth showing; everything else the
   native controls already say. */
.player-error {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--danger);
}

.retry {
  align-self: flex-start;
  min-height: 44px;
  padding: 0 18px;
  border: none;
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--lift-sm);
  font-family: var(--display);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color .2s ease, transform .2s ease;
}

.retry:hover { color: var(--marigold); transform: translateY(-1px); }

/* ───────────────── Skeletons ───────────────── */
@keyframes pulse { 0%, 100% { opacity: .45; } 50% { opacity: .85; } }

.sk { background: var(--hairline); border-radius: 6px; animation: pulse 1.5s ease-in-out infinite; }

.sk-row { padding: 12px 14px; display: flex; flex-direction: column; gap: 7px; }
.sk-row .sk-title { height: 15px; width: 82%; }
.sk-row .sk-meta { height: 11px; width: 42%; }

.sk-cover { width: clamp(84px, 16vw, 104px); height: clamp(84px, 16vw, 104px); border-radius: 14px; flex-shrink: 0; }
.sk-line { height: 14px; }
.sk-line-1 { width: 70%; }
.sk-line-2 { width: 45%; }
.sk-transport { height: 56px; border-radius: 14px; }

/* ───────────────── Subscribe ───────────────── */
.subscribe {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: clamp(20px, 3vw, 26px);
  border-radius: 18px;
  background: var(--panel);
}

.subscribe h2 {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -.01em;
}

.subscribe-head p {
  margin-top: 4px;
  font-size: 14.5px;
  color: var(--ink-soft);
  max-width: 62ch;
}

.feed-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: none;
  border-radius: 12px;
  font-family: var(--display);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform .18s ease, filter .18s ease;
}

.btn:hover { transform: translateY(-1px); filter: brightness(.97); }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-primary { background: var(--marigold); color: #3A2A08; }
.btn.copied { background: var(--periwinkle); color: #1E2A38; }

/* App shortcuts fire each app's URL scheme, so they only do anything if
   that app is installed. Nothing can detect that — hence the label. */
.apps-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.apps { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--lift-sm);
  font-family: var(--display);
  font-size: 13.5px;
  font-weight: 550;
  text-decoration: none;
  transition: transform .18s ease, color .18s ease;
}

.chip:hover { transform: translateY(-1px); color: var(--marigold); }
.chip .arrow { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.chip:hover .arrow { color: var(--marigold); }

/* ───────────────── Manual fallback ───────────────── */
.manual { border-top: 1px solid var(--hairline); padding-top: 16px; }

.manual summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  font-family: var(--display);
  font-size: 14.5px;
  font-weight: 550;
  color: var(--link);
}

.manual summary::-webkit-details-marker { display: none; }

.manual summary::before {
  content: "+";
  font-family: var(--mono);
  font-size: 15px;
  color: var(--marigold);
}

.manual[open] summary::before { content: "–"; }

.manual-body { padding-top: 12px; font-size: 14.5px; color: var(--ink-soft); }

.manual-body h3 {
  font-family: var(--display);
  font-size: 14px;
  font-weight: 650;
  color: var(--ink);
  margin: 16px 0 6px;
}

.manual-body h3:first-child { margin-top: 0; }
.manual-body ol { padding-left: 1.3em; }
.manual-body li { margin-bottom: 3px; }
.manual-body p { max-width: 62ch; }
.manual-body b { color: var(--ink); font-weight: 600; }

/* One click selects the whole URL for anyone pasting by hand. */
.feed-url {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--inset);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-soft);
  word-break: break-all;
  user-select: all;
}

/* ───────────────── Episode page actions ───────────────── */
.actions { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; }

.action-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--lift-sm);
  font-family: var(--display);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: transform .18s ease, color .18s ease;
}

.action-link:hover { transform: translateY(-1px); color: var(--marigold); }

/* ───────────────── Footer ───────────────── */
.foot {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.75;
  border-top: 1px solid var(--hairline);
  padding-top: 24px;
}

.foot a { color: var(--link); }

/* ───────────────── Responsive ─────────────────
   Player first on narrow screens, and the list stays a list. */
@media (max-width: 860px) {
  .stage { grid-template-columns: 1fr; }
  .stage .col-player { order: -1; }
}

@media (max-width: 520px) {
  .player-head { gap: 14px; }
  .summary { font-size: 14.5px; }
}

@media (prefers-reduced-motion: reduce) {
  /* Bars keep their resting heights; only the motion goes away. */
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
