/* ===== Background Music Player ===== */

.zen-player {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 90;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  /* Extra padding so mouse doesn't "leave" when moving between toggle and panel */
  padding: 12px;
  margin: -12px;
}

/* ---- Toggle Button ---- */
.zen-player-toggle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(229, 210, 198, 0.5);
  background: rgba(241, 240, 236, 0.88);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-dark);
  transition: box-shadow 0.3s cubic-bezier(0.16,1,0.3,1), transform 0.3s cubic-bezier(0.16,1,0.3,1);
  position: relative;
  padding: 0;
}

.zen-player-toggle:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  transform: translateY(-2px);
}

.zen-player-toggle:focus-visible {
  outline: 2px solid var(--c-norwegian);
  outline-offset: 3px;
}

/* Pulse animation when not playing */
.zen-player:not(.zen-player--playing) .zen-player-toggle {
  animation: zen-pulse 2.5s ease-in-out infinite;
}

.zen-player--playing .zen-player-toggle {
  animation: none;
}

@keyframes zen-pulse {
  0%, 100% { box-shadow: 0 4px 12px rgba(0,0,0,0.08), 0 0 0 0 rgba(147, 105, 82, 0.18); }
  50% { box-shadow: 0 4px 12px rgba(0,0,0,0.08), 0 0 0 10px rgba(147, 105, 82, 0); }
}

/* Note icon: hide when playing */
.zen-player--playing .zen-player-icon-note { display: none; }
.zen-player:not(.zen-player--playing) .zen-player-eq { display: none; }

/* Equalizer bars */
.zen-player-eq {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 16px;
}

.zen-player-eq span {
  width: 3px;
  background: var(--c-norwegian);
  border-radius: 1px;
  animation: zen-eq 1s ease-in-out infinite;
}

.zen-player-eq span:nth-child(1) { height: 60%; animation-delay: 0s; }
.zen-player-eq span:nth-child(2) { height: 100%; animation-delay: 0.2s; }
.zen-player-eq span:nth-child(3) { height: 40%; animation-delay: 0.4s; }

@keyframes zen-eq {
  0%, 100% { transform: scaleY(0.3); }
  50% { transform: scaleY(1); }
}

/* ---- Expand Panel ---- */
.zen-player-panel {
  position: absolute;
  bottom: 60px;
  right: 0;
  width: 260px;
  background: rgba(241, 240, 236, 0.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(229, 210, 198, 0.5);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 16px;
  pointer-events: none;
}

/* Panel open state controlled via inline styles in React */

/* ---- Track Title ---- */
.zen-player-track {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(229, 210, 198, 0.4);
}

.zen-player-title {
  font-size: 0.9rem;
  color: var(--c-dark);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Progress Bar ---- */
.zen-player-progress {
  margin-bottom: 8px;
}

.zen-player-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--c-skin);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  outline: none;
}

.zen-player-progress-bar:focus-visible {
  outline: 2px solid var(--c-norwegian);
  outline-offset: 3px;
}

.zen-player-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--c-dark), var(--c-norwegian));
  border-radius: 2px;
  width: 0%;
  pointer-events: none;
  transition: width 0.1s linear;
}

.zen-player-progress-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c-dark);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s cubic-bezier(0.16,1,0.3,1);
}

.zen-player-progress-bar:hover .zen-player-progress-thumb,
.zen-player-progress-bar:focus-visible .zen-player-progress-thumb {
  opacity: 1;
}

.zen-player-time {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--c-hipster);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* ---- Controls ---- */
.zen-player-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.zen-player-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-hipster);
  transition: color 0.3s cubic-bezier(0.16,1,0.3,1), background 0.3s cubic-bezier(0.16,1,0.3,1);
  flex-shrink: 0;
  padding: 0;
}

.zen-player-btn:hover {
  color: var(--c-dark);
  background: rgba(147, 105, 82, 0.08);
}

.zen-player-btn:focus-visible {
  outline: 2px solid var(--c-norwegian);
  outline-offset: 2px;
}

/* ---- Volume ---- */
.zen-player-volume {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.zen-player-slider {
  width: 55px;
  height: 3px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--c-skin);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.zen-player-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--c-dark);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  cursor: pointer;
  border: none;
}

.zen-player-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--c-dark);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  cursor: pointer;
  border: none;
}

.zen-player-slider:focus-visible {
  outline: 2px solid var(--c-norwegian);
  outline-offset: 3px;
}

/* ---- Playlist Panel ---- */
.zen-player-playlist {
  position: absolute;
  bottom: 60px;
  right: 0;
  width: 155px;
  overflow: hidden;
  background: rgba(241, 240, 236, 0.95);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(229, 210, 198, 0.5);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  pointer-events: none;
  z-index: 1;
}

/* Playlist open state controlled via inline styles in React */

.zen-player-playlist-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 8px 8px 8px 1em;
  border-bottom: 1px solid rgba(229, 210, 198, 0.4);
}

.zen-player-playlist-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--c-dark);
}

.zen-player-playlist-list {
  list-style: none;
  margin: 0;
  padding: 8px 0 16px;
  overflow-y: visible;
}

.zen-player-playlist-list::-webkit-scrollbar {
  width: 4px;
}

.zen-player-playlist-list::-webkit-scrollbar-track {
  background: transparent;
}

.zen-player-playlist-list::-webkit-scrollbar-thumb {
  background: var(--c-skin);
  border-radius: 2px;
}

/* Playlist items */
.zen-player-playlist-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  padding: 4px 8px 4px 1em;
  cursor: pointer;
  transition: background 0.2s cubic-bezier(0.16,1,0.3,1), color 0.2s cubic-bezier(0.16,1,0.3,1);
  font-size: 0.92rem;
  color: var(--c-hipster);
}

.zen-player-playlist-item:hover {
  background: rgba(147, 105, 82, 0.12);
  color: var(--c-dark);
  font-weight: 500;
}

.zen-player-playlist-item--active {
  color: var(--c-norwegian);
  font-weight: 600;
}

.zen-player-playlist-item-num {
  font-size: 0.8rem;
  color: var(--c-hipster);
  width: 1.6em;
  text-align: right;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.zen-player-playlist-item--active .zen-player-playlist-item-num {
  color: var(--c-dark);
  display: none;
}

.zen-player-playlist-item-eq {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
  width: 1.6em;
  justify-content: center;
  flex-shrink: 0;
}

.zen-player-playlist-item--active .zen-player-playlist-item-eq {
  display: flex;
}

.zen-player-playlist-item-eq span {
  width: 2px;
  background: var(--c-norwegian);
  border-radius: 1px;
  animation: zen-eq 1s ease-in-out infinite;
}

.zen-player-playlist-item-eq span:nth-child(1) { height: 50%; animation-delay: 0s; }
.zen-player-playlist-item-eq span:nth-child(2) { height: 100%; animation-delay: 0.15s; }
.zen-player-playlist-item-eq span:nth-child(3) { height: 35%; animation-delay: 0.3s; }

.zen-player-playlist-item-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Playlist toggle active state */
.zen-player-btn--list-active {
  color: var(--c-dark);
  background: rgba(147, 105, 82, 0.1);
}

/* ---- Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
  .zen-player-toggle { animation: none !important; }
  .zen-player-eq span { animation: none !important; transform: scaleY(0.6); }
  .zen-player-panel { transition-duration: 0.01s; }
  .zen-player-playlist-item-eq span { animation: none !important; transform: scaleY(0.6); }
}

/* ---- Mobile ---- */
@media (max-width: 768px) {
  .zen-player {
    bottom: 72px;
    right: 16px;
  }

  .zen-player-toggle {
    width: 44px;
    height: 44px;
  }

  .zen-player-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: 16px 16px 0 0;
    transform-origin: bottom center;
    padding: 24px 24px 32px;
  }

  .zen-player-slider {
    width: 100px;
  }

  .zen-player-btn {
    width: 44px;
    height: 44px;
  }

  .zen-player-playlist {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 0;
  }

  /* mobile playlist max-height handled in React inline styles */

  .zen-player-playlist-list {
    max-height: calc(60vh - 50px);
  }

  .zen-player-playlist-item {
    padding: 12px 24px;
  }
}

/* Screen reader only */
.zen-player .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
