/* RSS Replay — design tokens and components (audit §5).
   Dependency-free. Color roles switch for dark mode via
   `prefers-color-scheme`, so no JavaScript is needed for theming. */

:root {
  color-scheme: light dark;

  /* Type scale (rem). */
  --text-caption: 0.8125rem;
  --text-body: 1rem;
  --text-lead: 1.125rem;
  --text-h3: 1.375rem;
  --text-h2: 1.75rem;
  --text-h1: 2.25rem;

  /* Spacing scale (4px base). */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  /* Selects reserve room for the dropdown arrow, which lets short rate fields
     collapse; inline controls opt out with this width. */
  --field-gap: 8rem;

  --radius: 6px;
  --radius-lg: 8px;
  --measure: 46rem;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Color roles — light. */
  --bg: #ffffff;
  --surface: #f6f6f7;
  --surface-2: #ececef; /* inner tier: fields, nested tables, popover fills */
  --text: #1a1a1a;
  --text-muted: #5c5c5c;
  --border: #d9d9d9;
  --accent: #0b57d0;
  --on-accent: #ffffff;
  --danger: #b3261e;
  --on-danger: #ffffff;
  --success: #1a7f37;
  --warning: #8a5300;
  --info: #0b57d0;
  --shadow-pop: 0 6px 16px rgb(0 0 0 / 18%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --surface: #1e1e1e;
    --surface-2: #26262a;
    --text: #f2f2f2;
    --text-muted: #b0b0b0;
    --border: #3a3a3a;
    --accent: #9ecbff;
    --on-accent: #10233a;
    --danger: #ffb4ab;
    --on-danger: #3b0a06;
    --success: #7ee2a8;
    --warning: #ffd479;
    --info: #9ecbff;
    /* A 18% black shadow is nearly invisible on the dark bg; use the standard
       "lifted layer" black for elevation in dark mode. */
    --shadow-pop: 0 6px 16px rgb(0 0 0 / 55%);
  }
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  max-width: var(--measure);
  margin: var(--space-6) auto;
  padding: 0 var(--space-4);
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: var(--space-4) 0 var(--space-2);
}

h1 {
  font-size: var(--text-h1);
  font-weight: 700;
}
h2 {
  font-size: var(--text-h2);
  font-weight: 600;
}
h3 {
  font-size: var(--text-h3);
  font-weight: 600;
}

p {
  margin: var(--space-3) 0;
}

a {
  color: var(--accent);
}

.muted {
  color: var(--text-muted);
}

/* Monospace runs (rate examples, URLs, counts) — previously an undefined
   class that silently fell back to the body font. */
.mono {
  font-family: var(--font-mono);
}

/* A "nothing more to show" state (archive exhausted, skipped, never fetched).
   Reads through weight + a small neutral glyph, not through color alone, so it
   stays legible in dark mode and for users who don't read color. */
.state-none {
  color: var(--text-muted);
  font-weight: 600;
}
.state-none::before {
  content: "\2205"; /* ∅ */
  margin-right: var(--space-1);
  opacity: 0.55;
}

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

/* Skip link: off-screen until focused, then pinned to the top-left so it never
   sits half-clipped above the viewport (audit A2).  On :focus it jumps the user
   straight to <main id="main">, past the whole navigation bar. */
.skip-link {
  position: absolute;
  left: var(--space-4);
  top: 0;
  transform: translateY(-150%);
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 10;
}
.skip-link:focus {
  transform: translateY(var(--space-2));
}

/* ---- Navigation ---- */
.site-nav {
  display: flex;
  gap: var(--space-4);
  align-items: baseline;
  flex-wrap: wrap;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}
.site-nav__brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}
.site-nav__links {
  display: flex;
  gap: var(--space-4);
  align-items: baseline;
  flex-wrap: wrap;
}
.site-nav__link {
  padding: var(--space-1) 0;
  color: var(--accent);
  text-decoration: none;
}
.site-nav__link:hover {
  text-decoration: underline;
}
.site-nav__link.is-active {
  color: var(--text);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.site-nav__spacer {
  flex: 1;
}

/* ---- Messages (audit V5) ---- */
.messages {
  list-style: none;
  padding: 0;
  margin: var(--space-4) 0;
}
.messages__item {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-3);
  margin: var(--space-2) 0;
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.messages__item::before {
  font-weight: 700;
  line-height: 1.5;
}
.messages__item.success {
  border-left-color: var(--success);
  color: var(--success);
}
.messages__item.success::before {
  content: "\2713"; /* check */
}
.messages__item.error {
  border-left-color: var(--danger);
  color: var(--danger);
}
.messages__item.error::before {
  content: "\26A0"; /* warning sign */
}
.messages__item.warning {
  border-left-color: var(--warning);
  color: var(--warning);
}
.messages__item.warning::before {
  content: "\26A0";
}
.messages__item.info {
  border-left-color: var(--info);
  color: var(--info);
}
.messages__item.info::before {
  content: "\2139"; /* info */
}

/* ---- Forms ---- */
.field {
  margin: var(--space-3) 0;
}
.field > label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-1);
}
.field input[type="text"],
.field input[type="url"],
.field input[type="email"],
.field input[type="password"],
.field select {
  width: 100%;
  max-width: 30rem;
}
input[type="text"],
input[type="url"],
input[type="email"],
input[type="password"],
input[type="search"],
select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  min-height: 40px;
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
/* A bare select (e.g. the rate box) has no intrinsic width and collapses to a
   sliver; give it room and let the action forms stretch it if they like. */
select {
  min-width: var(--field-gap);
}
.field select {
  min-width: 0;
}
.actions select {
  flex: 1 1 var(--field-gap);
}
input[type="text"],
input[type="url"],
input[type="email"],
input[type="password"],
code {
  font-family: var(--font-mono);
}
.help {
  color: var(--text-muted);
  font-size: var(--text-caption);
  margin: var(--space-1) 0 0;
}
.errorlist {
  color: var(--danger);
  list-style: none;
  padding: 0;
  margin: var(--space-1) 0;
}

/* ---- Buttons (audit V4) ---- */
.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font: inherit;
  font-weight: 600;
  min-height: 40px;
  padding: var(--space-2) var(--space-3);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
/* A link styled as a button (e.g. "Open") must read as one, not as body copy:
   drop the anchor's underline and keep the button's own text color. */
a.btn,
a.btn:hover {
  color: var(--text);
  text-decoration: none;
}
.btn:hover,
button:hover:not(:disabled) {
  border-color: var(--accent);
}
/* A press state so a held button reads as engaged, not just hovered. */
.btn:active:not(:disabled),
button:active:not(:disabled) {
  transform: translateY(1px);
}
.btn--primary {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}
.btn--danger {
  color: var(--on-danger);
  background: var(--danger);
  border-color: var(--danger);
}
.btn:disabled,
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn--sm {
  min-height: 32px;
  padding: var(--space-1) var(--space-2);
  font-weight: 400;
}

/* Per-row rewind / fast-forward (⏮ / ⏭): compact, square glyph buttons that sit
   together at the end of a schedule row.  The disabled one must read as
   obviously inert at a glance — the enabled/disabled pair is what tells the
   reader which direction is possible for that row. */
.row-actions {
  white-space: nowrap;
}
.row-actions form {
  display: inline-flex;
  gap: var(--space-1);
  margin: 0;
}
.btn--glyph {
  min-width: 40px;
  font-size: 1rem;
  line-height: 1;
}
.btn--glyph:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  border-style: dashed;
}

.btn.is-loading::after {
  content: "";
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
  margin: var(--space-3) 0;
}
/* The inline "Other rate" box on the catalog: wide enough for its example. */
.input--rate {
  width: var(--field-gap);
}
/* The catalog's "other" box and its help text sit in one wrapper the JS reveals
   together; without JavaScript both stay visible.  The explicit display rule
   beats the UA `[hidden]` rule, so the hidden state needs its own. */
.rate-other {
  display: flex;
  flex-direction: column;
  flex: 1 1 var(--field-gap);
}
.rate-other[hidden] {
  display: none;
}
form.inline {
  display: inline;
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin: var(--space-4) 0;
}
.card > :first-child {
  margin-top: 0;
}
.card > :last-child {
  margin-bottom: 0;
}
.card__title {
  margin-top: 0;
}
/* Auth forms and other short single-column content get a narrower card so the
   page doesn't stretch a small form across the full measure. */
.card--narrow {
  max-width: 26rem;
}

/* Page-level status heading (e.g. "Account verified").  Pairs a status color
   with the heading's own text, so color is never the only cue. */
.status--success {
  color: var(--success);
}
.status--error {
  color: var(--danger);
}

/* ---- Empty states (audit X2/L5) ---- */
/* One pattern everywhere a list can be empty: a short heading, a sentence,
   and (where there is one) a single primary action.  The dashed border reads
   as a placeholder rather than a filled card. */
.empty-state {
  padding: var(--space-5) var(--space-4);
  margin: var(--space-4) 0;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  text-align: center;
}
.empty-state__title {
  margin: 0 0 var(--space-2);
  color: var(--text);
  font-size: var(--text-h3);
}
/* A primer's numbered steps still read left-to-right inside the centered box. */
.empty-state ol {
  display: inline-block;
  text-align: left;
}
.empty-state > :last-child {
  margin-bottom: 0;
}

/* ---- Tables (audit V3) ---- */
.table {
  border-collapse: collapse;
  width: 100%;
  margin: var(--space-3) 0;
  background: var(--surface-2);
  border-radius: var(--radius);
}
.table th,
.table td {
  text-align: left;
  vertical-align: top;
  padding: var(--space-2) var(--space-2);
}
.table td {
  border-top: 1px solid var(--border);
}
.table thead th {
  font-size: var(--text-caption);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.table .dates {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
/* A source item's secondary line (its original publish date) sits under the
   title, smaller and muted (audit D5/L9). */
.item-meta {
  display: block;
  font-size: var(--text-caption);
}
.feed-artwork {
  display: inline-flex;
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  min-width: 64px;
  max-width: 64px;
  min-height: 64px;
  max-height: 64px;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  margin-right: var(--space-2);
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface-2);
}
.feed-artwork__image,
.feed-artwork__placeholder {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 64px;
  max-height: 64px;
  object-fit: cover;
}
.feed-artwork__placeholder {
  background: linear-gradient(135deg, var(--surface-2), var(--border));
}
.feed-artwork__image--detail {
  display: block;
  width: 128px;
  height: 128px;
  max-width: 128px;
  max-height: 128px;
  object-fit: cover;
  border-radius: var(--radius);
}
.feed-overview {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  margin: var(--space-4) 0;
}
.feed-overview__description {
  margin: 0;
  white-space: pre-line;
}
.feed-title {
  display: inline-block;
  vertical-align: middle;
}
.col-actions {
  width: 1%;
  white-space: nowrap;
}

/* ---- Chips and progress (audit D1) ---- */
.chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  padding: 0 var(--space-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
}
.progress {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 12rem;
}
.progress__track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  background: var(--accent);
}
.progress__label {
  font-size: var(--text-caption);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  white-space: nowrap;
}
/* The "n / m" count doubles as a tap/click target revealing when the feed
   finishes; <details> gives that for free, with no JavaScript. */
.progress__details {
  position: relative;
}
.progress__details > summary {
  cursor: pointer;
  list-style: none;
}
.progress__details > summary::-webkit-details-marker {
  display: none;
}
.progress__details > summary::after {
  /* A drawn "ⓘ": U+2139 renders as a bare letter, and the circled code points
     (U+24D8 / U+1F6C8) are missing from many fonts, so draw the ring instead.
     The ring speaks the same color language as the accent bar it annotates. */
  content: "i";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15em;
  height: 1.15em;
  margin-left: var(--space-1);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 50%;
  font-size: 0.75em;
  font-style: italic;
  line-height: 1;
  vertical-align: center;
}
.progress__finish {
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-1));
  z-index: 5;
  width: max-content;
  max-width: 16rem;
  margin: 0;
  padding: var(--space-2) var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  font-size: var(--text-caption);
  white-space: normal;
}

/* ---- Feed URL copy field (audit M1) ---- */
/* The URL takes the full width of the card, with Copy / Open / QR Code on one
   row below it, so a long capability URL never squeezes the buttons. */
.copy-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.copy-field__url {
  overflow-wrap: anywhere;
  padding: var(--space-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.copy-field__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  /* Anchors the QR popover: the panel hangs below the button row and is capped
     to this width, so it can never overflow the card on a narrow screen. */
  position: relative;
}

/* The QR popup: a native disclosure so it needs no JavaScript, positioned
   under the button row like the progress popover. */
.qr-popover > summary {
  list-style: none;
  cursor: pointer;
}
.qr-popover > summary::-webkit-details-marker {
  display: none;
}
.qr-popover__panel {
  position: absolute;
  left: 0;
  top: calc(100% + var(--space-1));
  z-index: 5;
  width: max-content;
  max-width: 100%;
  padding: var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
}
/* The QR keeps its own white quiet zone, so it stays scannable on any theme. */
.qr-popover__code {
  display: block;
  line-height: 0;
}
.qr-popover__code svg {
  display: block;
  width: 12rem;
  max-width: 100%;
  height: auto;
}
.qr-popover__panel .help {
  margin-top: var(--space-2);
}

/* ---- Single-feed page: pacing, rate editor, danger zone ---- */
/* The source feed is provenance, not a headline; a caption keeps it out of the
   way while the full URL stays under the link's title. */
.source-line {
  font-size: var(--text-caption);
  margin: calc(-1 * var(--space-2)) 0 var(--space-4);
}
.pacing__line {
  font-variant-numeric: tabular-nums;
}
.pacing__note {
  margin: 0 0 var(--space-3);
}

/* The rate editor: the summary states the current cadence and opens the form,
   so the cadence is shown exactly once (no separate chip to fall out of sync). */
.rate-editor {
  margin: var(--space-3) 0;
}
.rate-editor > summary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  list-style: none;
}
.rate-editor > summary::-webkit-details-marker {
  display: none;
}
.rate-editor > summary::after {
  content: "\25BE"; /* ▾ */
  font-size: 0.75em;
}
.rate-editor[open] > summary::after {
  content: "\25B4"; /* ▴ */
}
/* One flat row: the select, the "other" box, then Save.  flex-start keeps the
   controls on a common line even though only one carries help text. */
.rate-editor__form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-2);
  margin-top: var(--space-3);
}
.rate-editor__form .field {
  margin: 0;
}
.rate-editor__form select {
  min-width: var(--field-gap);
}
.rate-editor__form .field--other {
  flex: 1 1 var(--field-gap);
}

/* A section heading that may carry an action on its right. */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.section-head h2 {
  margin-bottom: 0;
}

/* "Show all upcoming": a native disclosure whose summary reads as a button,
   so the full schedule needs no JavaScript (audit D3). */
.show-all > summary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  list-style: none;
}
.show-all > summary::-webkit-details-marker {
  display: none;
}
.show-all > summary::after {
  content: "\25BE"; /* ▾ */
  font-size: 0.75em;
}
.show-all[open] > summary::after {
  content: "\25B4"; /* ▴ */
}

/* Removal is destructive and rare: set apart at the foot.  The card surface
   with a danger-colored left rail makes the zone distinct without leaning on
   red text alone. */
.danger-zone {
  margin-top: var(--space-6);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.danger-zone h2 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-h3);
  color: var(--danger);
}

/* ---- Focus visibility (audit A6) ---- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (pointer: coarse) {
  .site-nav__link,
  .btn--sm {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  /* A7/L1: the interactive controls below are ~40px tall, which is below the
     44px touch-target guidance; on touch devices lift them all to it. */
  .btn,
  button,
  input[type="text"],
  input[type="url"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  select {
    min-height: 44px;
  }
}

@media (max-width: 600px) {
  body {
    margin: var(--space-4) auto;
  }
  /* Wide tables become stacked label/value rows (audit M12). */
  .table--stack thead {
    display: none;
  }
  .table--stack tr {
    display: block;
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border);
  }
  .table--stack td {
    display: block;
    border: 0;
    padding: var(--space-1) 0;
  }
  .table--stack td::before {
    content: attr(data-label) ": ";
    font-size: var(--text-caption);
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
  }
}
