/* players.css — 5 player style variants. Each scoped via #player-root.player-style-<id> */

#player-root {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0) + 20px);
  right: calc(env(safe-area-inset-right, 0) + 20px);
  z-index: 9999;
  font-family: inherit;
  max-width: calc(100vw - 40px);
}
#player-root audio { display: none; }

/* Panel toggle (visible when panel hidden) */
.panel-toggle {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0) + 20px);
  right: calc(env(safe-area-inset-right, 0) + 20px);
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 1.5px solid var(--theme-color);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}
.panel-toggle.visible { display: flex; }

/* Shared bits */
.p-art-wrap { position: relative; }
.p-art {
  width: 90px; height: 90px;
  border-radius: 10px;
  object-fit: cover;
  background: #222;
  transition: opacity .25s ease;
  opacity: 1;
}
.p-art.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.p-title {
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: break-word;
  max-width: 100%;
}
.p-listeners { color: #aaa; font-size: 11px; display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; }
.p-play {
  width: 44px; height: 44px; border-radius: 50%;
  border: none;
  background: #00ff88;
  color: #001122;
  font-size: 16px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 15px rgba(0,255,136,0.3);
  transition: background .2s ease, transform .15s ease;
}
.p-play.playing { background: #ff6b6b; }
.p-play:hover { transform: scale(1.06); }
.p-progress { flex: 1; height: 4px; background: #333; border-radius: 2px; overflow: hidden; }
.p-progress-fill { height: 100%; background: var(--theme-color); width: 100%; transition: width .2s linear; }
.p-volume { flex: 1; height: 4px; appearance: none; -webkit-appearance: none; background: #333; border-radius: 2px; cursor: pointer; }
.p-volume::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--theme-color); cursor: pointer; }
.p-volume::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--theme-color); cursor: pointer; border: none; }
.p-hide-btn {
  background: rgba(255,255,255,0.08); border: none;
  color: #fff; width: 28px; height: 28px; border-radius: 50%;
  cursor: pointer; font-size: 11px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ===== STYLE: CLASSIC ===== */
.player-style-classic #player-panel {
  width: 320px;
  background: var(--player-panel-bg, linear-gradient(135deg, #1a1a2e 0%, #16213e 100%));
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.1);
  position: relative;
}
.player-style-classic .p-top { display: flex; align-items: center; gap: 12px; }
.player-style-classic .p-info { flex: 1; min-width: 0; }
.player-style-classic .p-hide-btn { position: absolute; top: 8px; right: 8px; }
.player-style-classic .p-progress-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.player-style-classic .p-time { color: #888; font-size: 10px; min-width: 35px; }
.player-style-classic .p-vol-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: #666; font-size: 12px; }

/* ===== STYLE: CUBE ===== */
.player-style-cube #player-panel {
  width: 240px; height: 360px;
  background: var(--player-panel-bg, #1a1a2e);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  display: flex; flex-direction: column;
  position: relative;
}
.player-style-cube .p-cube-top {
  height: 40px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  color: #fff;
  font-size: 11px;
}
.player-style-cube .p-cube-mid {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 14px;
  background: var(--player-panel-bg, linear-gradient(180deg, #1a1a2e 0%, #16213e 100%));
}
.player-style-cube .p-art { width: 120px; height: 120px; border-radius: 12px; }
.player-style-cube .p-cube-text { text-align: center; margin-top: 10px; width: 100%; }
.player-style-cube .p-cube-bottom {
  height: 96px; padding: 10px 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: #1a1a2e;
}
.player-style-cube .p-play { width: 44px; height: 44px; font-size: 16px; }
.player-style-cube .p-vol-row { display: flex; align-items: center; gap: 8px; width: 100%; color: rgba(255,255,255,0.65); font-size: 11px; }

/* ===== STYLE: MINIMAL ===== */
.player-style-minimal #player-panel {
  min-width: 280px;
  max-width: 420px;
  background: var(--player-panel-bg, rgba(0,0,0,0.75));
  border-radius: 999px;
  padding: 8px 10px;
  display: flex; align-items: center; gap: 10px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.player-style-minimal .p-art { width: 40px; height: 40px; border-radius: 50%; }
.player-style-minimal .p-info { flex: 1; min-width: 0; overflow: hidden; }
.player-style-minimal .p-title { font-size: 12px; }
.player-style-minimal .p-listeners { font-size: 10px; margin-top: 2px; }
.player-style-minimal .p-play { width: 36px; height: 36px; font-size: 12px; }
.player-style-minimal .p-hide-btn { width: 22px; height: 22px; }
.player-style-minimal .p-progress-row, .player-style-minimal .p-vol-row { display: none; }

/* ===== STYLE: NEON ===== */
.player-style-neon #player-panel {
  width: 320px;
  padding: 14px;
  border-radius: 18px;
  background: var(--player-panel-bg, rgba(5, 10, 30, 0.9));
  border: 2px solid var(--theme-color);
  box-shadow:
    0 0 20px var(--theme-glow),
    0 0 40px var(--theme-glow),
    inset 0 0 20px rgba(0,240,255,0.12);
  position: relative;
  animation: neonPulse 2.4s infinite alternate;
  overflow: hidden;
}
@keyframes neonPulse {
  from { box-shadow: 0 0 18px var(--theme-glow), 0 0 30px var(--theme-glow); }
  to   { box-shadow: 0 0 28px var(--theme-color), 0 0 60px var(--theme-glow); }
}
.player-style-neon .p-hide-btn { position: absolute; top: 8px; right: 8px; }
.player-style-neon .p-top { display: flex; gap: 12px; align-items: center; overflow: hidden; }
.player-style-neon .p-info { flex: 1; min-width: 0; overflow: hidden; }
.player-style-neon .p-art { border: 2px solid var(--theme-color); box-shadow: 0 0 14px var(--theme-glow); flex-shrink: 0; }
.player-style-neon .p-title { color: var(--theme-color); text-shadow: 0 0 8px var(--theme-glow); }
.player-style-neon .p-play {
  background: transparent; border: 2px solid var(--theme-color); color: var(--theme-color);
  box-shadow: 0 0 12px var(--theme-glow);
}
.player-style-neon .p-play.playing { background: var(--theme-color); color: #001122; }
.player-style-neon .p-progress-row, .player-style-neon .p-vol-row {
  display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--theme-color); font-size: 11px;
}

/* ===== STYLE: VINYL ===== */
.player-style-vinyl #player-panel {
  width: 300px;
  background: var(--player-panel-bg, radial-gradient(circle at 30% 30%, #2a2a3e, #0a0a1a 70%));
  border-radius: 18px;
  padding: 18px;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  position: relative;
  text-align: center;
}
.player-style-vinyl .p-hide-btn { position: absolute; top: 8px; right: 8px; }
.player-style-vinyl .p-vinyl-wrap {
  position: relative;
  width: 200px; height: 200px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: radial-gradient(circle, #111 40%, #1a1a1a 41%, #0a0a0a 60%, #111 61%);
  box-shadow: 0 8px 24px rgba(0,0,0,0.7), inset 0 0 8px rgba(0,0,0,0.9);
  display: flex; align-items: center; justify-content: center;
  animation: vinylSpin 10s linear infinite;
  animation-play-state: paused;
  overflow: hidden;
}
.player-style-vinyl.playing .p-vinyl-wrap { animation-play-state: running; }
@keyframes vinylSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.player-style-vinyl .p-art {
  width: 140px; height: 140px; border-radius: 50%;
  border: 6px solid #0a0a0a;
}
.player-style-vinyl .p-title { margin-top: 6px; max-width: 100%; width: 280px; }
.player-style-vinyl .p-controls { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 10px; }
.player-style-vinyl .p-play { width: 52px; height: 52px; font-size: 18px; }
.player-style-vinyl .p-vol-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: #888; font-size: 11px; }

/* ===== STYLE: WAVE ===== */
.player-style-wave #player-panel {
  width: 320px;
  background: var(--player-panel-bg, linear-gradient(160deg, #0f2d5a 0%, #0a4d7c 50%, #0d3b5e 100%));
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,100,200,0.45);
  border: 1px solid rgba(0,180,255,0.2);
  position: relative;
}
.player-style-wave .p-hide-btn {
  position: absolute; top: 8px; right: 8px; z-index: 2;
}
.player-style-wave .p-wave-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 0;
}
.player-style-wave .p-art {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  border: 2px solid rgba(0,200,255,0.3);
}
.player-style-wave .p-wave-meta {
  flex: 1;
  min-width: 0;
}
.player-style-wave .p-title {
  font-size: 13px;
  color: #e0f4ff;
}
.player-style-wave .p-listeners {
  color: rgba(0,200,255,0.75);
}
.player-style-wave .p-wave-svg {
  display: block; width: 100%; height: 44px; margin-top: 8px;
  overflow: hidden;
}
/* The SVG is 200% of the container = 2 identical wave cycles.
   translateX(-50%) moves it left by 50% of its own width = 100% of the container = 1 full cycle.
   At that point the second cycle is exactly where the first was → perfect seamless loop. */
.player-style-wave .p-wave-anim {
  width: 200%;
  height: 100%;
  display: block;
  animation: wavePan 4s linear infinite;
}
@keyframes wavePan {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
.player-style-wave .p-wave-footer {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 14px 14px;
}
.player-style-wave .p-vol-row { flex: 1; display: flex; align-items: center; gap: 8px; color: rgba(0,200,255,0.65); font-size: 12px; }
.player-style-wave .p-wave-svg {
  display: block; width: 100%; height: 44px; margin-top: 8px;
}
.player-style-wave .p-play { background: linear-gradient(135deg, #00b4ff, #0070c0); box-shadow: 0 4px 16px rgba(0,150,255,0.4); }

/* ===== STYLE: GLASS ===== */
.player-style-glass #player-panel {
  width: 300px;
  background: var(--player-panel-bg, rgba(255,255,255,0.07));
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 22px;
  padding: 16px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.15);
  position: relative;
}
.player-style-glass .p-hide-btn { position: absolute; top: 10px; right: 10px; background: rgba(255,255,255,0.1); }
.player-style-glass .p-glass-art-wrap { text-align: center; margin-bottom: 12px; }
.player-style-glass .p-art {
  width: 110px; height: 110px; border-radius: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.player-style-glass .p-glass-info { text-align: center; margin-bottom: 14px; }
.player-style-glass .p-title { font-size: 14px; color: rgba(255,255,255,0.92); }
.player-style-glass .p-listeners { justify-content: center; color: rgba(255,255,255,0.5); margin-top: 4px; }
.player-style-glass .p-glass-controls {
  display: flex; align-items: center; gap: 12px;
}
.player-style-glass .p-play {
  background: rgba(255,255,255,0.18); border: 1.5px solid rgba(255,255,255,0.35);
  color: #fff; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.player-style-glass .p-play.playing { background: rgba(255,255,255,0.3); }
.player-style-glass .p-volume { flex: 1; }

/* ===== STYLE: RETRO ===== */
.player-style-retro #player-panel {
  width: 310px;
  background: var(--player-panel-bg, #0d0d1a);
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid #ff00cc;
  box-shadow: 0 0 20px rgba(255,0,204,0.5), 0 0 60px rgba(255,0,204,0.2), inset 0 0 30px rgba(0,0,0,0.8);
  position: relative;
}
.player-style-retro::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,0,204,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,0,204,0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
  z-index: 0;
}
.player-style-retro .p-retro-header {
  position: relative; z-index: 1;
  background: linear-gradient(90deg, #ff00cc, #7700ff);
  padding: 6px 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.player-style-retro .p-retro-label {
  font-size: 10px; font-weight: 900; letter-spacing: 2px; color: #fff;
  text-shadow: 0 0 8px rgba(255,255,255,0.6);
  font-family: 'Courier New', monospace;
}
.player-style-retro .p-hide-btn { background: rgba(0,0,0,0.3); border: none; }
.player-style-retro .p-retro-screen {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 12px;
  padding: 14px;
}
.player-style-retro .p-art {
  width: 80px; height: 80px; border-radius: 4px;
  border: 2px solid #ff00cc;
  box-shadow: 0 0 10px rgba(255,0,204,0.5);
}
.player-style-retro .p-retro-info { flex: 1; min-width: 0; }
.player-style-retro .p-title { color: #ff00cc; text-shadow: 0 0 8px rgba(255,0,204,0.8); font-family: 'Courier New', monospace; font-size: 12px; }
.player-style-retro .p-listeners { color: rgba(0,240,255,0.8); }
.player-style-retro .p-retro-controls {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px 14px;
}
.player-style-retro .p-play {
  background: transparent; border: 2px solid #ff00cc; color: #ff00cc;
  box-shadow: 0 0 10px rgba(255,0,204,0.5), inset 0 0 10px rgba(255,0,204,0.1);
  flex-shrink: 0;
}
.player-style-retro .p-play.playing { background: #ff00cc; color: #000; }
.player-style-retro .p-vol-row { flex: 1; display: flex; align-items: center; gap: 8px; color: rgba(0,240,255,0.7); font-size: 11px; }
.player-style-retro .p-volume { accent-color: #ff00cc; }

/* ===== STYLE: CARD ===== */
.player-style-card #player-panel {
  width: 300px;
  background: var(--player-panel-bg, #111);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.08);
}
.player-style-card .p-card-hero {
  position: relative; height: 160px;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  overflow: hidden;
}
.player-style-card .p-art {
  width: 100%; height: 100%;
  object-fit: cover; border-radius: 0;
  transition: opacity .4s ease;
}
.player-style-card .p-art.hidden { visibility: hidden; opacity: 0; }
.player-style-card .p-card-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  padding: 28px 12px 10px;
}
.player-style-card .p-title { font-size: 14px; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,0.8); }
.player-style-card .p-listeners { color: rgba(255,255,255,0.65); }
.player-style-card .p-card-controls {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: #181818;
}
.player-style-card .p-vol-row { flex: 1; display: flex; align-items: center; gap: 8px; color: #666; font-size: 12px; }
.player-style-card .p-play { background: var(--theme-color); color: #001122; box-shadow: 0 4px 14px var(--theme-glow); }

/* ===== STYLE: PARTY ===== */
.player-style-party #player-panel {
  width: 280px;
  background: var(--player-panel-bg, #0a0a14);
  border-radius: 20px;
  padding: 16px;
  border: 2px solid transparent;
  background-clip: padding-box;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  text-align: center;
}
.player-style-party #player-panel::before {
  content: '';
  position: absolute; inset: -2px; border-radius: 22px; z-index: -1;
  background: linear-gradient(135deg, #ff0080, #ff8c00, #40e0d0, #a64dff, #ff0080);
  background-size: 300% 300%;
  animation: partyGradient 4s ease infinite;
}
@keyframes partyGradient {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.player-style-party .p-hide-btn { position: absolute; top: 8px; right: 8px; }
.player-style-party .p-party-art {
  position: relative; width: 120px; height: 120px; margin: 8px auto 10px;
}
/* Art sits on top of the ring so it's always visible */
.player-style-party .p-art {
  width: 120px; height: 120px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.2);
  position: relative; z-index: 1;
}
/* Ring sits behind the art; transparent fill so the art shows through */
.player-style-party .p-party-ring {
  position: absolute; inset: -6px; border-radius: 50%;
  border: 3px solid transparent;
  background: transparent padding-box,
              linear-gradient(135deg, #ff0080, #ff8c00, #40e0d0, #a64dff) border-box;
  animation: partyRingSpin 3s linear infinite;
  z-index: 0;
}
@keyframes partyRingSpin { to { transform: rotate(360deg); } }
.player-style-party .p-party-title { font-size: 13px; margin-bottom: 4px; }
.player-style-party .p-party-listeners { justify-content: center; color: rgba(255,255,255,0.55); }
.player-style-party .p-party-controls {
  display: flex; align-items: center; gap: 10px; margin-top: 12px;
}
.player-style-party .p-play {
  background: linear-gradient(135deg, #ff0080, #a64dff);
  box-shadow: 0 4px 16px rgba(255,0,128,0.4);
  flex-shrink: 0;
}
.player-style-party .p-play.playing {
  background: linear-gradient(135deg, #ff8c00, #ff0080);
}
.player-style-party .p-volume { flex: 1; accent-color: #ff0080; }

/* iOS: hide volume (native volume only) */
.ios .p-vol-row { display: none !important; }

/* ===== SONG REQUEST INPUT ===== */
#song-request-input {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 9998;
  width: 300px;
  padding: 15px;
  border-radius: 25px;
  border: 2px solid #00f0ff;
  background: var(--ui-bg, rgba(0, 20, 60, 0.9));
  color: #fff;
  font-size: 16px;
  outline: none;
  box-sizing: border-box;
}
#song-request-input::placeholder { color: rgba(255,255,255,0.45); }

/* Mobile sizing — catches all iPhones in portrait */
@media (max-width: 480px) {
  /* Player panel sits above the song-request bar */
  #player-root {
    bottom: 66px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(92vw, 360px);
  }
  .player-style-classic #player-panel,
  .player-style-neon #player-panel,
  .player-style-vinyl #player-panel,
  .player-style-wave #player-panel,
  .player-style-glass #player-panel,
  .player-style-retro #player-panel,
  .player-style-card #player-panel,
  .player-style-party #player-panel { width: 92vw; max-width: 360px; }
  .player-style-cube #player-panel { width: min(240px, 92vw); max-width: 260px; height: 360px; }
  .player-style-minimal #player-panel { width: 92vw; max-width: 360px; }

  /* Toggle (show-player) button: centred horizontally, floating above request bar.
     Works correctly because mountPlayer() moves it to <body>, outside any
     CSS-transformed parent. */
  .panel-toggle {
    bottom: 70px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 1.5px solid var(--theme-color);
  }

  /* Song request bar: full-width strip pinned to the very bottom */
  #song-request-input {
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 56px;
    padding: 0 18px;
    border-radius: 0;
    border: none;
    border-top: 2px solid #00f0ff;
    font-size: 15px;
    box-sizing: border-box;
  }
}
