/* Radio Spot V2. System fonts only: nothing is fetched from a font CDN. */

:root {
  --bg: #f8f9ff;
  --surface: #ffffff;
  --surface-2: #e8eef9;
  --appbar: #a9c7f7;
  --on-appbar: #10151d;
  --text: #191c20;
  --muted: #5b6270;
  --border: #c4c7d0;
  --primary: #3d5f90;
  --on-primary: #ffffff;
  --primary-soft: #d6e3ff;
  --star: #f2a900;
  --danger: #ba1a1a;
  --danger-soft: #ffdad6;
  --current: #e3ecfb;
  --shadow: 0 2px 6px rgb(0 0 0 / 0.12), 0 6px 18px rgb(0 0 0 / 0.08);
  --radius: 14px;
  --gutter: 16px;
  --player-h: 72px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111318;
    --surface: #1b1f26;
    --surface-2: #262b33;
    --appbar: #1d2733;
    --on-appbar: #e2e2e9;
    --text: #e2e2e9;
    --muted: #a8adb8;
    --border: #434852;
    --primary: #aac7ff;
    --on-primary: #0a305f;
    --primary-soft: #284777;
    --star: #ffc531;
    --danger: #ffb4ab;
    --danger-soft: #5c1d18;
    --current: #1f2a3a;
    --shadow: 0 2px 6px rgb(0 0 0 / 0.4), 0 6px 18px rgb(0 0 0 / 0.3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111318;
  --surface: #1b1f26;
  --surface-2: #262b33;
  --appbar: #1d2733;
  --on-appbar: #e2e2e9;
  --text: #e2e2e9;
  --muted: #a8adb8;
  --border: #434852;
  --primary: #aac7ff;
  --on-primary: #0a305f;
  --primary-soft: #284777;
  --star: #ffc531;
  --danger: #ffb4ab;
  --danger-soft: #5c1d18;
  --current: #1f2a3a;
  --shadow: 0 2px 6px rgb(0 0 0 / 0.4), 0 6px 18px rgb(0 0 0 / 0.3);
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

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

button,
select,
input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

/* ---------- App bar ---------- */

.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: calc(8px + env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) 8px max(var(--gutter), env(safe-area-inset-left));
  background: var(--appbar);
  color: var(--on-appbar);
}

.appbar h1 {
  flex: 1;
  margin: 0;
  font-size: 1.35rem;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appbar-home {
  min-height: 84px;
}

.appbar-home h1 {
  font-size: clamp(1.35rem, 6.5vw, 1.75rem);
  font-weight: 750;
  letter-spacing: -0.01em;
}

.appbar-logo {
  width: 52px;
  height: 52px;
  border-radius: 13px;
}

/* ---------- Buttons ---------- */

.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
}

.icon-btn:hover {
  background: color-mix(in srgb, currentColor 10%, transparent);
}

.icon-btn:disabled {
  opacity: 0.3;
  cursor: default;
  background: transparent;
}

.icon-btn.danger {
  color: var(--danger);
}

.icon {
  display: inline-grid;
  width: 24px;
  height: 24px;
}

.icon svg {
  width: 100%;
  height: 100%;
}

.text-btn {
  padding: 8px 12px;
  border: 0;
  border-radius: 20px;
  background: transparent;
  color: inherit;
  font-weight: 600;
  cursor: pointer;
}

.text-btn:hover {
  background: color-mix(in srgb, currentColor 10%, transparent);
}

.results-status .text-btn {
  color: var(--primary);
  padding: 4px 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 22px;
  border: 0;
  border-radius: 22px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn-quiet {
  background: var(--primary-soft);
  color: var(--text);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.fab {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 15;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: var(--primary-soft);
  color: var(--text);
  box-shadow: var(--shadow);
}

.fab .icon {
  width: 30px;
  height: 30px;
}

.has-player .fab {
  bottom: calc(var(--player-h) + 20px + env(safe-area-inset-bottom));
}

/* ---------- Layout ---------- */

.content {
  max-width: 760px;
  margin: 0 auto;
  padding: 8px max(var(--gutter), env(safe-area-inset-right)) calc(110px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
}

.has-player .content {
  padding-bottom: calc(var(--player-h) + 110px + env(safe-area-inset-bottom));
}

/* ---------- Station rows ---------- */

.station-list {
  margin: 0 calc(-1 * var(--gutter) / 2);
  padding: 0;
  list-style: none;
}

.station {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 8px calc(var(--gutter) / 2);
  border-radius: var(--radius);
  cursor: pointer;
}

.station:hover {
  background: var(--surface-2);
}

.station.is-current {
  background: var(--current);
}

.station-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.station-name {
  font-size: 1.1rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.station-sub {
  color: var(--muted);
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.station-sub:empty {
  display: none;
}

.station.is-current .station-name {
  color: var(--primary);
}

/* Favourite gestures (touch only, see views/favorites.js): swipe sideways to remove,
   long-press and drag to reorder. */
.station.swipeable {
  position: relative;
  overflow: hidden;
  touch-action: pan-y;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.station.is-lifted {
  z-index: 6;
  cursor: grabbing;
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateY(var(--dy, 0)) scale(1.02);
}

.station-list.is-reordering .station:not(.is-lifted) {
  transform: translateY(var(--shift, 0));
  transition: transform 0.15s ease;
}

.station.is-swiping {
  background: var(--danger-soft);
}

.station.is-swiping > * {
  transform: translateX(var(--dx, 0));
}

.station.is-settling > * {
  transition: transform 0.18s ease-out;
}

.station.is-swiping::before {
  content: "Remove";
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  padding: 0 20px;
  color: var(--danger);
  font-weight: 700;
}

.station.is-swiping[data-swipe="right"]::before {
  left: 0;
}

.station.is-swiping[data-swipe="left"]::before {
  right: 0;
}

.station-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 2px;
}

.logo {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: contain;
  background: var(--surface);
}

.logo-sm {
  width: 48px;
  height: 48px;
}

.logo-fallback {
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
}

.fav-btn {
  color: var(--muted);
}

.fav-btn.is-on {
  color: var(--star);
}

/* Play button: one of play / stop / spinner is visible depending on the row state. */
.play-btn {
  position: relative;
  background: var(--primary);
  color: var(--on-primary);
}

.play-btn:hover {
  background: var(--primary);
  filter: brightness(1.08);
}

.play-btn .icon {
  width: 22px;
  height: 22px;
}

.play-btn .icon-stop,
.play-btn .spinner,
[data-state="playing"] .play-btn .icon-play,
[data-state="loading"] .play-btn .icon-play {
  display: none;
}

[data-state="playing"] .play-btn .icon-stop,
[data-state="loading"] .play-btn .spinner {
  display: inline-grid;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-inline {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-width: 2px;
  vertical-align: -2px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
}

/* ---------- Empty state ---------- */

.empty {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 64px 8px;
  text-align: center;
  color: var(--muted);
}

.empty-title {
  margin: 0;
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 650;
}

.empty .btn {
  margin-top: 16px;
}

/* ---------- Browse filters ---------- */

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 12px;
  padding: 14px 0 6px;
}

.field {
  display: grid;
  gap: 4px;
}

.field-label {
  padding-left: 4px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.field-control {
  position: relative;
  display: flex;
  align-items: center;
}

.field-control > .icon {
  position: absolute;
  left: 12px;
  width: 20px;
  height: 20px;
  color: var(--muted);
  pointer-events: none;
}

.field-control select,
.field-control input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px 0 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  appearance: none;
}

.field-control select {
  padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}

.search-control {
  grid-column: 1 / -1;
}

.results-status {
  margin: 12px 0 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.more-btn {
  display: flex;
  margin: 16px auto 0;
}

.attribution {
  margin-top: 28px;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

/* ---------- Settings ---------- */

.settings {
  display: grid;
  gap: 14px;
  padding-top: 16px;
}

.card {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.card h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.card p {
  margin: 0 0 12px;
  color: var(--muted);
}

.card p:last-child {
  margin-bottom: 0;
}

.warning {
  color: var(--danger) !important;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 22px;
  overflow: hidden;
}

.segmented button {
  min-height: 40px;
  padding: 0 18px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.segmented button + button {
  border-left: 1px solid var(--border);
}

.segmented [aria-checked="true"] {
  background: var(--primary-soft);
  font-weight: 600;
}

/* ---------- Player bar ---------- */

.player-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: none;
  align-items: center;
  gap: 12px;
  min-height: var(--player-h);
  padding: 10px max(var(--gutter), env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.has-player .player-bar {
  display: flex;
}

.player-bar .station-name {
  font-size: 1rem;
}

.player-bar[data-state="error"] .player-status {
  color: var(--danger);
}

.player-bar {
  cursor: pointer;
}

.route-playing .player-bar {
  display: none !important;
}

.route-playing .content {
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
}

/* Song line on the playing station, as in V1. */
.station-sub.is-track {
  color: var(--primary);
  font-style: italic;
}

/* ---------- Now playing ---------- */

.playing {
  display: grid;
  justify-items: center;
  gap: 20px;
  padding-top: 24px;
  text-align: center;
}

.cover-wrap {
  display: grid;
  place-items: center;
  width: min(100%, 420px);
  aspect-ratio: 1;
  border-radius: 20px;
  background: var(--surface-2);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.logo-xl {
  width: 62%;
  height: 62%;
  border-radius: 18px;
  font-size: 3rem;
}

.track {
  display: grid;
  gap: 4px;
  max-width: 100%;
}

.track-title {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.track-artist {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--primary);
}

.track-station {
  margin: 4px 0 0;
  color: var(--muted);
}

.track-station .station-name {
  font-size: inherit;
  font-weight: 600;
}

.playing-controls {
  display: flex;
  align-items: center;
  gap: 18px;
}

.playing-controls .play-btn {
  width: 72px;
  height: 72px;
}

.playing-controls .play-btn .icon,
.playing-controls .play-btn .spinner {
  width: 32px;
  height: 32px;
}

.playing-controls .fav-btn .icon {
  width: 30px;
  height: 30px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  width: fit-content;
  max-width: min(560px, calc(100vw - 2 * var(--gutter)));
  margin: 0 auto;
  padding: 12px 16px;
  border-radius: 12px;
  background: #2e3136;
  color: #eff0f7;
  box-shadow: var(--shadow);
  font-size: 0.95rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.2s, transform 0.2s;
}

.has-player .toast {
  bottom: calc(var(--player-h) + 16px + env(safe-area-inset-bottom));
}

/* Keep clear of the add button on the favourites screen. */
body:has(.fab) .toast {
  bottom: calc(96px + env(safe-area-inset-bottom));
}

body.has-player:has(.fab) .toast {
  bottom: calc(var(--player-h) + 96px + env(safe-area-inset-bottom));
}

.toast.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.toast-action {
  flex: none;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #aac7ff;
  font-weight: 700;
  cursor: pointer;
}

.noscript {
  padding: 24px;
  text-align: center;
}
