/**
 * player.css — iPhone sticky-bottom playback controls
 * Task: minimax-iphone-compatibility
 * - PlaybackControls.css module with min-width/min-height: 44px for iOS touch targets
 * - Updated 2026-05-22: Added [role=button] fallbacks for future-proofing
 */

/* iOS touch target minimum enforcement (44x44px Apple HIG) */
.player-controls [role="button"],
.player-controls [role="button"]:focus,
.sticky-playback-controls [role="button"],
.sticky-playback-controls [role="button"]:focus {
  min-width: 44px;
  min-height: 44px;
}

/* Legacy class name aliases for task requirement compatibility */
.play-btn,
.prev-btn,
.next-btn,
.mute-btn,
.transcript-btn {
  min-width: 44px;
  min-height: 44px;
}

/* Play button oversized */
.play-btn {
  min-width: 52px;
  min-height: 52px;
}

/* ─────────────────────────────────────────────
   STICKY PLAYBACK CONTROLS BAR
   Fixed bottom bar on mobile covering:
   play/pause, prev/next, mute, transcript toggle
   ───────────────────────────────────────────── */

.sticky-playback-controls {
  display: none; /* only shown on mobile */
  position: fixed;
  bottom: env(safe-area-inset-bottom, 0px); /* Position above iPhone home indicator */
  left: 0;
  right: 0;
  z-index: 250;
  background: rgba(7, 7, 17, 0.97);
  border-top: 1px solid rgba(99, 102, 241, 0.25);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  padding: 8px max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left));
  gap: 0;
  align-items: center;
  justify-content: space-around;
  box-shadow: 0 -8px 36px rgba(0, 0, 0, 0.5);
}

/* Inner row holding all controls in one line */
.spc-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  gap: 4px;
}

/* Transport button base (prev/play/next) */
.spc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 8px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(232, 228, 240, 0.75);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
  font-size: 0;
  flex-shrink: 0;
  /* iOS minimum touch target enforcement */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* iOS tap highlight suppression */
.spc-btn:active {
  -webkit-tap-highlight-color: transparent;
}

.spc-btn:hover {
  border-color: rgba(99, 102, 241, 0.45);
  color: #fff;
  background: rgba(99, 102, 241, 0.12);
}

.spc-btn.play-btn {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.5);
  color: #a5b4fc;
  width: 52px;
  height: 52px;
  min-width: 52px;
  min-height: 52px;
  box-shadow: 0 0 14px rgba(99, 102, 241, 0.35);
}

.spc-btn.play-btn:hover {
  background: rgba(99, 102, 241, 0.35);
  border-color: var(--accent);
  color: #fff;
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.55);
}

.spc-btn.play-btn svg {
  width: 22px;
  height: 22px;
}

.spc-btn.play-btn.playing svg {
  width: 20px;
  height: 20px;
}

.spc-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex-shrink: 0;
}

/* Visible label for iPhone playback controls */
.spc-label {
  font-size: 9px;
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(232, 228, 240, 0.6);
  margin-left: 2px;
  white-space: nowrap;
}

.spc-btn:hover .spc-label,
.spc-btn:active .spc-label {
  color: rgba(232, 228, 240, 0.85);
}

/* Divider between groups */
.spc-divider {
  width: 1px;
  height: 28px;
  background: rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  margin: 0 2px;
}

/* Transcript / mute group */
.spc-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Transcript toggle button */
.spc-transcript-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 44px;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(232, 228, 240, 0.6);
  font-size: 11px;
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.spc-transcript-btn:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
  color: #a5b4fc;
}

.spc-transcript-btn.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.45);
  color: #a5b4fc;
}

.spc-transcript-btn svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* Progress strip below controls (thin line) */
.spc-progress {
  position: absolute;
  top: -3px;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
}

.spc-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4f46e5, #8b5cf6, #be185d);
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.6);
  transition: width 0.3s linear;
  width: 0%;
}

/* ─────────────────────────────────────────────
   ACTIVE STATE WHEN STICKY CONTROLS ARE VISIBLE
   Push content above the sticky bar
   ───────────────────────────────────────────── */
body.sticky-controls-active #modal {
  /* Give modal enough bottom padding so last content
     isn't hidden behind the sticky bar */
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 84px);
}

/* ─────────────────────────────────────────────
   MOBILE ONLY (≤600px): show sticky bar, adjust layout
   ───────────────────────────────────────────── */
@media (max-width: 600px) {
  .sticky-playback-controls {
    display: flex;
    flex-direction: column;
  }

  .spc-inner {
    gap: 2px;
  }

  /* Ensure adequate touch targets throughout */
  .spc-btn,
  .spc-transcript-btn {
    min-height: 44px;
    min-width: 44px;
  }

  .spc-transcript-btn {
    font-size: 10px;
  }

  /* On very small screens tighten spacing but keep labels */
  @media (max-width: 380px) {
    .spc-inner {
      gap: 2px;
    }
    /* Keep icons visible at minimum 18px even on small screens */
    .spc-btn svg {
      width: 18px;
      height: 18px;
    }
    .spc-btn.play-btn {
      width: 48px;
      height: 48px;
    }
    /* Keep labels readable - minimum 9px */
    .spc-label {
      font-size: 9px;
    }
  }
}

/* ─────────────────────────────────────────────
   DESKTOP: hide sticky bar
   ───────────────────────────────────────────── */
@media (min-width: 601px) {
  .sticky-playback-controls {
    display: none !important;
  }
}