/* Tokens: change colours here, every component reads from these */
:root {
  --bg: #f8f5ef;
  --surface: #ffffff;
  --surface-2: #f2ede4;
  --ink: #1d1b18;
  --muted: #6b645b;
  --line: #e4ddd0;
  --accent: #b5470f;
  --accent-hover: #963a0b;
  --accent-ink: #ffffff;
  --ok: #2f7d4f;
  --warn: #9a6a00;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(29, 27, 24, 0.06), 0 6px 20px rgba(29, 27, 24, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12100d;
    --surface: #1c1915;
    --surface-2: #26221c;
    --ink: #f3eee6;
    --muted: #a39a8e;
    --line: #34302a;
    --accent: #e0703a;
    --accent-hover: #ea8150;
    --accent-ink: #12100d;
    --ok: #5cc284;
    --warn: #e0b04a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.3);
  }
}

:root[data-theme="dark"] {
  --bg: #12100d;
  --surface: #1c1915;
  --surface-2: #26221c;
  --ink: #f3eee6;
  --muted: #a39a8e;
  --line: #34302a;
  --accent: #e0703a;
  --accent-hover: #ea8150;
  --accent-ink: #12100d;
  --ok: #5cc284;
  --warn: #e0b04a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: 104px;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

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

h1, h2 { line-height: 1.15; letter-spacing: -0.01em; }
h1 { margin: 0 0 14px; font-size: clamp(28px, 5vw, 46px); font-weight: 750; max-width: 16ch; }
h2 { margin: 0; font-size: 20px; font-weight: 700; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 12px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  justify-content: space-between;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  box-shadow: inset 0 0 0 6px var(--accent), inset 0 0 0 9px var(--bg);
}
.brand-name { font-weight: 750; font-size: 17px; letter-spacing: -0.01em; }
.brand-accent { color: var(--accent); }
.header-right { display: flex; align-items: center; gap: 12px; flex: 1 1 300px; justify-content: flex-end; min-width: 0; }

.search {
  position: relative;
  flex: 1 1 220px;
  max-width: 340px;
  display: flex;
  align-items: center;
}
.search svg { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 38px; border-radius: 999px; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.status.is-offline .dot { background: var(--warn); box-shadow: none; }

input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Hero */
.hero {
  background:
    radial-gradient(900px 300px at 85% -20%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 70%),
    var(--surface);
  border-bottom: 1px solid var(--line);
}
.hero-inner { max-width: 1120px; margin: 0 auto; padding: 48px 20px 40px; }
.eyebrow { margin: 0 0 10px; font-size: 13px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.lede { margin: 0 0 22px; color: var(--muted); font-size: 18px; max-width: 58ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.stats { display: flex; flex-wrap: wrap; gap: 28px; margin: 28px 0 0; }
.stats div { display: grid; gap: 2px; }
.stats dt { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.stats dd { margin: 0; font-size: 26px; font-weight: 750; font-variant-numeric: tabular-nums; }

/* Buttons */
.btn, .link-btn, .icon-btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover, .icon-btn:hover { border-color: var(--accent); }
.btn-lg { padding: 13px 22px; font-size: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; }
.link-btn { border: none; background: none; color: var(--accent); padding: 4px 0; font-weight: 600; }
.icon-btn { padding: 8px 14px; font-size: 14px; }

/* Sections */
.section { max-width: 1120px; margin: 0 auto; padding: 36px 20px 8px; }
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.fine { margin: 0 0 12px; font-size: 14px; color: var(--muted); }

/* Country row: a horizontal strip on phones, wrapping on desktop */
.country-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}
.tile {
  flex: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  font: 500 14px/1 system-ui, sans-serif;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.tile:hover { border-color: var(--accent); }
.tile.is-active { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.tile .n { font-size: 12px; opacity: 0.65; font-variant-numeric: tabular-nums; }
@media (min-width: 760px) {
  .country-row { flex-wrap: wrap; overflow: visible; }
}

/* Tabs */
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 999px; }
.tab {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
}
.tab.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.count { font-size: 12px; opacity: 0.7; font-variant-numeric: tabular-nums; }

/* Toolbar */
.toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  align-items: end;
  margin-bottom: 16px;
}
.toolbar .results-line { grid-column: 1 / -1; margin: 0; }
.toolbar .link-btn { justify-self: start; }
@media (min-width: 760px) {
  .toolbar { grid-template-columns: 200px 200px auto 1fr; }
  .toolbar .results-line { grid-column: auto; text-align: right; }
}
.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.field input, .field select { color: var(--ink); font-weight: 400; }
.results-line { font-size: 14px; color: var(--muted); }

/* Station cards: compact, in an auto-fill grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  align-content: start;
  box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.15s;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.card.is-playing { border-color: var(--accent); }
.card-body { min-width: 0; grid-column: 2; }
.card-name { font-weight: 650; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-tags { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag { font-size: 12px; background: var(--surface-2); border-radius: 999px; padding: 2px 9px; color: var(--muted); }
.card-actions { grid-column: 1 / -1; display: flex; gap: 8px; margin-top: 10px; }
.card-actions .btn { flex: 1; padding: 8px 12px; font-size: 14px; }
.btn-save { flex: none !important; }
.btn-save[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.empty {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  color: var(--muted);
}
.empty button { margin-top: 10px; }

/* Avatar: monogram in a colour derived from the station name */
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 750;
  font-size: 15px;
  color: #fff;
  grid-row: span 2;
  flex: none;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
}
.avatar-sm { width: 40px; height: 40px; font-size: 13px; border-radius: 10px; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); }
.footer-inner { max-width: 1120px; margin: 0 auto; padding: 28px 20px; display: grid; gap: 12px; }
.footer-about { margin: 0; font-size: 14px; color: var(--muted); max-width: 70ch; }
.footer-links { display: flex; gap: 16px; }

/* Player */
.player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 24px rgba(29, 27, 24, 0.08);
  z-index: 20;
}
.player-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.play-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
}
.play-btn:hover { background: var(--accent-hover); }
.play-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.now { min-width: 0; flex: 1; }
.now-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-meta { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Equaliser: animates only while audio plays */
.eq { display: none; align-items: flex-end; gap: 3px; height: 18px; }
.player.is-playing .eq { display: inline-flex; }
.eq i { width: 3px; height: 100%; background: var(--accent); border-radius: 2px; animation: eq 0.9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: 0.2s; }
.eq i:nth-child(3) { animation-delay: 0.4s; }
@keyframes eq { 0%, 100% { transform: scaleY(0.3); } 50% { transform: scaleY(1); } }
@media (prefers-reduced-motion: reduce) {
  .eq i { animation: none; transform: scaleY(0.7); }
}

@media (max-width: 560px) {
  .player-inner { gap: 8px; padding: 10px 14px; }
  .player .icon-btn { display: none; }
  .eq { display: none !important; }
}

/* Submit modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 30;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  width: min(540px, 100%);
  max-height: 90vh;
  overflow: auto;
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow);
}
#submit-form { display: grid; gap: 12px; }
.checks { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 0; }
.checks legend { font-size: 13px; color: var(--muted); padding: 0 4px; font-weight: 600; }
.checks-grid { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.checks label { font-size: 14px; display: flex; gap: 6px; align-items: center; }
.form-error { color: var(--accent); margin: 0; font-size: 14px; }
#submit-json { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

@media (max-width: 560px) {
  .hero-inner { padding: 36px 16px 30px; }
  .section { padding: 28px 16px 8px; }
  .site-header { padding: 12px 16px; }
  .stats { gap: 20px; }
}
