/*
 * radio.css — all colors/fonts come from CSS variables defined in <head>
 * (see partials/head.php, fed by .env). Restyle a station without editing CSS.
 * When THEME_DYNAMIC_BG is on, player.js overrides --text and the background
 * colors at runtime to match the album art.
 */

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

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  text-align: center;
  -webkit-font-smoothing: antialiased;
  transition: background-color .6s ease;
}

a { color: var(--muted); text-decoration: none; }
a:hover, a:focus { color: var(--text); text-decoration: underline; }

/* -------------------------------------------------------------- layout */
.player-wrap {
  width: 100%;
  max-width: 660px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.player-card {
  width: 100%;
  padding: 24px;
  background: var(--surface);
  border-radius: calc(var(--radius) + 10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  transition: background-color .6s ease;
}

/* ----------------------------------------------------------- album art */
.art-wrap { position: relative; width: 100%; }

.album-art {
  width: 100%;
  max-width: 600px;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  filter:
    drop-shadow(0 0 calc(var(--glow, 0) * 55px) var(--accent))
    drop-shadow(0 0 calc(var(--glow, 0) * 18px) var(--accent));
  opacity: 0.92;
  transition: opacity .2s ease-in-out, border-radius .2s ease-in-out;
}
.album-art:hover { opacity: 1; border-radius: 0; }

/* ---------------------------------------------------------- track meta */
.track-meta { width: 100%; margin-top: 10px; }
.track-name   { font-size: 1.25rem; font-weight: 700; line-height: 1.3; word-break: break-word; }
.track-artist { font-size: 1rem; opacity: 0.9; margin-top: 2px; word-break: break-word; }
.track-album  { font-size: 0.85rem; opacity: 0.65; margin-top: 2px; word-break: break-word; }

/* ------------------------------------------------------------ controls */
.controls { display: flex; justify-content: center; }

/* Sized well past the 64px button so the ring visualizer's ticks (drawn
   radiating outward from the button edge) have room to show. */
.playpause-wrap {
  position: relative; width: 130px; height: 130px;
  display: flex; align-items: center; justify-content: center;
}
.art-ring { position: absolute; inset: 0; pointer-events: none; }
.art-ring[hidden] { display: none; }

.playpause {
  position: relative;
  width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%;
  background: var(--accent); color: var(--accent-text);
  cursor: pointer;
  transition: background .15s ease, transform .1s ease;
}
.playpause:hover, .playpause:focus { background: var(--accent-hover); outline: 0; }
.playpause:active { transform: scale(0.94); }

.icon-btn {
  background: none; border: none; color: var(--text);
  cursor: pointer; padding: 4px; display: inline-flex; opacity: 0.85;
}
.icon-btn:hover { opacity: 1; }

/* ---------------------------------------------------- seek / volume rows */
.seek-row, .vol-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
}
.vol-row { justify-content: center; }
.time { font-variant-numeric: tabular-nums; font-size: 0.8rem; opacity: 0.8; min-width: 40px; }

.live-badge { display: inline-flex; align-items: center; gap: 6px; }
.live-badge[hidden] { display: none; }  /* the [hidden] attr must beat display:inline-flex */
.live-text {
  color: #ffffff;
  font-size: 0.78rem; font-weight: 700; letter-spacing: .12em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.live-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #21d05f;
  animation: live-pulse 2.6s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 3px 0 rgba(33, 208, 95, 0.5);  opacity: 0.85; }
  50%      { box-shadow: 0 0 11px 3px rgba(33, 208, 95, 0.95); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; box-shadow: 0 0 6px rgba(33, 208, 95, 0.9); }
}

.range {
  -webkit-appearance: none; appearance: none;
  height: 6px; border-radius: 3px;
  background: rgba(127, 127, 127, 0.35);
  outline: none; cursor: pointer;
}
.seek { flex: 1; }
.volume { width: 140px; }
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: none; cursor: pointer;
}
.range::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: none; cursor: pointer;
}
.range:disabled { opacity: 0.45; cursor: default; }

/* native <audio> fallback (PLAYER_STYLE=simple / noscript) */
audio[controls] { width: 100%; outline: 0; }

/* --------------------------------------------------------------- waveform */
.waveform-wrap { position: relative; width: 100%; }
.waveform { width: 100%; display: block; border-radius: 8px; }
.waveform[hidden] { display: none; }   /* [hidden] must beat display:block */

.waveform-picker {
  position: fixed; top: 64px; right: 16px; z-index: 30;
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
}
.waveform-picker[hidden] { display: none; }
.waveform-picker fieldset {
  margin: 0; padding: 8px 10px;
  background: rgba(0, 0, 0, 0.85); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 10px;
  backdrop-filter: blur(4px);
  text-align: left; font-size: 0.8rem;
}
.waveform-picker legend { padding: 0 4px; opacity: .7; font-variant: small-caps; }
.waveform-picker label { display: flex; align-items: center; gap: 6px; padding: 2px 0; cursor: pointer; white-space: nowrap; }

/* --------------------------------------------------------------- buttons */
.btn-accent {
  min-width: 120px;
  padding: 9px 16px;
  background: var(--accent); color: var(--accent-text);
  font-variant: small-caps; font-size: 1rem;
  border: 1px solid var(--accent); border-radius: 6px;
  cursor: pointer;
  transition: background .15s ease, box-shadow .15s ease;
}
.btn-accent:hover, .btn-accent:focus {
  background: var(--accent-hover); border-color: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35); outline: 0;
}

/* --------------------------------------------------------------- lyrics */
.lyrics-toggle {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  padding: 6px 14px;
  background: rgba(0, 0, 0, 0.55); color: #fff;
  font-variant: small-caps; font-size: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 999px;
  cursor: pointer; backdrop-filter: blur(4px);
  transition: background .15s ease;
}
.lyrics-toggle:hover, .lyrics-toggle:focus { background: rgba(0, 0, 0, 0.8); outline: 0; }
.lyrics-toggle[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.lyrics {
  position: absolute; inset: 0; z-index: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;   /* momentum scroll on iOS */
  overscroll-behavior: contain;
  text-align: left; white-space: pre-line; line-height: 1.6;
  padding: 52px 20px 20px;
  background: rgba(0, 0, 0, 0.8);
  border-radius: var(--radius);
  color: #fff;
}
.lyrics[hidden] { display: none; }   /* [hidden] must beat position:absolute rule specificity */

.lyrics-line {
  display: block; width: 100%; text-align: left;
  background: none; border: none; margin: 0; padding: 4px 0;
  font: inherit; color: inherit; cursor: pointer;
  opacity: .55; transition: opacity .2s ease, color .2s ease;
  -webkit-user-select: text; user-select: text;   /* buttons are unselectable by default */
}
.lyrics-line:hover, .lyrics-line:focus-visible { opacity: .85; outline: 0; }
.lyrics-line.current { opacity: 1; font-weight: 700; }

.lyrics-source {
  display: block; margin-top: 14px;
  font-size: 0.75rem; opacity: .6; color: inherit;
}
.lyrics-source:hover, .lyrics-source:focus-visible { opacity: 1; text-decoration: underline; }
.lyrics-source[hidden] { display: none; }

/* dumb-only: Genius annotations found in the lyrics (see renderAnnotatedLyrics). */
.lyrics-annotated { text-decoration: underline dotted; text-underline-offset: 3px; }
.annotation-toggle {
  background: none; border: none; cursor: pointer; padding: 0 2px;
  font-size: 0.85em; line-height: 1; vertical-align: baseline;
  opacity: .75;
}
.annotation-toggle:hover, .annotation-toggle:focus-visible { opacity: 1; outline: 0; }
.annotation-body {
  display: block; white-space: normal;   /* .lyrics has white-space: pre-line; this is prose */
  margin: 4px 0 8px; padding: 8px 10px;
  background: rgba(255, 255, 255, 0.08); border-radius: 8px;
  font-size: 0.85rem; opacity: .85;
}
.annotation-body[hidden] { display: none; }

.lyrics-sync {
  position: absolute; top: 48px; right: 10px; z-index: 2;
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 999px;
  backdrop-filter: blur(4px);
  font-variant-numeric: tabular-nums; font-size: 0.75rem;
}
.lyrics-sync button {
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.15); border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff; cursor: pointer; font-size: 0.8rem; line-height: 1; padding: 0;
}
.lyrics-sync button:hover, .lyrics-sync button:focus { background: rgba(255, 255, 255, 0.3); outline: 0; }
.lyrics-sync[hidden] { display: none; }

/* Hide the scrollbar but keep wheel / touch / drag scrolling. */
.no-scrollbar, .lyrics, .history {
  scrollbar-width: none;          /* Firefox */
  -ms-overflow-style: none;       /* legacy Edge / IE */
}
.no-scrollbar::-webkit-scrollbar,
.lyrics::-webkit-scrollbar,
.history::-webkit-scrollbar {     /* Chrome / Safari / new Edge */
  width: 0; height: 0; display: none;
}

/* ----------------------------------------------------------------- menu */
.menu-wrap { position: fixed; top: 16px; right: 16px; z-index: 30; }
.menu-toggle {
  position: relative;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-text);
  font-size: 1.1rem; line-height: 1;
  border: none; border-radius: 8px; cursor: pointer;
}
.menu-toggle:hover, .menu-toggle:focus { background: var(--accent-hover); outline: 0; }

.menu-list {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30;
  min-width: 170px; margin: 0; padding: 6px;
  list-style: none;
  background: rgba(0, 0, 0, 0.85); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 10px;
  backdrop-filter: blur(4px);
}
.menu-list[hidden] { display: none; }
.menu-item {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px; margin: 0;
  background: none; border: none; border-radius: 6px;
  color: inherit; font: inherit; font-size: 0.85rem; cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: rgba(255, 255, 255, 0.15); outline: 0; }

/* ----------------------------------------------------- history panel */
.history {
  position: fixed; top: 0; right: 0; height: 100%;
  width: min(90vw, 420px); padding: 64px 16px 16px;
  background: var(--surface);
  color: var(--panel-text, #fff);      /* stay readable regardless of album-art tint */
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
  transform: translateX(100%); transition: transform .35s ease;
  overflow-y: auto;                    /* long lists scroll up/down */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  z-index: 25;
}
.history.open { transform: translateX(0); }
.history-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; text-align: left; }
.history-table th, .history-table td {
  padding: 6px 8px; border-bottom: 1px solid rgba(127, 127, 127, 0.25); vertical-align: top;
}
.history-table th { opacity: 0.7; font-weight: 600; }

/* ------------------------------------------------------- liquid glass btns */
/* THEME_LIQUID_GLASS=true: refraction technique ported from
   https://github.com/nikdelvin/liquid-glass (MIT) — see the liquid-glass
   block in player.js for the SVG feDisplacementMap filter it builds.
   .glass-fx gets its real backdrop-filter set there; the rule below is
   just the pre-JS / unsupported-browser fallback (plain blur). The
   [aria-pressed="true"] variant is needed to beat .lyrics-toggle's own
   higher-specificity active-state accent fill (class+attribute selector).
   position/z-index are NOT set here — .lyrics-toggle already needs its own
   position: absolute for corner placement, so each button supplies its own
   (see .playpause / .menu-toggle), keeping this class layout-neutral. */
.glass-btn,
.glass-btn:hover,
.glass-btn:focus,
.glass-btn:active,
.glass-btn[aria-pressed="true"] {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
}
.glass-btn {
  isolation: isolate;     /* keeps .glass-fx's negative z-index scoped to this button */
  overflow: hidden;
  transition: transform .25s ease;
}
.glass-btn:hover, .glass-btn:focus { outline: 0; transform: scale(1.05) rotate(-1deg); }
.glass-fx {
  position: absolute; inset: 0; z-index: -1;   /* behind the icon/text, above the page */
  border-radius: inherit;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 0 4px rgba(255, 255, 255, 0.55);
  /* player.js sets --glass-filter/--glass-filter-hover per button (sized to
     fit); the value here is only the pre-JS / unsupported-browser fallback. */
  backdrop-filter: var(--glass-filter, blur(8px) saturate(160%) brightness(1.1));
  -webkit-backdrop-filter: var(--glass-filter, blur(8px) saturate(160%) brightness(1.1));
  transition: backdrop-filter .2s ease, -webkit-backdrop-filter .2s ease,
              background .2s ease, box-shadow .2s ease;
}
/* Hover: weaker refraction + lighter tint so more of what's behind shows through. */
.glass-btn:hover .glass-fx, .glass-btn:focus .glass-fx {
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 3px rgba(255, 255, 255, 0.35);
  backdrop-filter: var(--glass-filter-hover, blur(4px) saturate(130%) brightness(1.05));
  -webkit-backdrop-filter: var(--glass-filter-hover, blur(4px) saturate(130%) brightness(1.05));
}

/* ------------------------------------------------------------ listeners */
.listeners {
  position: fixed; bottom: 12px; left: 12px;
  font-size: 0.9rem; color: var(--text); opacity: 0.85;
}

/* ------------------------------------------------------------ responsive */
@media (max-width: 575px) {
  body { background: var(--bg-mobile); }
  .player-card { padding: 16px; }
  .art-wrap, .album-art { width: 96%; }
  .history { width: min(96vw, 420px); }

  /* -webkit-touch-callout is a no-op everywhere except iOS WebKit, so this
     @supports check targets iOS phones without any JS/UA sniffing. The menu
     item is hidden there, so give the art a fake ambient glow (no audio
     analysis) in its place. */
  @supports (-webkit-touch-callout: none) {
    #menu-waveform { display: none; }
    .album-art { animation: art-glow-pulse 3.2s ease-in-out infinite; }
  }
}

@keyframes art-glow-pulse {
  0%, 100% {
    filter: drop-shadow(0 0 6px var(--accent)) drop-shadow(0 0 2px var(--accent));
  }
  50% {
    filter: drop-shadow(0 0 42px var(--accent)) drop-shadow(0 0 15px var(--accent));
  }
}
@media (prefers-reduced-motion: reduce) {
  .album-art { animation: none; }
}

@media print { html, body { display: none; } }
