/* Persistent bottom audio player bar */

#persistent-audio-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1020;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Raised only while the full-screen panel is open, so it covers the mobile nav */
#persistent-audio-player.panel-expanded {
  z-index: 1035;
}

#persistent-audio-player.visible {
  transform: translateY(0);
}

.audio-player-bar {
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
  padding-bottom: 8px;
  padding-top: 0;
}

.audio-player-progress {
  height: 5px;
  background: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  position: relative;
  touch-action: none;
}

.audio-player-progress:hover .audio-player-progress-handle,
.audio-player-progress.seeking .audio-player-progress-handle {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

.audio-player-progress-fill {
  height: 100%;
  background: #18bc9c;
  width: 0%;
  position: relative;
  transition: width 0.1s linear;
}

.audio-player-progress.seeking .audio-player-progress-fill {
  transition: none;
}

.audio-player-progress-handle {
  position: absolute;
  right: -7px;
  top: 50%;
  transform: translateY(-50%) scale(0);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #18bc9c;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}

.audio-player-controls {
  display: flex;
  align-items: center;
  padding: 0.6rem 1rem;
  gap: 0.75rem;
}

.audio-player-transport {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

/* Transport button base style */
.audio-player-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  padding: 0.3rem;
  line-height: 1;
  font-size: 1rem;
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
}

.audio-player-btn:hover {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.15);
}

.audio-player-btn:active {
  transform: scale(0.9);
}

.audio-player-btn:disabled {
  color: rgba(255, 255, 255, 0.25);
  cursor: default;
  background: none;
}

.audio-player-btn:disabled:hover {
  background: none;
  color: rgba(255, 255, 255, 0.25);
}

/* Main play/pause button — larger */
.audio-player-btn-main {
  font-size: 1.4rem;
  padding: 0.35rem;
  color: #fff;
}

.audio-player-btn-main:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

/* Close button */
.audio-player-close-btn {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.85rem;
}

.audio-player-close-btn:hover {
  color: rgba(255, 255, 255, 0.8);
}

/* Continuous play toggle */
.audio-player-continuous-btn {
  color: rgba(255, 255, 255, 0.4);
}

.audio-player-continuous-btn.active {
  color: #18bc9c;
}

.audio-player-continuous-btn.active:hover {
  color: #1ad6b2;
}

/* Generating state */
.audio-player-generating {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
}

.audio-player-generating-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.audio-player-generating-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #18bc9c;
  border-radius: 50%;
  animation: audio-spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes audio-spin {
  to { transform: rotate(360deg); }
}

.audio-player-generating-text {
  display: flex;
  flex-direction: column;
}

.audio-player-generating-title {
  font-weight: 500;
  font-size: 0.95rem;
}

.audio-player-generating-meta {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
}

@media (min-width: 768px) {
  .audio-player-generating {
    padding: 1rem 3rem;
  }

  .audio-player-generating-spinner {
    width: 28px;
    height: 28px;
  }

  .audio-player-generating-title {
    font-size: 1.05rem;
  }
}

@media (min-width: 1200px) {
  .audio-player-generating {
    padding: 1rem 5rem;
  }
}

.audio-player-track-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.audio-player-title {
  font-weight: 500;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-player-meta {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-player-time {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  white-space: nowrap;
}

.audio-player-speed {
  font-size: 0.65rem;
  padding: 0.05rem 0.15rem;
  flex-shrink: 0;
  min-width: auto;
}

/* Body padding when player is visible */
body.has-audio-player {
  padding-bottom: 64px;
}

/* Adjust toast container position when player is visible */
body.has-audio-player .toast-container-fixed {
  bottom: 80px;
}

/* Safe area inset for notch devices, with 8px minimum fallback */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .audio-player-bar {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  body.has-audio-player {
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
  }
}

/* Desktop: larger player with more padding */
@media (min-width: 768px) {
  .audio-player-controls {
    padding: 0.75rem 3rem;
    gap: 1rem;
  }

  .audio-player-btn {
    font-size: 1.1rem;
    padding: 0.4rem;
  }

  .audio-player-btn-main {
    font-size: 1.6rem;
    padding: 0.4rem;
  }

  .audio-player-title {
    font-size: 0.95rem;
  }

  .audio-player-meta {
    font-size: 0.8rem;
  }

  .audio-player-time {
    font-size: 0.85rem;
  }

  body.has-audio-player {
    padding-bottom: 72px;
  }

  body.has-audio-player .toast-container-fixed {
    padding-bottom: 88px;
  }
}

@media (min-width: 1200px) {
  .audio-player-controls {
    padding: 0.85rem 5rem;
    gap: 1.25rem;
  }
}

/* Mobile: compact layout */
@media (max-width: 576px) {
  .audio-player-controls {
    padding: 0.4rem 0.5rem;
    gap: 0.5rem;
  }

  .audio-player-btn-main {
    font-size: 1.5rem;
    padding: 0.4rem;
  }

  .audio-player-time {
    display: none;
  }
}

/* Listen page styles */

.playlist-track {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  cursor: pointer;
  transition: background-color 0.15s ease;
  gap: 0.75rem;
}

.playlist-track:hover {
  background-color: rgba(0, 0, 0, 0.03);
}

.playlist-track.active {
  background-color: rgba(44, 62, 80, 0.08);
  border-left: 3px solid #2c3e50;
  color: inherit;
}

.playlist-track.disabled {
  opacity: 0.5;
  cursor: default;
}

.playlist-track-number {
  width: 2rem;
  text-align: center;
  font-size: 0.875rem;
  color: #6c757d;
  flex-shrink: 0;
}

.playlist-track.active .playlist-track-number {
  color: #2c3e50;
  font-weight: 600;
}

.playlist-track-info {
  flex: 1;
  min-width: 0;
}

.playlist-track-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist-track-meta {
  font-size: 0.8rem;
  color: #6c757d;
}

.playlist-track-actions {
  flex-shrink: 0;
}

.playlist-track .bi-soundwave {
  color: #2c3e50;
  animation: soundwave-pulse 1.5s ease-in-out infinite;
}

@keyframes soundwave-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* Listen page header / now playing */
.listen-now-playing {
  background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
  color: white;
  border-radius: 0.5rem;
  padding: 1.5rem;
}

.listen-now-playing .track-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.listen-now-playing .track-meta {
  color: rgba(255, 255, 255, 0.7);
}

/* ============================================================
   Mobile full-screen "now playing" panel
   ============================================================ */

.audio-player-panel {
  position: fixed;
  inset: 0;
  z-index: 1031;
  background: linear-gradient(160deg, #1a252f 0%, #0d1117 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(env(safe-area-inset-top), 20px) 1.5rem
           calc(env(safe-area-inset-bottom) + 1.5rem);
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  will-change: transform;
}

.audio-player-panel.panel-open {
  transform: translateY(0);
}

/* Drag handle / dismiss button */
.audio-player-panel-handle {
  width: 100%;
  text-align: center;
  padding: 0 0 1.25rem;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: none;
}

.audio-player-panel-handle-icon {
  font-size: 1.5rem;
  color: rgba(255, 255, 255, 0.45);
  line-height: 1;
  display: block;
  transition: color 0.15s ease;
}

.audio-player-panel-handle:active .audio-player-panel-handle-icon {
  color: rgba(255, 255, 255, 0.8);
}

/* Cover view wrapper — same flex footprint as text view so controls don't shift */
.audio-player-panel-cover-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  flex: 1;
  min-height: 0;
}

/* Text view */
.audio-player-panel-text-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  width: 100%;
  scrollbar-width: none;
}

.audio-player-panel-text-view::-webkit-scrollbar {
  display: none;
}

.audio-player-panel-text-content {
  font-size: 0.95rem;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.85);
  white-space: pre-wrap;
  padding-bottom: 2rem;
}

/* Artwork — fills available space in the cover view */
.audio-player-panel-artwork {
  width: 85%;
  max-width: 320px;
  flex: 1;
  min-height: 0;
  margin: 0 auto 1.25rem;
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.audio-player-panel-artwork-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.audio-player-panel-artwork-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  font-size: 4rem;
  color: rgba(255, 255, 255, 0.25);
}

/* Track info */
.audio-player-panel-info {
  width: 100%;
  text-align: center;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.audio-player-panel-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 0.5rem;
}

.audio-player-panel-meta {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.55);
}

/* Progress bar */
.audio-player-panel-progress-wrap {
  width: 100%;
  margin-bottom: 0.25rem;
  flex-shrink: 0;
}

/* Large touch target — 44px tall so fingers can grab it easily */
.audio-player-panel-progress-touch {
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
  margin-bottom: 0.25rem;
}

/* Visual track inside the touch target */
.audio-player-panel-progress-track {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  position: relative;
}

.audio-player-panel-progress-fill {
  height: 100%;
  background: #18bc9c;
  border-radius: 3px;
  width: 0%;
  position: relative;
  transition: width 0.1s linear;
}

.audio-player-panel-progress-touch.seeking .audio-player-panel-progress-fill {
  transition: none;
}

.audio-player-panel-progress-handle {
  position: absolute;
  right: -9px;
  top: 50%;
  transform: translateY(-50%) scale(0.65);
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s ease;
  pointer-events: none;
  opacity: 0.9;
}

.audio-player-panel-progress-touch:active .audio-player-panel-progress-handle,
.audio-player-panel-progress-touch.seeking .audio-player-panel-progress-handle {
  transform: translateY(-50%) scale(1);
}

.audio-player-panel-times {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.45);
  font-variant-numeric: tabular-nums;
}

/* Transport */
.audio-player-panel-controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
  flex-shrink: 0;
}

/* ±15 s skip buttons */
.audio-player-panel-btn-skip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: 1.6rem;
}

.audio-player-panel-btn-skip small {
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.7);
}

.audio-player-panel-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: 2rem;
  padding: 0.25rem;
  cursor: pointer;
  line-height: 1;
  transition: opacity 0.1s, transform 0.1s;
}

.audio-player-panel-btn:active {
  opacity: 0.5;
  transform: scale(0.88);
}

.audio-player-panel-btn[disabled] {
  opacity: 0.2;
  cursor: default;
}

.audio-player-panel-btn-main {
  font-size: 3.75rem;
  color: #fff;
}

/* Secondary controls */
.audio-player-panel-secondary {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-shrink: 0;
}

.audio-player-panel-secondary-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1.4rem;
  padding: 0.25rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s;
}

.audio-player-panel-secondary-btn.active {
  color: #18bc9c;
}

/* Mini bar track-info — tap affordance on mobile */
@media (max-width: 767.98px) {
  .audio-player-track-info {
    cursor: pointer;
  }
}

.audio-player-expand-btn {
  color: rgba(255, 255, 255, 0.6);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.audio-player-expand-btn:hover {
  color: #18bc9c;
}
