/* =========================================================================
   Spotiny · Player styles (v2 — dark premium redesign)
   ----------------------------------------------------------------------------
   1. Mini-player — floats above the bottom-nav bar, fixed 72×72 cover,
                    thin accent progress bar across the very bottom.
   2. Full-screen "Now Playing" view — large square cover, white progress
                                          fill, big white play button.
   3. Queue panel — slide-up sheet.
   ========================================================================= */

/* =========================================================================
   1. Mini-player
   --------------------------------------------------------------------------
   Sits ABOVE the bottom-nav (z-index 35, bottom = --bottom-nav-h).
   DOM structure (unchanged from v1):
     .mini-player
       .mini-player__inner
         .mini-player__main              ← cover | body | controls
           .mini-player__cover (button — opens now playing)
           .mini-player__body (title + artist)
           .mini-player__controls (prev, play, next)
         .mini-player__seek-row          ← cur | range | dur
   ========================================================================= */
.mini-player {
  position: fixed;
  bottom: var(--bottom-nav-h);
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: calc(var(--app-max-w) - 24px);
  height: var(--mini-h);
  z-index: 35;
  background: var(--surface-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  padding: 0;
  /* hidden state */
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(120%);
  transition: opacity var(--dur-3) var(--ease-out),
              transform var(--dur-3) var(--ease-out);
}
.mini-player.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.mini-player__inner {
  width: 100%;
  height: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-2) var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.mini-player__main {
  display: flex; align-items: center; gap: var(--sp-3);
  flex: 1;
  min-height: 0;
}

.mini-player__cover {
  width: var(--mini-h);     /* 72×72 — matches bar height */
  height: var(--mini-h);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-3);
  flex-shrink: 0;
  position: relative;
  display: grid; place-items: center;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  border: 0;
}
.mini-player__cover img { width: 100%; height: 100%; object-fit: cover; display: block; image-rendering: -webkit-optimize-contrast; }
.mini-player__cover--placeholder {
  background: var(--accent-soft);
  color: var(--accent);
}
.mini-player__cover--placeholder svg { width: 22px; height: 22px; }

.mini-player__body {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
  cursor: pointer;
  justify-content: center;
}
.mini-player__title {
  font-size: var(--fs-14); font-weight: 600; color: var(--text);
}
.mini-player__artist {
  font-size: var(--fs-12); color: var(--muted);
}

.mini-player__controls {
  display: flex; align-items: center; gap: var(--sp-1);
  flex-shrink: 0;
}
.mini-player__btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text);
  background: transparent;
  border: 0;
  transition: color var(--dur-1), background var(--dur-1), transform var(--dur-1);
}
.mini-player__btn:hover { color: var(--text); background: var(--surface-3); }
.mini-player__btn:active { transform: scale(0.92); }
.mini-player__btn svg { width: 18px; height: 18px; }
.mini-player__btn--play {
  width: 40px; height: 40px;
  background: var(--bg);
  color: var(--text);
  box-shadow: none;
}
.mini-player__btn--play:hover { background: var(--surface-3); color: var(--text); }
.mini-player__btn--play svg { width: 20px; height: 20px; }
.mini-player__btn--play.is-loading svg { display: none; }
.mini-player__btn--play.is-loading::after {
  content: '';
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.mini-player__seek-row {
  display: flex; align-items: center; gap: var(--sp-2);
}
.mini-player__cur, .mini-player__dur {
  font-size: 10px; color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 32px; text-align: center;
}

/* Native range input styled as progress bar */
.mini-player__seek {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-3);
  outline: none;
  cursor: pointer;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-size: 0% 100%;
  transition: height var(--dur-1);
}
.mini-player__seek:hover { height: 6px; }
.mini-player__seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  cursor: pointer;
  transition: transform var(--dur-1);
}
.mini-player__seek:hover::-webkit-slider-thumb { transform: scale(1.2); }
.mini-player__seek::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
  border: none;
  cursor: pointer;
}
.mini-player__seek:focus-visible {
  box-shadow: 0 0 0 4px var(--accent-softer);
}

/* Thin accent progress bar at the very bottom of the mini-player.
   JS sets --mini-progress via style.setProperty('--mini-progress', pct + '%'). */
.mini-player::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: var(--mini-progress, 0%);
  background: var(--accent);
  transition: width 200ms linear;
  pointer-events: none;
  z-index: 1;
}

/* =========================================================================
   2. Full-screen Now Playing view
   --------------------------------------------------------------------------
   DOM structure (unchanged IDs):
     .now-playing (overlay, fixed, full-screen)
       .now-playing__backdrop (blurred cover image)
       .now-playing__header (close | title | lyrics toggle)
       .now-playing__main (cover-side | lyrics-side)
       .now-playing__footer (progress bar + transport controls)
   ========================================================================= */
.now-playing {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(40px) scale(0.98);
  transition: opacity var(--dur-3) var(--ease-out),
              transform var(--dur-3) var(--ease-out),
              visibility 0s var(--dur-3);
  overflow: hidden;
}
.now-playing.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition: opacity var(--dur-3) var(--ease-out),
              transform var(--dur-3) var(--ease-out),
              visibility 0s;
}

/* Blurred backdrop from cover image */
.now-playing__backdrop {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: blur(80px) saturate(140%);
  opacity: 0.45;
  transform: scale(1.2);
  z-index: 0;
  transition: background-image var(--dur-3) var(--ease-out);
}
.now-playing__backdrop::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(to bottom,
    rgba(13,13,13,0.55) 0%,
    rgba(13,13,13,0.75) 60%,
    rgba(13,13,13,0.95) 100%);
}

/* Header */
.now-playing__header {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 16px 20px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
}
.now-playing__header-title {
  flex: 1;
  text-align: center;
  font-size: var(--fs-13); font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Header actions group (share/sleep/lyrics) */
.now-playing__header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}
.now-playing__header-actions .icon-btn--lg {
  width: 36px; height: 36px;
}

/* Main content area (cover + lyrics side-by-side on desktop, stacked on mobile) */
.now-playing__main {
  position: relative; z-index: 1;
  flex: 1;
  display: flex;
  align-items: stretch;
  gap: var(--sp-6);
  padding: var(--sp-4) var(--sp-5);
  min-height: 0;
  overflow: hidden;
}

/* Cover side (left/top) */
.now-playing__cover-side {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-5);
  width: 100%;
}
.now-playing__cover {
  width: var(--now-playing-cover);   /* min(75vw, 320px) */
  height: var(--now-playing-cover);
  border-radius: var(--r-xl);
  overflow: hidden;
  background: var(--surface-3);
  box-shadow: var(--shadow-lg);
  margin: 0 auto var(--sp-6);
  display: grid; place-items: center;
  color: var(--muted-2);
}
.now-playing__cover img {
  width: var(--now-playing-cover);
  height: var(--now-playing-cover);
  object-fit: cover;
  image-rendering: -webkit-optimize-contrast;
}
.now-playing__cover svg { width: 64px; height: 64px; }

/* Meta row: title + artist on the left, like button on the right */
.now-playing__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 var(--sp-6);
  margin-bottom: var(--sp-6);
  width: 100%;
  gap: var(--sp-3);
}
.now-playing__title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  flex: 1;
  min-width: 0;
  letter-spacing: -0.02em;
}
.now-playing__artist {
  font-size: var(--fs-15);
  color: var(--muted);
  margin-top: 4px;
}
.now-playing__meta-info {
  flex: 1; min-width: 0;
}
/* Like button — moved to the right side of meta as a heart icon only */
.now-playing__meta-like {
  width: 32px; height: 32px;
  flex-shrink: 0;
  display: grid; place-items: center;
  color: var(--muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  border-radius: 50%;
  transition: color var(--dur-1), background var(--dur-1), transform var(--dur-1);
}
.now-playing__meta-like svg { width: 22px; height: 22px; }
.now-playing__meta-like:hover { color: var(--text); background: var(--surface-3); }
.now-playing__meta-like:active { transform: scale(0.92); }
.now-playing__meta-like.is-liked,
.now-playing__meta-like.is-active { color: var(--accent); }
.now-playing__meta-like.is-liked svg,
.now-playing__meta-like.is-active svg { fill: var(--accent); }

/* Legacy actions row (kept for np-queue / np-speed chips) */
.now-playing__actions {
  display: flex; gap: var(--sp-3);
  margin-top: var(--sp-2);
}

/* Lyrics side (right/bottom) — hidden on mobile by default, toggled via .is-lyrics-visible */
.now-playing__lyrics-side {
  flex: 1;
  min-width: 0;
  display: none;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: rgba(0,0,0,0.25);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
}
.now-playing.is-lyrics-visible .now-playing__lyrics-side { display: flex; }
.now-playing.is-lyrics-visible .now-playing__cover-side { display: none; }
@media (min-width: 900px) {
  .now-playing.is-lyrics-visible .now-playing__main {
    flex-direction: row;
  }
  .now-playing.is-lyrics-visible .now-playing__cover-side {
    display: flex;
    width: auto;
    flex: 0 0 360px;
  }
  .now-playing.is-lyrics-visible .now-playing__lyrics-side {
    display: flex;
  }
}

/* Footer (progress + transport) */
.now-playing__footer {
  position: relative; z-index: 1;
  padding: var(--sp-4) var(--sp-6) var(--sp-6);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--sp-6));
}
.now-playing__progress {
  display: flex; align-items: center; gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.now-playing__cur, .now-playing__dur {
  font-size: var(--fs-12); color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
}

/* Progress bar — white fill, white thumb, accent on hover */
.now-playing__bar {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  padding: 8px 0;
  margin: 0;
  outline: none;
}
.now-playing__fill {
  height: 4px;
  border-radius: 2px;
  background: var(--text);   /* white progress fill */
  width: 0%;
  border-radius: 999px;
  transition: width 200ms linear;
}
.now-playing__bar:hover .now-playing__fill { background: var(--accent); }

.now-playing__thumb {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
  width: 12px; height: 12px;
  background: var(--text);
  border-radius: 50%;
  opacity: 0;
  transition: opacity var(--dur-1), background var(--dur-1);
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.now-playing__bar:hover .now-playing__thumb,
.now-playing__bar:focus-visible .now-playing__thumb { opacity: 1; background: var(--accent); }
.now-playing__bar:focus-visible .now-playing__thumb { box-shadow: 0 0 0 4px var(--accent-soft); }

/* Playback controls row */
.now-playing__controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-4);
  margin: var(--sp-6) 0 var(--sp-4);
  gap: var(--sp-4);
}

/* Play button — solid white disc, large */
#np-play {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  border: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 0;
  transition: transform var(--dur-1), background var(--dur-1);
  box-shadow: var(--shadow);
  flex-shrink: 0;
}
#np-play:hover { transform: scale(1.06); background: #fff; }
#np-play:active { transform: scale(0.95); }
#np-play svg { width: 28px; height: 28px; }

#np-prev, #np-next {
  color: var(--text);
}
#np-prev:hover, #np-next:hover { color: var(--text); background: var(--surface-3); }

#np-shuffle, #np-repeat { color: var(--muted); }
#np-shuffle.is-active, #np-repeat.is-active { color: var(--accent); }
#np-shuffle:hover, #np-repeat:hover { background: var(--surface-3); }

/* Legacy icon-btn--xl rule kept so markup that still uses it doesn't break */
.now-playing__controls .icon-btn--xl {
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
  transition: transform var(--dur-1), background var(--dur-1);
}
.now-playing__controls .icon-btn--xl:hover { transform: scale(1.06); }
.now-playing__controls .icon-btn--xl:active { transform: scale(0.95); }

/* Shuffle / repeat active states — accent dot indicator */
.now-playing__controls .icon-btn.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  position: relative;
}
.now-playing__controls .icon-btn.is-active::after {
  content: '';
  position: absolute;
  bottom: 4px; left: 50%;
  transform: translateX(-50%);
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
}
/* Repeat-one indicator (small "1" badge) */
#np-repeat.repeat-one::before {
  content: '1';
  position: absolute;
  top: 4px; right: 4px;
  font-size: 9px; font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

/* Volume row in footer */
.now-playing__volume-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}
.now-playing__volume {
  flex: 1;
  height: 4px;
  background: var(--surface-3);
  border-radius: var(--r-pill);
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  cursor: pointer;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
.now-playing__volume::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 14px; height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: transform var(--dur-1);
  box-shadow: 0 1px 4px var(--accent-glow);
}
.now-playing__volume::-webkit-slider-thumb:hover  { transform: scale(1.3); }
.now-playing__volume::-webkit-slider-thumb:active { transform: scale(1.1); }
.now-playing__volume::-moz-range-thumb {
  width: 14px; height: 14px;
  background: var(--accent);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.now-playing__volume:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* Speed chip in now-playing actions */
#np-speed { font-variant-numeric: tabular-nums; }
#np-speed.is-active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* =========================================================================
   3. Queue panel (slide-up sheet showing state.queue + state.queueIndex)
   ========================================================================= */
.queue-panel {
  position: fixed;
  inset: 0;
  z-index: 50;
  visibility: hidden;
  opacity: 0;
  transition: opacity var(--dur-3) var(--ease-out),
              visibility 0s var(--dur-3);
}
.queue-panel.is-open {
  visibility: visible;
  opacity: 1;
  transition: opacity var(--dur-3) var(--ease-out),
              visibility 0s;
}
.queue-panel__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.queue-panel__sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-width: var(--app-max-w);
  margin: 0 auto;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-strong);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform var(--dur-3) var(--ease-out);
}
.queue-panel.is-open .queue-panel__sheet {
  transform: translateY(0);
}
.queue-panel__header {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5) var(--sp-3);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-18);
  font-weight: 800;
  flex-shrink: 0;
}
.queue-panel__title {
  flex: 1;
  font-size: var(--fs-18);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}
.queue-panel__count {
  font-size: var(--fs-13);
  color: var(--muted);
  flex-shrink: 0;
}
.queue-panel__list {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-2) var(--sp-3) var(--sp-5);
  -webkit-overflow-scrolling: touch;
}
.queue-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--dur-1);
}
.queue-item:hover { background: var(--surface-3); }
.queue-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.queue-item.is-current {
  background: var(--accent-soft);
}
.queue-item__cover {
  width: 40px; height: 40px;
  border-radius: var(--r-xs);
  background: var(--surface-3);
  flex-shrink: 0;
  overflow: hidden;
  display: grid; place-items: center;
  color: var(--muted);
}
.queue-item__cover img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.queue-item__body {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.queue-item__title {
  font-size: var(--fs-14);
  color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.queue-item__artist {
  font-size: var(--fs-12);
  color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.queue-item.is-current .queue-item__title {
  color: var(--accent);
  font-weight: 600;
}
.queue-item__index {
  flex-shrink: 0;
  min-width: 24px;
  text-align: center;
  font-size: var(--fs-13);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  display: grid; place-items: center;
}
.queue-item.is-current .queue-item__index {
  color: var(--accent);
}
.queue-item__index svg { width: 14px; height: 14px; }
.queue-empty {
  text-align: center;
  padding: var(--sp-8) var(--sp-4);
  color: var(--muted);
  font-size: var(--fs-14);
}

/* Queue item: drag handle + remove button + drag-over highlight */
.queue-item__drag {
  display: grid;
  place-items: center;
  width: 20px;
  height: 100%;
  color: var(--muted-2);
  cursor: grab;
  flex-shrink: 0;
  opacity: 0.4;
  transition: opacity var(--dur-1);
}
.queue-item__drag svg { width: 14px; height: 14px; }
.queue-item:hover .queue-item__drag { opacity: 1; color: var(--muted); }
.queue-item__drag:active { cursor: grabbing; }

.queue-item__remove {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  background: transparent;
  border: 0;
  color: var(--muted);
  border-radius: var(--r-pill);
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--dur-1), background var(--dur-1), color var(--dur-1);
}
.queue-item__remove svg { width: 14px; height: 14px; }
.queue-item:hover .queue-item__remove { opacity: 0.7; }
.queue-item__remove:hover  { background: var(--surface-3); color: var(--danger); opacity: 1; }
.queue-item__remove:active { transform: scale(0.92); }
.queue-item__remove:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; opacity: 1; }

.queue-item.is-dragging { opacity: 0.4; }
.queue-item.is-drop-target { background: var(--accent-soft); border-color: var(--accent); }

.queue-panel__clear {
  font-size: var(--fs-12);
  font-weight: 500;
  margin-left: var(--sp-2);
}

/* On wide screens, leave a margin around the sheet so it doesn't span the
   full viewport width. */
@media (min-width: 768px) {
  .queue-panel__sheet {
    margin: 0 var(--sp-5) calc(env(safe-area-inset-bottom, 0px) + var(--sp-4));
    border-radius: var(--r-lg);
    border: 1px solid var(--border-strong);
  }
}
