/* extinction.meme theme radio: the boombox in the header + its popover panel + the YouTube mini-player.
   Colours come from the site's theme variables (style.css), so it follows discord kitten (light) / reddit mod (dark).
   No inline styles anywhere: radio.js only sets positions/transforms through CSSOM. */

.xr {
  --xr-ink: #2b1020;
  --xr-body: var(--pink, #ff9ccf);
  --xr-grill: #fff;
  --xr-cone: var(--hot, #ff3d9a);
  --xr-win: var(--sky, #a9dcff);
  --xr-blush: #ff6fb5;
  --xr-lcd: #dff3ff;
  --xr-lcd-ink: #2b1020;
  --xr-eq: #ff3d9a;
  position: relative; display: inline-flex; flex: none; align-items: center; justify-content: center;
}
.xr-panel, .xr-yt-host {
  --xr-ink: #2b1020;
  --xr-body: var(--pink, #ff9ccf);
  --xr-grill: #fff;
  --xr-cone: var(--hot, #ff3d9a);
  --xr-lcd: #dff3ff;
  --xr-lcd-ink: #2b1020;
  --xr-eq: #ff3d9a;
  --xr-btn: var(--paper, #fff8fb);
  --xr-handle: var(--xr-ink);
}
/* reddit mod: orange boombox, dark speakers, an amber-on-black LCD */
:root[data-theme="dark"] .xr, :root[data-theme="dark"] .xr-panel, :root[data-theme="dark"] .xr-yt-host {
  --xr-ink: #0b0d0e; --xr-body: #ff4500; --xr-grill: #d7dadc; --xr-cone: #1a1a1b; --xr-win: #7193ff; --xr-blush: transparent;
  --xr-lcd: #121314; --xr-lcd-ink: #ff8c5a; --xr-eq: #ff4500; --xr-btn: #272729; --xr-handle: #d7dadc;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .xr, :root:not([data-theme="light"]) .xr-panel, :root:not([data-theme="light"]) .xr-yt-host {
    --xr-ink: #0b0d0e; --xr-body: #ff4500; --xr-grill: #d7dadc; --xr-cone: #1a1a1b; --xr-win: #7193ff; --xr-blush: transparent;
    --xr-lcd: #121314; --xr-lcd-ink: #ff8c5a; --xr-eq: #ff4500; --xr-btn: #272729; --xr-handle: #d7dadc;
  }
}
/* 終末FM gets sakura on its display, whatever the theme */
.xr-panel[data-station="ja"] { --xr-eq: #ff7eb6; }
:root[data-theme="dark"] .xr-panel[data-station="ja"] { --xr-lcd-ink: #ffb3d4; }

/* ---------- the boombox button ---------- */
.xr-boombox {
  position: relative; width: 42px; height: 40px; padding: 0; margin: 0; border: 0; background: none; border-radius: 12px;
  display: grid; place-items: center; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.xr-boombox:hover .xr-bb { filter: drop-shadow(2px 2px 0 var(--shade, #2b1020)); }
.xr-boombox:active .xr-bb { transform: scale(1.12, .86); }
.xr-bb { width: 40px; height: 34px; display: block; overflow: visible; transform-origin: 50% 100%; will-change: transform; }
.xr-bb .ln { fill: none; stroke: var(--xr-ink); stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; }
.xr-bb .body { fill: var(--xr-body); stroke: var(--xr-ink); stroke-width: 3.4; stroke-linejoin: round; }
.xr-bb .grill { fill: var(--xr-grill); stroke: var(--xr-ink); stroke-width: 3; }
.xr-bb .cone { fill: var(--xr-cone); stroke: var(--xr-ink); stroke-width: 2; transform-box: fill-box; transform-origin: center; }
.xr-bb .dot { fill: var(--xr-ink); }
.xr-bb .win { fill: var(--xr-win); stroke: var(--xr-ink); stroke-width: 2.2; }
.xr-bb .blush { fill: var(--xr-blush); opacity: .85; }
.xr-bb .eye { fill: var(--xr-ink); }
.xr-bb .smile { fill: none; stroke: var(--xr-ink); stroke-width: 2; stroke-linecap: round; }
.xr-bb .ant-ball { fill: var(--xr-cone); stroke: var(--xr-ink); stroke-width: 2; }
/* idle: a tiny breathing wiggle */
.xr:not(.is-playing) .xr-bb { animation: xr-breathe 3.4s ease-in-out infinite; }
@keyframes xr-breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.03, .97) rotate(-2deg); } }
/* playing: the antenna lights up (the only "on" sign in calm mode, where nothing bounces) */
.xr.is-playing .xr-bb .ant-ball { fill: var(--butter, #fff27a); }
/* music notes floating up while it plays */
.xr-note {
  position: absolute; left: 50%; top: 2px; pointer-events: none; font-size: 15px; line-height: 1; font-weight: 700;
  color: var(--xr-cone); text-shadow: 1px 1px 0 var(--paper, #fff); z-index: 1;
  animation: xr-note 1.5s ease-out forwards;
}
@keyframes xr-note {
  0% { opacity: 0; transform: translate(-50%, 6px) scale(.6) rotate(0); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 8px)), -26px) scale(1.05) rotate(var(--rot, 14deg)); }
}

/* ---------- the panel: a tiny boombox ---------- */
.xr-panel {
  position: fixed; z-index: 80; width: 336px; max-width: calc(100vw - 16px);
  font-family: var(--body, sans-serif); color: var(--ink, #2b1020);
}
.xr-panel[hidden], .xr-panel [hidden] { display: none !important; }
.xr-handle {
  position: absolute; left: 24%; right: 24%; top: -17px; height: 21px; pointer-events: none;
  border: 4px solid var(--xr-handle, var(--xr-ink)); border-bottom: 0; border-radius: 16px 16px 0 0;
}
.xr-handle::before, .xr-handle::after { content: ""; position: absolute; bottom: -4px; width: 12px; height: 7px; border-radius: 3px; background: var(--xr-handle, var(--xr-ink)); }
.xr-handle::before { left: -8px; } .xr-handle::after { right: -8px; }
.xr-case {
  position: relative; overflow: auto; overscroll-behavior: contain;
  background: var(--xr-body); border: 3.5px solid var(--xr-ink); border-radius: 22px;
  box-shadow: 6px 6px 0 var(--shade, #2b1020); padding: 12px 12px 10px;
  animation: xr-pop .26s cubic-bezier(.3, 1.6, .5, 1);
}
@keyframes xr-pop { from { transform: translateY(-8px) scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
.xr-x {
  position: absolute; right: 8px; top: 8px; width: 28px; height: 28px; padding: 0; border-radius: 50%; z-index: 2;
  border: 2.5px solid var(--xr-ink); background: var(--xr-btn); color: var(--ink, #2b1020); font-size: 13px; line-height: 1; font-weight: 700;
}
.xr-face { display: grid; grid-template-columns: 54px minmax(0, 1fr) 54px; gap: 8px; align-items: center; margin-top: 18px; }
.xr-spk {
  width: 54px; height: 54px; border-radius: 50%; border: 3px solid var(--xr-ink); display: grid; place-items: center;
  background: radial-gradient(circle, var(--xr-ink) 1.1px, transparent 1.6px) 0 0 / 7px 7px, var(--xr-grill);
}
.xr-spk i {
  width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid var(--xr-ink); background: var(--xr-cone);
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, .28); display: block; will-change: transform;
}
.xr-lcd {
  min-width: 0; background: var(--xr-lcd); color: var(--xr-lcd-ink); border: 3px solid var(--xr-ink); border-radius: 12px;
  padding: 6px 8px 5px; box-shadow: inset 2px 2px 0 rgba(0, 0, 0, .12);
}
.xr-station { font-family: var(--display, sans-serif); font-size: 16px; line-height: 1.1; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xr-title { font-weight: 700; font-size: 14.5px; line-height: 1.2; margin-top: 3px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.xr-artist { font-size: 12.5px; line-height: 1.2; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xr-eq { display: block; width: 100%; height: 26px; margin-top: 4px; }

.xr-ctrls { display: flex; justify-content: center; align-items: center; gap: 10px; margin: 12px 0 8px; }
.xr-b {
  width: 40px; height: 40px; padding: 0; display: grid; place-items: center; border-radius: 12px;
  border: 2.5px solid var(--xr-ink); background: var(--xr-btn); color: var(--ink, #2b1020); box-shadow: 2px 2px 0 var(--xr-ink);
  font-size: 16px; line-height: 1; transition: transform .1s, box-shadow .1s;
}
.xr-b:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--xr-ink); }
.xr-b svg { width: 18px; height: 18px; fill: currentColor; display: block; }
.xr-b.play { width: 54px; height: 48px; border-radius: 16px; background: var(--butter, #fff27a); color: #2b1020; }
.xr-b.play svg { width: 22px; height: 22px; }
.xr-b[aria-pressed="true"] { background: var(--hot, #ff3d9a); color: #fff; }
:root[data-theme="dark"] .xr-b.play { background: #ff4500; color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .xr-b.play { background: #ff4500; color: #fff; } }

.xr-vol { display: flex; align-items: center; gap: 8px; margin: 2px 4px 8px; font-size: 15px; }
.xr-vol input { flex: 1; min-width: 0; height: 26px; margin: 0; background: none; accent-color: var(--xr-ink); cursor: pointer; -webkit-appearance: none; appearance: none; }
.xr-vol input::-webkit-slider-runnable-track { height: 8px; border-radius: 99px; background: var(--xr-btn); border: 2.5px solid var(--xr-ink); }
.xr-vol input::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8.5px; border-radius: 50%; background: var(--butter, #fff27a); border: 2.5px solid var(--xr-ink); }
.xr-vol input::-moz-range-track { height: 4px; border-radius: 99px; background: var(--xr-btn); border: 2.5px solid var(--xr-ink); }
.xr-vol input::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--butter, #fff27a); border: 2.5px solid var(--xr-ink); }
.xr-vol input:focus-visible { outline: 3px dashed var(--xr-ink); outline-offset: 2px; }

/* tuning dial: three stations on a little frequency strip, the needle slides to the one playing */
.xr-dial {
  position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin: 0 2px 4px; padding: 14px 4px 4px;
  border: 2.5px solid var(--xr-ink); border-radius: 12px; background: var(--xr-lcd); color: var(--xr-lcd-ink);
  background-image: repeating-linear-gradient(90deg, currentColor 0 1.5px, transparent 1.5px 10px);
  background-size: 100% 7px; background-repeat: no-repeat; background-position: 0 3px;
}
.xr-needle {
  position: absolute; top: 1px; bottom: 1px; width: 3px; margin-left: -1.5px; border-radius: 2px; background: var(--xr-eq);
  left: 16.66%; transition: left .5s cubic-bezier(.3, 1.6, .5, 1); pointer-events: none;
}
.xr-dial[data-station="mod"] .xr-needle { left: 50%; }
.xr-dial[data-station="ja"] .xr-needle { left: 83.33%; }
.xr-st {
  position: relative; z-index: 1; padding: 3px 2px; border: 0; border-radius: 8px; background: none; color: inherit;
  font-size: 12.5px; font-weight: 700; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .7;
}
.xr-st[aria-pressed="true"] { opacity: 1; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }

.xr-yt-slot { width: 100%; aspect-ratio: 16 / 9; margin: 8px 0 4px; border-radius: 12px; border: 3px solid var(--xr-ink); background: #000; }
.xr-yt-slot[hidden] { display: none; }
.xr-yt-line { margin: 2px 4px 0; font-size: 13px; line-height: 1.3; }
.xr-yt-line a, .xr-credit a { color: inherit; font-weight: 700; }
.xr-hint { display: block; opacity: .85; }
.xr-credit { margin: 6px 4px 0; font-size: 11.5px; line-height: 1.3; opacity: .85; overflow-wrap: anywhere; }
.xr-credit:empty { display: none; }

/* ---------- the YouTube player (one iframe; moves between the panel and a corner mini-player without reloading) ---------- */
.xr-yt-host {
  position: fixed; z-index: 81; left: 0; top: 0; width: 280px; border-radius: 10px; overflow: hidden; background: #000;
}
.xr-yt-host[hidden] { display: none; }
.xr-yt-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; }
.xr-yt-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.xr-yt-bar { display: none; }
.xr-yt-host.is-mini {
  left: auto; top: auto; right: 12px; bottom: 12px; width: 232px; max-width: calc(100vw - 24px);
  border: 3px solid var(--xr-ink); border-radius: 14px; background: var(--xr-body); box-shadow: 4px 4px 0 var(--shade, #2b1020);
}
.xr-yt-host.is-mini .xr-yt-bar { display: flex; align-items: center; gap: 6px; padding: 5px 6px; }
.xr-yt-bar .xr-mini-name { flex: 1; min-width: 0; font-weight: 700; font-size: 12.5px; color: var(--ink, #2b1020); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xr-yt-bar .xr-b { width: 30px; height: 28px; border-radius: 9px; font-size: 13px; box-shadow: 1.5px 1.5px 0 var(--xr-ink); }
.xr-yt-bar .xr-b svg { width: 14px; height: 14px; }

/* ---------- phones: the panel becomes a sheet under the header ---------- */
.xr-panel.is-sheet { width: auto; max-width: none; }
@media (max-width: 760px) {
  .xr-boombox { width: 38px; height: 36px; }
  .xr-bb { width: 36px; height: 31px; }
}
@media (max-width: 380px) {
  .xr-face { grid-template-columns: 46px minmax(0, 1fr) 46px; gap: 6px; }
  .xr-spk { width: 46px; height: 46px; }
  .xr-spk i { width: 22px; height: 22px; }
}

/* calm mode / reduced motion: nothing bounces, breathes or floats */
@media (prefers-reduced-motion: reduce) {
  .xr .xr-bb, .xr-case, .xr-note { animation: none !important; }
  .xr-needle { transition: none; }
}
:root[data-calm] .xr .xr-bb, :root[data-calm] .xr-case { animation: none !important; }
:root[data-calm] .xr-note { display: none; }
