/* Hidden in-DOM audio (required for reliable background / lock-screen on many mobile browsers) */
.koshermusik-global-audio {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

/* ===== NAV PLAYER DOCK (next to logo) ===== */
.nav-brand-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  margin-right: auto;
}

.nav-brand-group .nav-logo {
  margin-right: 0;
}

.nav-player-dock {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.nav-player-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text, #fff);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.nav-player-chip:hover {
  background: rgba(255, 45, 45, 0.15);
  border-color: rgba(255, 45, 45, 0.45);
  color: var(--ricky-red, #ff2d2d);
}

.nav-player-chip svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-player-chip.nav-player-play.is-playing {
  background: rgba(255, 45, 45, 0.2);
  border-color: var(--ricky-red, #ff2d2d);
  box-shadow: 0 0 12px rgba(255, 45, 45, 0.25);
}

body.koshermusik-page .nav-player-chip:hover {
  color: var(--ricky-red, #ff2d2d);
}

[data-theme="light"] .nav-player-chip {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.12);
  color: var(--text);
}

[data-theme="light"] .nav-player-chip:hover {
  background: rgba(255, 45, 45, 0.12);
  border-color: rgba(255, 45, 45, 0.35);
}

@media (max-width: 768px) {
  .nav-player-dock {
    gap: 3px;
  }

  .nav-player-chip {
    width: 34px;
    height: 34px;
  }

  .nav-player-chip svg {
    width: 16px;
    height: 16px;
  }
}

/* ===== MINI PLAYER - PERSISTS ACROSS PAGES ===== */
.km-mini-player {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  background: linear-gradient(135deg, #1a1a1a 0%, #0d0d0d 100%);
  border: 1px solid rgba(255, 45, 45, 0.3);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.8), 0 0 20px rgba(255, 45, 45, 0.15);
  cursor: pointer;
  transition: all 0.3s ease;
  max-width: 320px;
  min-width: 280px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  /* Prevent the mini player from being paused by mobile OS */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.km-mini-player:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 50px -10px rgba(0, 0, 0, 0.9), 0 0 30px rgba(255, 45, 45, 0.25);
  border-color: rgba(255, 45, 45, 0.5);
}

.km-mini-player.is-playing {
  border-color: var(--ricky-red);
  box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.8), 0 0 30px rgba(255, 45, 45, 0.3);
}

.km-mini-player-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.km-mini-artwork {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(255, 45, 45, 0.2), rgba(255, 45, 45, 0.05));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.km-mini-artwork-inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: miniPulse 2s ease-in-out infinite;
}

@keyframes miniPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.km-mini-player.is-playing .km-mini-artwork-inner {
  animation: miniSpin 8s linear infinite;
}

@keyframes miniSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.km-mini-artwork svg {
  width: 24px;
  height: 24px;
  color: var(--ricky-red);
}

.km-mini-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.km-mini-label {
  font-family: "Syne", sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ricky-red);
  text-transform: uppercase;
}

.km-mini-track {
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.km-mini-btn,
.km-mini-link,
.km-mini-close {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.km-mini-btn:hover,
.km-mini-link:hover {
  background: rgba(255, 45, 45, 0.2);
  border-color: var(--ricky-red);
  color: var(--ricky-red);
}

.km-mini-close {
  width: 28px;
  height: 28px;
  opacity: 0.6;
}

.km-mini-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

.km-mini-btn svg,
.km-mini-link svg,
.km-mini-close svg {
  width: 18px;
  height: 18px;
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .km-mini-player {
    bottom: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
    min-width: auto;
  }

  .km-mini-player-inner {
    gap: 10px;
  }

  .km-mini-artwork {
    width: 40px;
    height: 40px;
  }

  .km-mini-track {
    font-size: 0.8rem;
  }
}

/* Hide on koshermusik page - full player is there */
body.koshermusik-page .km-mini-player {
  display: none !important;
}

/* Light mode */
[data-theme="light"] .km-mini-player {
  background: linear-gradient(135deg, #fff 0%, #f5f5f5 100%);
  border-color: rgba(255, 45, 45, 0.2);
  box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.2), 0 0 20px rgba(255, 45, 45, 0.1);
}

[data-theme="light"] .km-mini-btn,
[data-theme="light"] .km-mini-link,
[data-theme="light"] .km-mini-close {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
  color: var(--text);
}

[data-theme="light"] .km-mini-btn:hover,
[data-theme="light"] .km-mini-link:hover {
  background: rgba(255, 45, 45, 0.15);
  border-color: var(--ricky-red);
  color: var(--ricky-red);
}

[data-theme="light"] .km-mini-close:hover {
  background: rgba(0, 0, 0, 0.08);
  opacity: 1;
}

[data-theme="light"] .km-mini-track {
  color: var(--text);
}

[data-theme="light"] .km-mini-artwork {
  background: linear-gradient(135deg, rgba(255, 45, 45, 0.15), rgba(255, 45, 45, 0.05));
}

[data-theme="light"] .km-mini-artwork svg {
  color: var(--ricky-red);
}

/* ===== PERSISTENT AUDIO ELEMENT STYLES ===== */
/* The persistent audio element is detached from DOM but functional */
audio#kmPersistentAudio {
  /* Ensure audio can play in background */
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ===== MEDIA SESSION API STYLES ===== */
/* Lock screen / notification styles are handled by the Media Session API */
/* These are fallback styles for browsers that don't support it fully */

/* ===== BACKGROUND PLAYBACK INDICATOR ===== */
.km-background-indicator {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  background: rgba(255, 45, 45, 0.9);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-family: "Syne", sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  display: none;
  animation: slideIn 0.3s ease;
}

.km-background-indicator.visible {
  display: flex;
  align-items: center;
  gap: 8px;
}

.km-background-indicator::before {
  content: '';
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes slideIn {
  from {
    transform: translateX(100px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ===== MOBILE BACKGROUND AUDIO SUPPORT ===== */
/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
  .km-mini-player {
    /* Ensure mini player stays visible during background playback */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }
  
  /* Prevent audio from being paused when app is backgrounded */
  audio {
    -webkit-playsinline: true;
    playsinline: true;
  }
}

/* Android Chrome specific fixes */
@media screen and (max-width: 768px) {
  .km-mini-player {
    /* Ensure player is clickable even when audio is playing in background */
    touch-action: manipulation;
  }
}

/* ===== OFFLINE INDICATOR ===== */
.km-offline-indicator {
  position: fixed;
  bottom: 80px;
  right: 20px;
  z-index: 9998;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.75rem;
  display: none;
  backdrop-filter: blur(10px);
}

.km-offline-indicator.visible {
  display: block;
}

[data-theme="light"] .km-offline-indicator {
  background: rgba(255, 255, 255, 0.9);
  color: #333;
}

/* ===== SYNC STATUS INDICATOR ===== */
.km-sync-status {
  position: fixed;
  bottom: 100px;
  right: 20px;
  z-index: 9997;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.7rem;
  color: var(--ricky-red);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.km-sync-status.visible {
  opacity: 1;
}

/* ===== SERVICE WORKER UPDATE NOTIFICATION ===== */
.km-update-notification {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10001;
  background: linear-gradient(135deg, #1a1a1a 0%, #0d0d0d 100%);
  border: 1px solid rgba(255, 45, 45, 0.3);
  border-radius: 12px;
  padding: 16px 24px;
  box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.8);
  display: none;
  flex-direction: column;
  gap: 12px;
  min-width: 280px;
  max-width: 90vw;
}

.km-update-notification.visible {
  display: flex;
}

.km-update-notification p {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.9rem;
  color: var(--text);
}

.km-update-notification button {
  background: var(--ricky-red);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-family: "Syne", sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.km-update-notification button:hover {
  background: #e62828;
}

[data-theme="light"] .km-update-notification {
  background: linear-gradient(135deg, #fff 0%, #f5f5f5 100%);
  border-color: rgba(255, 45, 45, 0.2);
}
