/**
 * Sticky Playback Controls - Persistent bottom bar for iOS/mobile
 * iOS touch target specification: minimum 44x44px
 */

/* Base sticky controls container - fixed to bottom */
.sticky-playback-controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 350;
  background: linear-gradient(180deg, rgba(15, 15, 26, 0.98) 0%, rgba(8, 12, 20, 0.98) 100%);
  border-top: 1px solid rgba(99, 102, 241, 0.25);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45), 0 -4px 12px rgba(99, 102, 241, 0.1);
  padding: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
  font-family: 'Inter', system-ui, sans-serif;
  display: none; /* Hidden by default, shown on mobile */
}

/* Sticky controls active state */
body.sticky-controls-active .sticky-playback-controls {
  display: block;
}

/* Progress bar */
.spc-progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;         /* Taller for easier touch scrubbing */
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: height 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.spc-progress:hover {
  height: 10px;
}

/* Expand touch area above progress bar for easier scrubbing */
.spc-progress::before {
  content: '';
  position: absolute;
  top: -12px;
  left: 0;
  right: 0;
  height: 12px;
}

.spc-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  border-radius: 0 2px 2px 0;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
  pointer-events: none;
}

/* Inner container with flex layout */
.spc-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  min-height: 64px;
}

/* Transport controls - Previous, Play/Pause, Next */
.spc-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 44px;
  min-height: 44px;
  padding: 6px 10px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: rgba(232, 228, 240, 0.7);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-tap-highlight-color: transparent;
}

.spc-btn:hover {
  background: rgba(99, 102, 241, 0.15);
  color: rgba(232, 228, 240, 0.95);
}

.spc-btn:active {
  background: rgba(99, 102, 241, 0.25);
  transform: scale(0.95);
}

/* SVG sizing in buttons */
.spc-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* Label styling for buttons */
.spc-label {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.75;
}

/* Primary play button */
.spc-btn.play-btn {
  min-width: 52px;
  min-height: 52px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  border-radius: 50%;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.spc-btn.play-btn:hover {
  background: linear-gradient(135deg, #7c7ff2, #5f52f0);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.spc-btn.play-btn:active {
  transform: scale(0.92);
}

.spc-btn.play-btn.playing {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

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

/* Divider */
.spc-divider {
  width: 1px;
  height: 36px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0 4px;
}

/* Group container for secondary controls */
.spc-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Transcript button */
.spc-transcript-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 44px;
  min-height: 44px;
  padding: 6px 12px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(232, 228, 240, 0.65);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-tap-highlight-color: transparent;
}

.spc-transcript-btn:hover {
  background: rgba(99, 102, 241, 0.2);
  color: rgba(232, 228, 240, 0.95);
}

.spc-transcript-btn.active {
  background: rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.5);
}

.spc-transcript-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* Transcript label */
#spcTranscriptLabel {
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Focus states for accessibility */
.sticky-playback-controls .spc-btn:focus-visible,
.sticky-playback-controls .spc-transcript-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.6), 0 0 16px rgba(99, 102, 241, 0.4);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .sticky-playback-controls *,
  .spc-btn,
  .spc-progress-fill {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Mobile breakpoint - show on smaller screens */
@media (max-width: 600px) {
  .sticky-playback-controls {
    display: block;
  }

  .spc-inner {
    padding: 12px 14px;
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
    gap: 6px;
  }

  .spc-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 8px;
  }

  .spc-btn.play-btn {
    min-width: 50px;
    min-height: 50px;
  }

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

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

  /* Adjust spacing for very small screens */
  @media (max-width: 380px) {
    .spc-inner {
      gap: 4px;
      padding: 10px 10px;
    }

    .spc-divider {
      display: none;
    }

    .spc-group {
      gap: 2px;
    }

    .spc-label {
      display: none;
    }

    #spcTranscriptLabel {
      display: none;
    }
  }
}

/* Desktop - hide by default, can be forced with body class */
@media (min-width: 601px) {
  .sticky-playback-controls {
    display: none !important;
  }

  body.sticky-controls-active .sticky-playback-controls {
    display: block !important;
  }
}

/* Ensure button icon colors update properly */
.spc-btn#spcMute.muted svg {
  opacity: 0.5;
}

/* Speed button in sticky bar */
#spcSpeedBtn {
  color: rgba(232, 228, 240, 0.55);
}
#spcSpeedBtn:hover {
  color: rgba(232, 228, 240, 0.85);
}
#spcSpeedBtn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
}

/* Time display in sticky bar */
.spc-time-display {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: rgba(232, 228, 240, 0.6);
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 500;
  white-space: nowrap;
  min-width: 32px;
  text-align: center;
  letter-spacing: 0.02em;
}