/* ---------- radio listener (audio station + full-bleed background) ----------
   Layered on top of style.css — reuses --vars, .brand, .topbar, .pill,
   .live-dot, .tapstart, .ghost. Only the radio-station layout lives here. */

/* ---------- background compositor (z-stack behind everything) ----------
   Two stacked full-bleed layers: live <video> (WHEP) and the <canvas> visualizer.
   compositor.js crossfades between them via the body[data-background] tag and/or its
   own classes; we ship a sane default (animation = canvas) so the page is never blank. */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #000;
  overflow: hidden;
}
.bg-video,
.bg-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity .8s ease;
}
/* Default visibility before compositor.js takes over: show the visualizer, hide video. */
.bg-video { opacity: 0; }
.bg-canvas { opacity: 1; }
body[data-background="iphone"] .bg-video,
body[data-background="eufy"] .bg-video { opacity: 1; }
body[data-background="iphone"] .bg-canvas,
body[data-background="eufy"] .bg-canvas { opacity: 0; }

/* Legibility scrim over the background so floating copy stays readable. */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(1100px 700px at 50% 38%, rgba(7, 10, 20, .15), rgba(7, 10, 20, .72) 78%),
    linear-gradient(180deg, rgba(7, 10, 20, .55), transparent 22%, transparent 62%, rgba(7, 10, 20, .78));
}

/* ---------- stage (now an overlay floating over the background) ---------- */
.radio-stage {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 96px 24px 120px;
  text-align: center;
  background: transparent; /* the background compositor shows through */
  pointer-events: none;    /* let the background breathe; re-enable on controls */
}
.radio-stage > * { pointer-events: auto; }

/* Pulsing "vinyl" / now-playing art placeholder. Hidden: minimalist full-bleed look. */
.disc {
  display: none;
  width: min(46vw, 240px);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #0a0e1a 0 16%, transparent 17%),
    conic-gradient(from 0deg, rgba(255,255,255,.06), rgba(255,255,255,.02) 25%, rgba(255,255,255,.08) 50%, rgba(255,255,255,.02) 75%, rgba(255,255,255,.06));
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55), inset 0 0 0 12px rgba(0,0,0,.35);
  place-items: center;
  position: relative;
}
.disc::after {
  content: "";
  width: 22%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--grad);
  opacity: .9;
}
/* Spin only while audio is actually playing. */
.disc.spinning { animation: spin 8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.np {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 32ch;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .6);
}
.np-title {
  font-size: clamp(1.3rem, 4.5vw, 2rem);
  font-weight: 800;
  margin: 0;
  line-height: 1.2;
}
.np-artist {
  color: var(--muted);
  font-size: clamp(.95rem, 3vw, 1.1rem);
  margin: 0;
}
.np-source {
  margin-top: 4px;
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--cyan);
}
.np-source:empty { display: none; }

/* Controls row: big play/pause + follow toggle. */
.controls { display: flex; align-items: center; gap: 14px; }
.play-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  padding: 0;
  font-size: 1.4rem;
  display: grid;
  place-items: center;
}
.follow-btn {
  border-radius: 999px;
  padding: 11px 18px;
  font-size: .9rem;
}
.follow-btn.on {
  background: rgba(255, 255, 255, .9);
  color: #0a0e1a;
  border-color: transparent;
}
/* Clean, monochrome glassy play button — no orange. */
.play-btn {
  background: rgba(255, 255, 255, .10);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, .22);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* Persistent station tagline (the manifesto sign-off). */
.signoff {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .9rem;
  letter-spacing: .01em;
  text-shadow: 0 2px 14px rgba(0, 0, 0, .6);
}

/* ---------- minimal stream HUD (lower-left) ---------- */
.streaminfo {
  position: fixed;
  left: 16px;
  bottom: 14px;
  z-index: 6;
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .72rem;
  line-height: 1.55;
  letter-spacing: .02em;
  color: var(--ink);
  opacity: .62;
  pointer-events: none;
  text-shadow: 0 1px 10px rgba(0, 0, 0, .7);
}
.streaminfo:empty { display: none; }
.streaminfo .si-src { display: flex; align-items: center; gap: 7px; }
.streaminfo .si-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--cyan); box-shadow: 0 0 8px var(--cyan);
  animation: si-pulse 2.4s ease-in-out infinite;
}
.streaminfo .si-meta { color: var(--muted); }
@keyframes si-pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .streaminfo .si-dot { animation: none; } }

/* ---------- minimalist overlay when a live video fills the background ---------- */
body[data-background="iphone"] .radio-stage,
body[data-background="eufy"] .radio-stage {
  justify-content: flex-end;
  padding: 24px 22px 80px;
  gap: 12px;
}
body[data-background="iphone"] .np-title,
body[data-background="eufy"] .np-title {
  font-size: clamp(1.05rem, 3.2vw, 1.4rem);
  font-weight: 600;
}
body[data-background="iphone"] .scrim,
body[data-background="eufy"] .scrim {
  background: linear-gradient(180deg, rgba(7, 10, 20, .34), transparent 16%, transparent 56%, rgba(7, 10, 20, .68));
}

/* ---------- manifesto idents (float over the background) ---------- */
.manifesto {
  position: fixed;
  inset: 0;                 /* full-screen so the idents sit in the MIDDLE of the video */
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 22px;
  padding: 0 24px;
  pointer-events: none;
  text-align: center;
}
.manifesto .ident {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(1rem, 3.4vw, 1.5rem);
  font-weight: 400;
  letter-spacing: .04em;
  color: var(--ink);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 1.6s ease, transform 1.6s ease;
  text-shadow: 0 2px 24px rgba(0, 0, 0, .55);
}
.manifesto .ident.visible { opacity: .5; transform: none; } /* a little transparent */
/* Static mode (reduced motion): show all values quietly, no fades. */
.manifesto.static .ident {
  opacity: .42;
  transform: none;
  transition: none;
  font-size: .82rem;
  font-weight: 500;
}

/* ---------- chat (corner panel over /ws) ---------- */
.chat {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10;
  width: min(340px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}
.chat-toggle {
  background: rgba(0, 0, 0, .45);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: .85rem;
  font-weight: 600;
  backdrop-filter: blur(8px);
}
.chat-toggle.unread::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 7px;
  border-radius: 50%;
  background: var(--rose);
  vertical-align: middle;
}
.chat.open .chat-toggle.unread::after { display: none; }
.chat-body {
  width: 100%;
  background: rgba(7, 10, 20, .72);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-body[hidden] { display: none; } /* author display:flex would otherwise beat [hidden] */
.chat-log {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: min(46vh, 320px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: .88rem;
  line-height: 1.4;
}
.chat-log li { word-break: break-word; }
.chat-log b {
  color: var(--cyan);
  font-weight: 700;
  margin-right: 6px;
}
.chat-form { margin: 0; }
.chat-form input { padding: 10px 13px; }

/* ---------- off-air dimming ---------- */
.radio-stage.offair .disc { filter: grayscale(1) brightness(.6); animation: none; }
.radio-stage.offair .np-title { color: var(--muted); }

/* ---------- prefers-reduced-motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .disc.spinning { animation: none; }
  .bg-video, .bg-canvas { transition: none; }
  .manifesto .ident { transition: none; }
}

/* Small screens: keep chat from swallowing the controls. */
@media (max-width: 480px) {
  .manifesto { bottom: 96px; }
  .chat { left: 16px; width: auto; }
  .chat:not(.open) { left: auto; }
}

/* ---------- quantum-field listener map (bottom-right, ambient) ---------- */
.fieldmap {
  position: fixed;
  right: 16px;
  bottom: 58px;
  width: min(320px, 40vw);
  aspect-ratio: 2 / 1;
  background: rgba(7, 10, 20, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  overflow: hidden;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  pointer-events: none;
  z-index: 5;
  opacity: .9;
}
.fieldmap canvas { width: 100%; height: 100%; display: block; }
.fieldmap-credit {
  position: absolute;
  right: 6px; bottom: 4px;
  font: 10px/1.2 ui-monospace, "SF Mono", monospace;
  color: var(--muted);
  opacity: .55;
}
.fieldmap-credit a { color: inherit; text-decoration: none; pointer-events: auto; }
@media (max-width: 640px) { .fieldmap { width: 56vw; right: 8px; bottom: 54px; } }

/* Removed per design: top-right LIVE pill + the center now-playing card. The lower-left
   stream HUD already shows the live source, so the centre stays clean. */
#presence { display: none; }
.radio-stage .np { display: none; }

/* ============================================================================
   GOLDEN-RATIO PASS (φ = 1.618) — chat removed; HUD (lower-left) and map
   (lower-right) share one baseline + inset; spacing/type on a φ modular scale.
   ============================================================================ */
:root {
  --phi: 1.618;
  --g1: 6px;    /* 16 / φ²  */
  --g2: 10px;   /* 16 / φ   */
  --g3: 16px;   /* base     */
  --g4: 26px;   /* 16 · φ   */
  --g5: 42px;   /* 16 · φ²  */
  --g6: 68px;   /* 16 · φ³  */
}

/* chat removed */
.chat { display: none !important; }

/* HUD + map share the exact same inset + baseline (left vs right mirror) */
.streaminfo {
  left: var(--g3);
  bottom: var(--g3);
  font-size: var(--g2);
  line-height: var(--phi);
}
.streaminfo .si-src { gap: var(--g1); }

.fieldmap {
  left: auto;
  right: var(--g3);
  bottom: var(--g3);
  width: min(272px, 42vw);
  aspect-ratio: var(--phi) / 1;   /* a golden rectangle, not 2:1 */
  border-radius: var(--g2);
  background: rgba(7, 10, 20, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.10);
}
.fieldmap-credit { right: var(--g1); bottom: var(--g1); font-size: var(--g2); }

/* manifesto + signoff + controls on the φ scale */
.manifesto .ident { font-size: clamp(var(--g3), 3.2vw, var(--g4)); }
.signoff { font-size: var(--g3); margin-top: var(--g1); }
body[data-background="iphone"] .radio-stage,
body[data-background="eufy"] .radio-stage { padding: var(--g4) var(--g4) var(--g5); gap: var(--g3); }
.play-btn { width: var(--g5); height: var(--g5); font-size: var(--g4); }
.topbar { padding: var(--g2) var(--g3); }
.pill { padding: var(--g1) var(--g2); font-size: var(--g2); }

/* play button: connecting spinner (empty label + rotating ring) so it never shows a stale ▶ */
.play-btn.loading { cursor: progress; }
.play-btn.loading::after {
  content: "";
  width: 42%;
  height: 42%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-top-color: var(--ink);
  animation: spin 0.8s linear infinite;
}
@media (prefers-reduced-motion: reduce) { .play-btn.loading::after { animation: none; } }

/* ---------- play button: CSS-drawn icons (no emoji glyphs) ---------- */
.play-btn { font-size: 0; line-height: 0; }
.play-btn::before { content: ""; display: block; box-sizing: content-box; }
/* idle → play triangle */
.play-btn[data-state="idle"]::before {
  width: 0; height: 0;
  border-style: solid;
  border-width: 10px 0 10px 16px;
  border-color: transparent transparent transparent var(--ink);
  transform: translateX(2px);
}
/* playing → two pause bars (one element: left + right borders) */
.play-btn[data-state="playing"]::before {
  width: 4px; height: 17px;
  border-left: 5px solid var(--ink);
  border-right: 5px solid var(--ink);
}
/* connecting → spinner ring */
.play-btn[data-state="connecting"]::before {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--ink);
  animation: spin 0.8s linear infinite;
}
/* retire the old ::after spinner so it can't double up */
.play-btn.loading::after { content: none; display: none; }
@media (prefers-reduced-motion: reduce) { .play-btn[data-state="connecting"]::before { animation: none; } }

/* ---------- phone layout: HUD + map sit in opposite corners, controls lifted clear ---------- */
@media (max-width: 640px) {
  .fieldmap { width: 44vw; right: 10px; bottom: 10px; }
  .streaminfo { left: 10px; bottom: 10px; font-size: 9px; max-width: 50vw; line-height: 1.5; }
  /* push the play button + sign-off ABOVE the bottom-corner widgets so nothing overlaps */
  .radio-stage,
  body[data-background="iphone"] .radio-stage,
  body[data-background="eufy"] .radio-stage {
    justify-content: flex-end;
    padding: var(--g4) var(--g3) calc(44vw / 1.618 + 30px);
    gap: var(--g2);
  }
  .signoff { font-size: 12px; opacity: .9; }
}
