/* Podcast Floating Mini-Bar Player */

:root {
  --podcast-accent: #6B6B6B;
  --podcast-accent-hover: #4A4A4A;
  --podcast-bar-height: 60px;
  --podcast-easing: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Theme-aware colors */
.podcast-bar,
.podcast-pill,
.podcast-playlist {
  --podcast-bg: #FDFBF7;
  --podcast-bg-secondary: #F0EEEB;
  --podcast-text: #1A1A1A;
  --podcast-text-muted: #6B6B6B;
  --podcast-border: #E0DCD6;
}

.dark .podcast-bar,
.dark .podcast-pill,
.dark .podcast-playlist {
  --podcast-accent: #8A8A8A;
  --podcast-accent-hover: #A0A0A0;
  --podcast-bg: #121212;
  --podcast-bg-secondary: #1A1A1A;
  --podcast-text: #E8E6E3;
  --podcast-text-muted: #8A8A8A;
  --podcast-border: #2A2A2A;
}

/* ============================================
   BODY OFFSET WHEN PLAYER ACTIVE
   ============================================ */

body.podcast-active {
  padding-bottom: var(--podcast-bar-height);
}

body.podcast-subtitle-active {
  padding-bottom: calc(var(--podcast-bar-height) + 34px);
}

/* Bump PaperMod scroll-to-top button up */
body.podcast-active .top-link {
  bottom: calc(60px + var(--podcast-bar-height));
}

/* ============================================
   FIXED BOTTOM BAR
   ============================================ */

.podcast-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--podcast-bg);
  border-top: 1px solid var(--podcast-border);
  z-index: 500;
  display: flex;
  flex-direction: column;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  transition: transform 0.3s var(--podcast-easing);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.podcast-bar-main {
  display: flex;
  align-items: center;
  height: var(--podcast-bar-height);
  padding: 0 16px;
  gap: 12px;
}

/* Subtitle row - full width current cue text below controls */
.podcast-subtitle {
  display: none;
  padding: 0 16px 10px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--podcast-text);
  /* Allow wrapping but cap at 2 lines */
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Only show when bar has active cue */
.podcast-subtitle:empty {
  display: none !important;
}

.podcast-bar.has-subtitle .podcast-subtitle {
  display: -webkit-box;
}

.podcast-bar.hidden {
  transform: translateY(100%);
  pointer-events: none;
}

/* ============================================
   PLAYBACK CONTROLS
   ============================================ */

.podcast-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.podcast-btn {
  background: none;
  border: none;
  color: var(--podcast-text);
  cursor: pointer;
  padding: 6px;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s var(--podcast-easing);
}

.podcast-btn:hover {
  color: var(--podcast-text-muted);
}

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

.podcast-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

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

/* ============================================
   TRACK INFO
   ============================================ */

.podcast-track-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex-shrink: 1;
  max-width: 200px;
}

.podcast-track-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--podcast-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.podcast-track-desc {
  font-size: 11px;
  color: var(--podcast-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

/* ============================================
   SEEKABLE PROGRESS BAR
   ============================================ */

.podcast-progress-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.podcast-time {
  font-size: 11px;
  color: var(--podcast-text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 36px;
  text-align: center;
}

.podcast-progress {
  flex: 1;
  height: 4px;
  background: var(--podcast-border);
  border-radius: 0;
  cursor: pointer;
  position: relative;
  min-width: 60px;
}

.podcast-progress:hover {
  height: 6px;
}

.podcast-progress-fill {
  height: 100%;
  background: var(--podcast-text);
  border-radius: 0;
  width: 0%;
  position: relative;
  transition: none;
}

.podcast-progress:hover .podcast-progress-thumb {
  opacity: 1;
  transform: scale(1) translateY(-50%);
}

.podcast-progress-thumb {
  position: absolute;
  right: -5px;
  top: 50%;
  transform: scale(0) translateY(-50%);
  transform-origin: center;
  width: 10px;
  height: 10px;
  background: var(--podcast-text);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
}

/* ============================================
   VOLUME CONTROL
   ============================================ */

.podcast-volume-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.podcast-volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 70px;
  height: 4px;
  background: var(--podcast-border);
  border-radius: 0;
  outline: none;
  cursor: pointer;
}

.podcast-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: var(--podcast-text);
  border-radius: 50%;
  cursor: pointer;
}

.podcast-volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--podcast-text);
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

/* ============================================
   RIGHT-SIDE ACTIONS (PLAYLIST + MINIMIZE)
   ============================================ */

.podcast-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* ============================================
   PLAYLIST POPUP
   ============================================ */

.podcast-playlist {
  position: fixed;
  bottom: var(--podcast-bar-height);
  left: 0;
  right: 0;
  max-height: 0;
  overflow: hidden;
  background: var(--podcast-bg);
  border-top: 1px solid var(--podcast-border);
  z-index: 499;
  transition: max-height 0.3s var(--podcast-easing);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.podcast-playlist.open {
  max-height: 320px;
  overflow-y: auto;
}

.podcast-playlist-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px 8px;
  position: sticky;
  top: 0;
  background: var(--podcast-bg);
  z-index: 1;
}

.podcast-playlist-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--podcast-text);
}

.podcast-playlist-items {
  padding: 0 8px 8px;
}

.podcast-playlist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 0;
  cursor: pointer;
  transition: background 0.15s var(--podcast-easing);
}

.podcast-playlist-item:hover {
  background: var(--podcast-bg-secondary);
}

.podcast-playlist-item.active {
  background: transparent;
}

.podcast-playlist-item-icon {
  width: 32px;
  height: 32px;
  border-radius: 0;
  background: var(--podcast-bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--podcast-text-muted);
}

.podcast-playlist-item.active .podcast-playlist-item-icon {
  background: var(--podcast-text);
  color: var(--podcast-bg);
}

.podcast-playlist-item-icon svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

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

.podcast-playlist-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--podcast-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.podcast-playlist-item.active .podcast-playlist-item-title {
  font-weight: 700;
  color: var(--podcast-text);
}

.podcast-playlist-item-desc {
  font-size: 11px;
  color: var(--podcast-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.podcast-playlist-item-duration {
  font-size: 11px;
  color: var(--podcast-text-muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* ============================================
   MINIMIZED STATE - PILL
   ============================================ */

.podcast-pill {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  right: 20px;
  z-index: 500;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 8px;
  background: var(--podcast-bg);
  border: 1px solid var(--podcast-border);
  border-radius: 0;
  cursor: pointer;
  transition: border-color 0.2s var(--podcast-easing);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.podcast-pill:hover {
  border-color: var(--podcast-text);
}

.podcast-pill.visible {
  display: flex;
}

.podcast-pill-play {
  width: 32px;
  height: 32px;
  background: var(--podcast-text);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--podcast-bg);
  flex-shrink: 0;
}

.podcast-pill-play svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.podcast-pill-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--podcast-text);
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .podcast-volume-wrap {
    display: none;
  }

  .podcast-track-info {
    max-width: 140px;
  }

  /* Offset pill to avoid MJLM toggle overlap */
  .podcast-pill {
    right: 80px;
  }

  .podcast-transcript.open {
    max-height: 320px;
  }

  .podcast-transcript-cues {
    max-height: 272px;
  }
}

@media (max-width: 480px) {
  .podcast-bar {
    gap: 8px;
    padding: 0 10px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .podcast-btn-prev,
  .podcast-btn-next {
    display: none;
  }

  .podcast-time {
    display: none;
  }

  .podcast-track-info {
    max-width: 100px;
  }

  .podcast-pill {
    right: 80px;
    bottom: 20px;
  }

  .podcast-transcript.open {
    max-height: 60vh;
  }

  .podcast-transcript-cues {
    max-height: calc(60vh - 48px);
  }

  .podcast-transcript-cue {
    padding: 10px 8px;
  }

  .podcast-transcript-text {
    font-size: 14px;
  }
}

/* ============================================
   REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  .podcast-bar,
  .podcast-playlist,
  .podcast-transcript,
  .podcast-pill,
  .podcast-btn,
  .podcast-subtitle,
  .podcast-progress-thumb,
  .podcast-transcript-cue {
    animation: none !important;
    transition: none !important;
  }
}

/* ============================================
   SCROLLBAR FOR PLAYLIST
   ============================================ */

.podcast-playlist::-webkit-scrollbar {
  width: 6px;
}

.podcast-playlist::-webkit-scrollbar-track {
  background: transparent;
}

.podcast-playlist::-webkit-scrollbar-thumb {
  background: var(--podcast-border);
  border-radius: 3px;
}

.podcast-playlist::-webkit-scrollbar-thumb:hover {
  background: var(--podcast-text-muted);
}

/* ============================================
   TRANSCRIPT PANEL
   ============================================ */

.podcast-transcript {
  position: fixed;
  bottom: var(--podcast-bar-height);
  left: 0;
  right: 0;
  max-height: 0;
  overflow: hidden;
  background: var(--podcast-bg);
  border-top: 1px solid var(--podcast-border);
  z-index: 499;
  transition: max-height 0.3s var(--podcast-easing);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.podcast-transcript.open {
  max-height: 400px;
  overflow: hidden;
}

.podcast-transcript-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px 8px;
  position: sticky;
  top: 0;
  background: var(--podcast-bg);
  z-index: 1;
}

.podcast-transcript-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--podcast-text);
}

.podcast-transcript-cues {
  padding: 0 16px 12px;
  overflow-y: auto;
  max-height: 352px;
}

.podcast-transcript-cue {
  display: flex;
  gap: 10px;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s var(--podcast-easing);
  align-items: baseline;
}

.podcast-transcript-cue:hover {
  background: var(--podcast-bg-secondary);
}

.podcast-transcript-cue.active {
  background: var(--podcast-bg-secondary);
}

.podcast-transcript-cue.active .podcast-transcript-text {
  color: var(--podcast-text);
  font-weight: 500;
}

.podcast-transcript-time {
  font-size: 11px;
  color: var(--podcast-text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 32px;
  opacity: 0.6;
}

.podcast-transcript-cue.active .podcast-transcript-time {
  opacity: 1;
}

.podcast-transcript-text {
  font-size: 13px;
  color: var(--podcast-text-muted);
  line-height: 1.5;
}

.podcast-transcript-empty {
  font-size: 13px;
  color: var(--podcast-text-muted);
  text-align: center;
  padding: 20px 0;
}

/* Transcript button active state */
.podcast-btn-transcript.active {
  color: var(--podcast-accent-hover);
}

/* Theme-aware transcript */
.podcast-transcript {
  --podcast-bg: #FDFBF7;
  --podcast-bg-secondary: #F0EEEB;
  --podcast-text: #1A1A1A;
  --podcast-text-muted: #6B6B6B;
  --podcast-border: #E0DCD6;
}

.dark .podcast-transcript {
  --podcast-accent: #8A8A8A;
  --podcast-accent-hover: #A0A0A0;
  --podcast-bg: #121212;
  --podcast-bg-secondary: #1A1A1A;
  --podcast-text: #E8E6E3;
  --podcast-text-muted: #8A8A8A;
  --podcast-border: #2A2A2A;
}

/* ============================================
   TRANSCRIPT SCROLLBAR
   ============================================ */

.podcast-transcript-cues::-webkit-scrollbar {
  width: 6px;
}

.podcast-transcript-cues::-webkit-scrollbar-track {
  background: transparent;
}

.podcast-transcript-cues::-webkit-scrollbar-thumb {
  background: var(--podcast-border);
  border-radius: 3px;
}

.podcast-transcript-cues::-webkit-scrollbar-thumb:hover {
  background: var(--podcast-text-muted);
}
