/* dRUMELODY — Sprint 2 player UI */

:root {
  --mini-player-h: calc(3.75rem + var(--safe-bottom));
  --player-sheet-radius: 1.35rem 1.35rem 0 0;
}

body.has-mini-player .section {
  padding-bottom: calc(var(--dock-h) + var(--mini-player-h) + 0.5rem);
}

body.player-open {
  overflow: hidden;
}

body.player-open .dock {
  transform: translateX(-50%) translateY(120%);
}

/* Backdrop */
.player-backdrop {
  position: fixed;
  inset: 0;
  z-index: 140;
  background: rgba(3, 0, 8, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s var(--ease-out-expo), visibility 0.4s;
}

.player-backdrop.is-visible {
  opacity: 1;
  visibility: visible;
}

/* Bottom sheet */
.player-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  max-height: min(88vh, 640px);
  padding:
    0.5rem 1.15rem
    calc(1.25rem + var(--safe-bottom));
  border-radius: var(--player-sheet-radius);
  background:
    linear-gradient(180deg, rgba(107, 45, 255, 0.12) 0%, transparent 35%),
    rgba(8, 0, 18, 0.94);
  border: 1px solid var(--glass-border);
  border-bottom: none;
  box-shadow:
    0 -24px 80px rgba(0, 0, 0, 0.65),
    0 0 60px rgba(255, 45, 154, 0.12);
  transform: translateY(105%);
  transition: transform 0.55s var(--ease-out-expo);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overflow: hidden;
}

.player-sheet.is-open {
  transform: translateY(0);
}

.player-sheet__handle {
  width: 2.5rem;
  height: 4px;
  margin: 0.15rem auto 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.player-sheet__close {
  position: absolute;
  top: calc(0.65rem + var(--safe-top));
  right: 1rem;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  font-size: 1.35rem;
  line-height: 1;
  color: var(--text-muted);
  z-index: 2;
}

.player-sheet__head {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  padding-right: 2.5rem;
}

.player-sheet__cover {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 0.5rem;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.player-sheet__meta {
  min-width: 0;
  flex: 1;
}

.player-sheet__title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.player-sheet__sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Platform switcher */
.player-platform {
  display: flex;
  gap: 0.35rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 0.15rem;
}

.player-platform::-webkit-scrollbar {
  display: none;
}

.player-platform__btn {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.65rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--text-muted);
  transition: all 0.25s;
}

.player-platform__btn.is-active {
  color: var(--text);
  border-color: var(--magenta);
  background: rgba(255, 45, 154, 0.15);
  box-shadow: 0 0 16px var(--magenta-dim);
}

.player-platform__btn--spotify.is-active {
  border-color: rgba(29, 185, 84, 0.5);
  background: rgba(29, 185, 84, 0.12);
}

.player-platform__btn--deezer.is-active {
  border-color: rgba(255, 85, 0, 0.45);
  background: rgba(255, 85, 0, 0.1);
}

.player-platform__btn--apple.is-active {
  border-color: rgba(252, 60, 68, 0.45);
  background: rgba(252, 60, 68, 0.12);
}

.player-platform__btn--sc.is-active {
  border-color: rgba(255, 85, 0, 0.45);
  background: rgba(255, 85, 0, 0.1);
}

.player-embed--iframe-mode iframe {
  width: 100%;
  min-height: 352px;
  border: 0;
  border-radius: 0.75rem;
}

.player-embed--apple iframe,
.player-embed--soundcloud iframe {
  width: 100%;
  border: 0;
  border-radius: 0.75rem;
}

.player-embed--apple {
  min-height: 11rem;
}

.player-platform__btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* Embed area */
.player-embed-wrap {
  position: relative;
  min-height: 5.5rem;
  border-radius: 0.75rem;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.player-embed {
  width: 100%;
  min-height: 5.5rem;
}

.player-embed--spotify {
  min-height: 5.5rem;
}

.player-embed--spotify iframe {
  border-radius: 0.75rem;
}

.player-embed--deezer {
  min-height: 12rem;
}

.player-embed--deezer iframe {
  width: 100%;
  height: 12rem;
  border: 0;
  border-radius: 0.75rem;
}

.player-embed__fallback {
  padding: 1.5rem 1rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.player-embed__fallback a {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.55rem 1rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  color: var(--text);
}

/* Transport */
.player-transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
}

.player-transport__btn {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--magenta), var(--purple));
  box-shadow: 0 8px 28px var(--magenta-dim);
  font-size: 1.1rem;
  transition: transform 0.2s var(--ease-spring);
}

.player-transport__btn:active {
  transform: scale(0.92);
}

.player-transport__btn svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: currentColor;
}

.player-transport__btn .icon-play,
.player-transport__btn .icon-pause {
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-transport__btn .icon-pause {
  display: none;
}

.player-transport.is-playing .icon-play,
#player-play-toggle.is-playing .icon-play {
  display: none;
}

.player-transport.is-playing .icon-pause,
#player-play-toggle.is-playing .icon-pause {
  display: flex;
}

/* Listen on */
.player-listen-on {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
}

.player-listen-on__link {
  padding: 0.4rem 0.75rem;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
}

.player-listen-on__link:active {
  color: var(--cyan);
  border-color: rgba(0, 245, 255, 0.35);
}

/* Mini player */
.mini-player {
  position: fixed;
  left: 0.65rem;
  right: 0.65rem;
  bottom: calc(var(--dock-h) + 0.35rem);
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.65rem 0.45rem 0.45rem;
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 0 24px var(--magenta-dim);
  transform: translateY(calc(120% + var(--dock-h)));
  transition: transform 0.5s var(--ease-out-expo);
  max-width: 28rem;
  margin: 0 auto;
}

.mini-player.is-visible {
  transform: translateY(0);
}

.mini-player__cover {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.35rem;
  object-fit: cover;
  flex-shrink: 0;
}

.mini-player__info {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.mini-player__title {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-player__artist {
  font-size: 0.62rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.mini-player__play {
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #1db954, var(--acid));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

.mini-player__expand {
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Hero listen as button */
button.btn--listen {
  text-decoration: none;
  color: inherit;
  width: 100%;
  max-width: 18rem;
}

.visualizer.is-live span {
  animation-duration: 0.35s !important;
}

/* ——— Sprint 4: premium player polish ——— */

.player-sheet__glow {
  position: absolute;
  inset: -20% 0 auto;
  height: 55%;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(255, 45, 154, 0.2), transparent 70%);
  pointer-events: none;
}

.player-sheet.is-playing .player-sheet__glow {
  animation: player-glow-pulse 2.2s ease-in-out infinite;
}

@keyframes player-glow-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.player-sheet__cover-wrap {
  position: relative;
  flex-shrink: 0;
}

.player-sheet__cover-aura {
  position: absolute;
  inset: -12%;
  border-radius: 0.65rem;
  background: conic-gradient(from 120deg, var(--magenta), var(--cyan), var(--acid), var(--purple), var(--magenta));
  opacity: 0.55;
  filter: blur(10px);
  animation: cover-aura-spin 6s linear infinite;
}

.player-sheet.is-playing .player-sheet__cover-aura {
  opacity: 0.85;
  animation-duration: 3.5s;
}

@keyframes cover-aura-spin {
  to { transform: rotate(360deg); }
}

.player-sheet__cover {
  position: relative;
  z-index: 1;
  box-shadow:
    0 12px 36px rgba(0, 0, 0, 0.5),
    0 0 32px var(--magenta-dim);
}

.player-waveform {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  height: 2.75rem;
  padding: 0 0.25rem;
}

.player-waveform span {
  flex: 1;
  max-width: 5px;
  height: 22%;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--cyan), var(--magenta));
  transform-origin: bottom;
  transition: height 0.1s ease-out;
}

body.is-playback-live .player-waveform span {
  box-shadow: 0 0 8px var(--magenta-dim);
}

.player-progress {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.player-progress__track {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.player-progress__fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--magenta), var(--cyan), var(--acid));
  box-shadow: 0 0 12px var(--magenta-dim);
  transition: width 0.35s linear;
}

.player-progress__time {
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 4.5rem;
  text-align: right;
}

.player-sheet.is-playing {
  box-shadow:
    0 -28px 90px rgba(0, 0, 0, 0.7),
    0 0 80px rgba(255, 45, 154, 0.18);
}

.player-transport__btn {
  position: relative;
}

.player-sheet.is-playing .player-transport__btn::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid rgba(255, 45, 154, 0.35);
  animation: transport-ring 1.6s ease-out infinite;
}

@keyframes transport-ring {
  0% { transform: scale(0.9); opacity: 0.8; }
  100% { transform: scale(1.35); opacity: 0; }
}

.mini-player__glow {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(255, 45, 154, 0.12), rgba(0, 245, 255, 0.1));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.mini-player.is-playing .mini-player__glow {
  opacity: 1;
}

.mini-player__wave {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 1.5rem;
  flex-shrink: 0;
}

.mini-player__wave span {
  width: 3px;
  height: 30%;
  border-radius: 1px;
  background: linear-gradient(180deg, var(--acid), var(--magenta));
  transform-origin: bottom;
}

.mini-player.is-playing {
  border-color: rgba(255, 45, 154, 0.45);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 0 32px var(--magenta-dim);
}

@media (max-width: 380px) {
  .mini-player__wave {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .player-sheet__cover-aura,
  .player-sheet.is-playing .player-sheet__glow,
  .player-sheet.is-playing .player-transport__btn::after {
    animation: none !important;
  }
}

/* Tracklista */
.player-tracklist {
  list-style: none;
  margin: 0.75rem 1rem 0;
  padding: 0;
  max-height: 9rem;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.65rem;
  background: rgba(0, 0, 0, 0.25);
}

.player-tracklist__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: transparent;
  color: var(--text-muted, rgba(255, 255, 255, 0.75));
  font: inherit;
  font-size: 0.8rem;
  text-align: left;
  cursor: default;
}

.player-tracklist__item.is-playable {
  cursor: pointer;
  color: var(--text, #fff);
}

.player-tracklist__item.is-playable:hover {
  background: rgba(255, 45, 154, 0.12);
}

.player-tracklist__item.is-active {
  background: rgba(57, 255, 20, 0.1);
  color: var(--acid, #39ff14);
}

.player-tracklist__num {
  flex: 0 0 1.25rem;
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
}

.player-tracklist__title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-tracklist__dur {
  flex: 0 0 auto;
  opacity: 0.5;
  font-size: 0.72rem;
}
