/* ============================================================
   MAVEL'S CORNER — AUDIO PLAYER
   Floating read-aloud player for blog posts
   Placement: src/assets/css/audio-player.css
   v3.0 — Draggable progress, gender toggle, volume, keyboard, resume prompt
   ============================================================ */

:root {
  --ap-navy:       #0D2B30;
  --ap-teal:       #1B9AAA;
  --ap-teal-glow:  rgba(27,154,170,0.22);
  --ap-teal-light: #22c5d8;
  --ap-gold:       #C8973A;
  --ap-gold-dim:   rgba(200,151,58,0.18);
  --ap-white:      #FFFFFF;
  --ap-mist:       rgba(255,255,255,0.06);
  --ap-border:     rgba(27,154,170,0.20);
  --ap-shadow:     0 8px 40px rgba(0,0,0,0.45), 0 2px 8px rgba(0,0,0,0.28);
  --ap-radius:     18px;
  --ap-font-body:  'Lato', sans-serif;
}

/* ── TRIGGER BUTTON (bottom-right FAB) ── */
#mc-audio-trigger {
  position: fixed;
  bottom: 28px;
  right: 24px;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 20px 12px 14px;
  background: var(--ap-navy);
  border: 1.5px solid var(--ap-teal);
  border-radius: 50px;
  cursor: pointer;
  box-shadow: var(--ap-shadow), 0 0 0 0 var(--ap-teal-glow);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
  font-family: var(--ap-font-body);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

#mc-audio-trigger:hover {
  transform: translateY(-2px);
  border-color: var(--ap-teal-light);
  box-shadow: var(--ap-shadow), 0 0 18px var(--ap-teal-glow);
}

#mc-audio-trigger .ap-fab-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ap-teal) 0%, #0f7080 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

#mc-audio-trigger:hover .ap-fab-icon { transform: scale(1.08); }

#mc-audio-trigger .ap-fab-icon svg {
  width: 15px;
  height: 15px;
  fill: #fff;
}

#mc-audio-trigger .ap-fab-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ap-teal-light);
  white-space: nowrap;
}

#mc-audio-trigger.ap-playing {
  animation: ap-fab-pulse 2.4s ease-in-out infinite;
}

@keyframes ap-fab-pulse {
  0%, 100% { box-shadow: var(--ap-shadow), 0 0 0 0 var(--ap-teal-glow); }
  50%       { box-shadow: var(--ap-shadow), 0 0 0 10px rgba(27,154,170,0); }
}

/* ── PLAYER PANEL ── */
#mc-audio-player {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 9100;
  width: min(520px, calc(100vw - 32px));
  background: linear-gradient(160deg, #0f2f35 0%, #091f23 100%);
  border: 1.5px solid var(--ap-border);
  border-radius: var(--ap-radius);
  box-shadow: var(--ap-shadow), inset 0 1px 0 rgba(255,255,255,0.05);
  padding: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34,1.3,0.64,1);
  font-family: var(--ap-font-body);
}

#mc-audio-player.ap-open {
  opacity: 1;
  pointer-events: all;
  transform: translateX(-50%) translateY(0);
}

#mc-audio-player::before {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg, transparent 0%, var(--ap-teal) 30%, var(--ap-teal-light) 60%, var(--ap-gold) 100%);
}

/* ── RESUME PROMPT BANNER ── */
.ap-resume-prompt {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 16px;
  background: var(--ap-gold-dim);
  border-bottom: 1px solid rgba(200,151,58,0.2);
}

.ap-resume-prompt.ap-visible {
  display: flex;
}

.ap-resume-text {
  font-size: 11.5px;
  color: var(--ap-gold);
  font-style: italic;
  flex: 1;
}

.ap-resume-btns {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.ap-resume-btn {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: var(--ap-font-body);
  transition: background 0.18s, color 0.18s;
  outline: none;
}

.ap-resume-btn.ap-resume-yes {
  background: var(--ap-gold);
  color: var(--ap-navy);
  border-color: var(--ap-gold);
}

.ap-resume-btn.ap-resume-yes:hover {
  background: #e0a93f;
}

.ap-resume-btn.ap-resume-no {
  background: transparent;
  color: rgba(255,255,255,0.5);
  border-color: rgba(255,255,255,0.15);
}

.ap-resume-btn.ap-resume-no:hover {
  color: #fff;
  border-color: rgba(255,255,255,0.35);
}

/* ── HEADER ── */
.ap-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--ap-mist);
}

.ap-icon-wrap {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--ap-teal) 0%, #0b6070 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.ap-icon-wrap svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

.ap-meta { flex: 1; min-width: 0; }

.ap-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ap-teal);
  margin-bottom: 3px;
}

.ap-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ap-white);
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-bottom: 2px;
}

.ap-author {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  font-style: italic;
}

.ap-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ap-mist);
  border: 1px solid rgba(255,255,255,0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.18s, transform 0.18s;
  outline: none;
  margin-top: -2px;
}

.ap-close:hover {
  background: rgba(255,255,255,0.12);
  transform: scale(1.1);
}

.ap-close svg {
  width: 11px;
  height: 11px;
  stroke: rgba(255,255,255,0.6);
  stroke-width: 2;
  fill: none;
}

/* ── WAVEFORM ── */
.ap-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 36px;
  padding: 0 18px;
  overflow: hidden;
}

.ap-wave-bar {
  width: 3px;
  border-radius: 2px;
  background: var(--ap-teal);
  opacity: 0.35;
  transition: opacity 0.2s;
}

.ap-wave.ap-wave-active .ap-wave-bar { opacity: 1; }

.ap-wave-bar:nth-child(1)  { height: 6px; }
.ap-wave-bar:nth-child(2)  { height: 10px; }
.ap-wave-bar:nth-child(3)  { height: 18px; }
.ap-wave-bar:nth-child(4)  { height: 24px; }
.ap-wave-bar:nth-child(5)  { height: 28px; }
.ap-wave-bar:nth-child(6)  { height: 24px; }
.ap-wave-bar:nth-child(7)  { height: 32px; }
.ap-wave-bar:nth-child(8)  { height: 20px; }
.ap-wave-bar:nth-child(9)  { height: 14px; }
.ap-wave-bar:nth-child(10) { height: 22px; }
.ap-wave-bar:nth-child(11) { height: 30px; }
.ap-wave-bar:nth-child(12) { height: 16px; }
.ap-wave-bar:nth-child(13) { height: 26px; }
.ap-wave-bar:nth-child(14) { height: 20px; }
.ap-wave-bar:nth-child(15) { height: 12px; }
.ap-wave-bar:nth-child(16) { height: 8px; }

.ap-wave.ap-wave-active .ap-wave-bar:nth-child(1)  { animation: ap-wave 1.1s  0.00s ease-in-out infinite alternate; }
.ap-wave.ap-wave-active .ap-wave-bar:nth-child(2)  { animation: ap-wave 0.9s  0.08s ease-in-out infinite alternate; }
.ap-wave.ap-wave-active .ap-wave-bar:nth-child(3)  { animation: ap-wave 1.3s  0.16s ease-in-out infinite alternate; }
.ap-wave.ap-wave-active .ap-wave-bar:nth-child(4)  { animation: ap-wave 0.8s  0.24s ease-in-out infinite alternate; }
.ap-wave.ap-wave-active .ap-wave-bar:nth-child(5)  { animation: ap-wave 1.2s  0.10s ease-in-out infinite alternate; }
.ap-wave.ap-wave-active .ap-wave-bar:nth-child(6)  { animation: ap-wave 1.0s  0.32s ease-in-out infinite alternate; }
.ap-wave.ap-wave-active .ap-wave-bar:nth-child(7)  { animation: ap-wave 0.7s  0.18s ease-in-out infinite alternate; }
.ap-wave.ap-wave-active .ap-wave-bar:nth-child(8)  { animation: ap-wave 1.4s  0.04s ease-in-out infinite alternate; }
.ap-wave.ap-wave-active .ap-wave-bar:nth-child(9)  { animation: ap-wave 0.95s 0.28s ease-in-out infinite alternate; }
.ap-wave.ap-wave-active .ap-wave-bar:nth-child(10) { animation: ap-wave 1.1s  0.36s ease-in-out infinite alternate; }
.ap-wave.ap-wave-active .ap-wave-bar:nth-child(11) { animation: ap-wave 0.85s 0.12s ease-in-out infinite alternate; }
.ap-wave.ap-wave-active .ap-wave-bar:nth-child(12) { animation: ap-wave 1.25s 0.20s ease-in-out infinite alternate; }
.ap-wave.ap-wave-active .ap-wave-bar:nth-child(13) { animation: ap-wave 0.75s 0.40s ease-in-out infinite alternate; }
.ap-wave.ap-wave-active .ap-wave-bar:nth-child(14) { animation: ap-wave 1.15s 0.06s ease-in-out infinite alternate; }
.ap-wave.ap-wave-active .ap-wave-bar:nth-child(15) { animation: ap-wave 0.9s  0.30s ease-in-out infinite alternate; }
.ap-wave.ap-wave-active .ap-wave-bar:nth-child(16) { animation: ap-wave 1.05s 0.44s ease-in-out infinite alternate; }

@keyframes ap-wave {
  from { transform: scaleY(0.3); opacity: 0.6; }
  to   { transform: scaleY(1.0); opacity: 1.0; }
}

/* ── PROGRESS / SCRUBBER ── */
.ap-progress-wrap {
  padding: 0 18px 4px;
}

.ap-progress-track {
  position: relative;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 99px;
  cursor: pointer;
  /* overflow visible so thumb can extend above track */
}

.ap-progress-track:hover .ap-progress-thumb,
.ap-progress-track.ap-dragging .ap-progress-thumb {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.ap-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ap-teal) 0%, var(--ap-teal-light) 100%);
  border-radius: 99px;
  width: 0%;
  /* no transition during drag — instant feel */
  pointer-events: none;
}

.ap-progress-fill.ap-smooth {
  transition: width 0.4s linear;
}

/* draggable thumb */
.ap-progress-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ap-white);
  border: 2px solid var(--ap-teal);
  box-shadow: 0 0 6px var(--ap-teal-glow);
  transform: translateX(-50%) scale(0.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  /* positioned by JS */
}

.ap-time-row {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 10px;
  color: rgba(255,255,255,0.32);
  letter-spacing: 0.04em;
}

/* ── CONTROLS ── */
.ap-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 18px 14px;
}

.ap-btn-play {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ap-teal) 0%, #0b6575 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px var(--ap-teal-glow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  outline: none;
  flex-shrink: 0;
}

.ap-btn-play:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(27,154,170,0.4);
}

.ap-btn-play:active { transform: scale(0.96); }

.ap-btn-play svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

.ap-btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ap-mist);
  border: 1px solid rgba(255,255,255,0.07);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s, transform 0.18s;
  outline: none;
  flex-shrink: 0;
}

.ap-btn-icon:hover {
  background: rgba(255,255,255,0.10);
  transform: scale(1.08);
}

.ap-btn-icon svg {
  width: 14px;
  height: 14px;
  fill: rgba(255,255,255,0.55);
}

.ap-speed-btn {
  background: var(--ap-mist);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 30px;
  padding: 5px 11px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.55);
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
  outline: none;
  font-family: var(--ap-font-body);
}

.ap-speed-btn:hover,
.ap-speed-btn.ap-active {
  background: var(--ap-gold-dim);
  color: var(--ap-gold);
  border-color: rgba(200,151,58,0.3);
}

/* ── VOICE ROW (gender toggle + dropdown) ── */
.ap-voice-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px 10px;
  border-top: 1px solid var(--ap-mist);
}

.ap-voice-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
  flex-shrink: 0;
}

/* gender toggle group */
.ap-gender-toggle {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.ap-gender-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.10);
  background: var(--ap-mist);
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  font-family: var(--ap-font-body);
  transition: background 0.18s, color 0.18s, border-color 0.18s;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.ap-gender-btn svg {
  width: 10px;
  height: 10px;
  fill: currentColor;
  flex-shrink: 0;
}

.ap-gender-btn:hover {
  color: rgba(255,255,255,0.75);
  border-color: rgba(255,255,255,0.22);
}

.ap-gender-btn.ap-active[data-gender="female"] {
  background: rgba(27,154,170,0.18);
  color: var(--ap-teal-light);
  border-color: rgba(27,154,170,0.4);
}

.ap-gender-btn.ap-active[data-gender="male"] {
  background: rgba(200,151,58,0.16);
  color: var(--ap-gold);
  border-color: rgba(200,151,58,0.35);
}

/* voice dropdown (secondary) */
.ap-voice-select {
  background: var(--ap-mist);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 10.5px;
  color: rgba(255,255,255,0.45);
  font-family: var(--ap-font-body);
  cursor: pointer;
  outline: none;
  flex: 1;
  min-width: 0;
  max-width: 160px;
  transition: border-color 0.18s, color 0.18s;
}

.ap-voice-select:hover {
  border-color: var(--ap-teal);
  color: rgba(255,255,255,0.7);
}

.ap-voice-select option {
  background: #0f2f35;
  color: #fff;
}

/* ── VOLUME ROW ── */
.ap-volume-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px 12px;
}

.ap-volume-icon {
  width: 16px;
  height: 16px;
  fill: rgba(255,255,255,0.3);
  flex-shrink: 0;
}

.ap-volume-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  border-radius: 99px;
  background: rgba(255,255,255,0.10);
  outline: none;
  cursor: pointer;
  /* filled portion drawn via JS inline gradient */
}

.ap-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--ap-white);
  border: 2px solid var(--ap-teal);
  box-shadow: 0 0 4px var(--ap-teal-glow);
  cursor: pointer;
  transition: transform 0.15s;
}

.ap-volume-slider::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--ap-white);
  border: 2px solid var(--ap-teal);
  box-shadow: 0 0 4px var(--ap-teal-glow);
  cursor: pointer;
  transition: transform 0.15s;
}

.ap-volume-slider:hover::-webkit-slider-thumb { transform: scale(1.2); }
.ap-volume-slider:hover::-moz-range-thumb     { transform: scale(1.2); }

.ap-volume-pct {
  font-size: 10px;
  color: rgba(255,255,255,0.3);
  width: 28px;
  text-align: right;
  flex-shrink: 0;
}

/* ── STATUS FOOTER ── */
.ap-footer {
  display: flex;
  align-items: center;
  padding: 8px 18px 14px;
  border-top: 1px solid var(--ap-mist);
}

.ap-status {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  font-style: italic;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ap-status.ap-status-active { color: var(--ap-teal); }

/* keyboard shortcut hint */
.ap-kb-hint {
  font-size: 10px;
  color: rgba(255,255,255,0.18);
  letter-spacing: 0.04em;
  flex-shrink: 0;
  display: none;
}

@media (hover: hover) {
  .ap-kb-hint { display: block; }
}

/* ── BROWSER UNSUPPORTED ── */
.ap-unsupported {
  padding: 14px 18px;
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  text-align: center;
  line-height: 1.5;
}

/* ── RESPONSIVE ── */
@media (max-width: 560px) {
  #mc-audio-player {
    bottom: 0;
    left: 0;
    right: 0;
    transform: translateY(20px);
    width: 100%;
    border-radius: var(--ap-radius) var(--ap-radius) 0 0;
  }

  #mc-audio-player.ap-open { transform: translateY(0); }

  #mc-audio-trigger {
    bottom: 20px;
    right: 16px;
  }

  .ap-voice-select { max-width: 120px; }
}

@media (max-width: 360px) {
  .ap-controls  { gap: 7px; }
  .ap-btn-play  { width: 42px; height: 42px; }
  .ap-btn-icon  { width: 32px; height: 32px; }
  .ap-gender-btn { padding: 4px 8px; font-size: 10px; }
}

/* ── LOADING SPINNER ── */
@keyframes ap-spin {
  to { transform: rotate(360deg); }
}
.ap-spin {
  animation: ap-spin 0.9s linear infinite;
  transform-origin: center;
}

/* ── DOWNLOAD BUTTON ── */
.ap-btn-download {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ap-mist);
  border: 1px solid rgba(255,255,255,0.07);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s, transform 0.18s;
  outline: none;
  flex-shrink: 0;
}

.ap-btn-download:hover {
  background: rgba(255,255,255,0.10);
  transform: scale(1.08);
}

.ap-btn-download svg {
  width: 14px;
  height: 14px;
  fill: rgba(255,255,255,0.55);
}
