/* ================================================================
   ITOLDU SPEAKEASY — AUDIO PLAYER
   Palette: purple · pink · amber · deep violet
   ================================================================ */

:root {
  --sk-pink:   #ec4899;
  --sk-rose:   #db2777;
  --sk-deep:   #be185d;
  --sk-purple: #7c3aed;
  --sk-smoke:  #5b21b6;
  --sk-gold:   #f59e0b;
  --sk-warm:   #fdf4ff;
  --sk-forest: #059669;
}

/* ── Outer Container ──────────────────────────────────────────── */
.speakeasy-media-player {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 10px 14px 10px 50px;
  font-family: inherit;

  background: linear-gradient(145deg, #fdf4ff 0%, #faf5ff 55%, #fefce8 100%);

  border-radius: 60px;
  border: 2px solid transparent;
  background-clip: padding-box;

  box-shadow:
    0 0 0 2px rgba(124, 58, 237, 0.28),
    0 6px 28px rgba(124, 58, 237, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);

  overflow: hidden;
  transition: box-shadow 0.4s ease, transform 0.3s ease;
}

.speakeasy-media-player:hover,
.speakeasy-media-player:focus-within {
  box-shadow:
    0 0 0 2.5px var(--sk-rose),
    0 10px 32px rgba(124, 58, 237, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transform: translateY(-1px);
}

/* ── Sound wave glyph (left) ──────────────────────────────────── */
.speakeasy-media-player::before {
  content: '🔊';
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.25rem;
  pointer-events: none;
  animation: speakPulse 3s ease-in-out infinite;
  line-height: 1;
  z-index: 1;
}

@keyframes speakPulse {
  0%, 100% { transform: translateY(-50%) scale(1);    opacity: 0.85; }
  50%       { transform: translateY(-50%) scale(1.15); opacity: 1;    }
}

/* ── Shimmer sweep on hover ───────────────────────────────────── */
.speakeasy-media-player::after {
  content: '';
  position: absolute;
  top: -60%;
  left: -130%;
  width: 55%;
  height: 220%;
  background: linear-gradient(
    120deg,
    transparent,
    rgba(255, 255, 255, 0.55),
    transparent
  );
  transition: left 1.1s ease;
  pointer-events: none;
  z-index: 0;
}

.speakeasy-media-player:hover::after {
  left: 170%;
}

/* ── All in-player buttons — base ─────────────────────────────── */
.speakeasy-media-player .speakeasy-button {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 0;
}

/* ▶ Play — purple-to-pink glow orb ───────────────────────────── */
#speakeasy-play-button {
  width: 44px !important;
  height: 44px !important;
  background: linear-gradient(
    135deg,
    var(--sk-purple),
    var(--sk-pink),
    var(--sk-deep)
  ) !important;
  box-shadow:
    0 4px 16px rgba(124, 58, 237, 0.52),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

#speakeasy-play-button:hover:not([disabled]) {
  transform: scale(1.16) translateY(-1px);
  box-shadow:
    0 8px 26px rgba(124, 58, 237, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* Radiant pulse ring while actively speaking */
.speakeasy-media-player:has(#speakeasy-play-button[aria-pressed="true"])
  #speakeasy-play-button {
  animation: orbRadiance 2.2s ease-in-out infinite;
}

@keyframes orbRadiance {
  0%   { box-shadow: 0 4px 16px rgba(124,58,237,0.52), 0 0 0 0   rgba(236,72,153,0.6); }
  60%  { box-shadow: 0 4px 16px rgba(124,58,237,0.52), 0 0 0 14px rgba(236,72,153,0);  }
  100% { box-shadow: 0 4px 16px rgba(124,58,237,0.52), 0 0 0 0   rgba(236,72,153,0);  }
}

/* ⏸ Pause — amber orb ────────────────────────────────────────── */
#speakeasy-pause-button:not([disabled]) {
  background: linear-gradient(135deg, #fbbf24, #d97706) !important;
  box-shadow: 0 4px 16px rgba(217, 119, 6, 0.52);
}

#speakeasy-pause-button:not([disabled]):hover {
  transform: scale(1.14) translateY(-1px);
  box-shadow: 0 8px 22px rgba(217, 119, 6, 0.68);
}

/* ⏹ Stop — deep violet orb ───────────────────────────────────── */
#speakeasy-stop-button:not([disabled]) {
  background: linear-gradient(135deg, var(--sk-smoke), #3b0764) !important;
  box-shadow: 0 4px 16px rgba(91, 33, 182, 0.48);
}

#speakeasy-stop-button:not([disabled]):hover {
  transform: scale(1.14) translateY(-1px);
  box-shadow: 0 8px 22px rgba(91, 33, 182, 0.65);
}

/* ⚙ Settings — ghost pill ────────────────────────────────────── */
#speakeasy-settings-toggle {
  border-radius: 16px !important;
  width: auto !important;
  min-width: 38px;
  padding: 0 10px !important;
  background: rgba(124, 58, 237, 0.07) !important;
  border: 1.5px solid rgba(124, 58, 237, 0.22) !important;
}

#speakeasy-settings-toggle:hover {
  background: rgba(124, 58, 237, 0.15) !important;
  border-color: var(--sk-pink) !important;
}

/* ── SVG icon fills ───────────────────────────────────────────── */
#speakeasy-play-button svg,
#speakeasy-pause-button:not([disabled]) svg,
#speakeasy-stop-button:not([disabled]) svg {
  fill: #ffffff;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.22));
  width: 18px !important;
  height: 18px !important;
}

#speakeasy-pause-button[disabled] svg,
#speakeasy-stop-button[disabled] svg {
  fill: rgba(124, 58, 237, 0.28);
}

#speakeasy-settings-toggle svg {
  fill: var(--sk-smoke);
  width: 20px !important;
  height: 20px !important;
  transition: fill 0.25s ease, transform 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#speakeasy-settings-toggle:hover svg {
  fill: var(--sk-pink);
  transform: rotate(65deg) scale(1.1);
}

/* ── Disabled state ───────────────────────────────────────────── */
.speakeasy-media-player .speakeasy-button[disabled] {
  opacity: 0.32;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
  background: transparent !important;
}

/* ── Focus ring ──────────────────────────────────────────────── */
.speakeasy-media-player .speakeasy-button:focus-visible {
  outline: 3px solid var(--sk-pink);
  outline-offset: 3px;
  border-radius: 50%;
}

#speakeasy-settings-toggle:focus-visible {
  border-radius: 16px;
}

/* ── "Listen to this page" label ─────────────────────────────── */
.speakeasy-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--sk-smoke);
  letter-spacing: 0.4px;
  white-space: nowrap;
  opacity: 0.72;
  flex-shrink: 0;
  transition: opacity 0.4s ease;
  user-select: none;
  z-index: 1;
}

.speakeasy-media-player:has(#speakeasy-play-button[aria-pressed="true"]) .speakeasy-label,
.speakeasy-media-player:has(#speakeasy-pause-button[aria-pressed="true"]) .speakeasy-label {
  opacity: 0.28;
}

/* ── Animated EQ bars ─────────────────────────────────────────── */
.speakeasy-eq {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 22px;
  flex-shrink: 0;
  z-index: 1;
}

.speakeasy-eq-bar {
  width: 3px;
  border-radius: 3px 3px 1px 1px;
  background: linear-gradient(to top, var(--sk-pink) 0%, var(--sk-gold) 100%);
  transform-origin: bottom center;
  animation: eqDance 0.95s ease-in-out infinite;
  animation-play-state: paused;
  opacity: 0.38;
  transition: opacity 0.4s ease;
}

.speakeasy-media-player:has(#speakeasy-play-button[aria-pressed="true"]) .speakeasy-eq-bar {
  animation-play-state: running;
  opacity: 1;
}

.speakeasy-eq-bar:nth-child(1) { height: 7px;  animation-delay: 0s;     }
.speakeasy-eq-bar:nth-child(2) { height: 15px; animation-delay: 0.17s;  }
.speakeasy-eq-bar:nth-child(3) { height: 10px; animation-delay: 0.34s;  }
.speakeasy-eq-bar:nth-child(4) { height: 19px; animation-delay: 0.085s; }
.speakeasy-eq-bar:nth-child(5) { height: 12px; animation-delay: 0.255s; }
.speakeasy-eq-bar:nth-child(6) { height: 8px;  animation-delay: 0.425s; }

@keyframes eqDance {
  0%,  100% { transform: scaleY(0.3); }
  50%        { transform: scaleY(1);   }
}

/* ── Progress slider ─────────────────────────────────────────── */
.speakeasy-progress {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 50px;
  height: 5px;
  border-radius: 10px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(124, 58, 237, 0.16);
  accent-color: var(--sk-pink);
  transition: height 0.2s ease;
  outline: none;
}

.speakeasy-progress:hover { height: 8px; }

.speakeasy-progress::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 38%, var(--sk-gold), var(--sk-pink));
  box-shadow: 0 2px 9px rgba(236, 72, 153, 0.6);
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.speakeasy-progress:hover::-webkit-slider-thumb {
  transform: scale(1.45);
}

.speakeasy-progress::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 38%, var(--sk-gold), var(--sk-pink));
  box-shadow: 0 2px 9px rgba(236, 72, 153, 0.6);
  border: none;
  cursor: pointer;
}

/* ── Settings panel ──────────────────────────────────────────── */
.speakeasy-settings {
  position: relative;
  margin-top: 10px;
  padding: 18px 22px;
  background: linear-gradient(145deg, #fdf4ff, #faf5ff);
  border-radius: 24px;
  border: 1.5px solid rgba(124, 58, 237, 0.2);
  box-shadow:
    0 4px 20px rgba(124, 58, 237, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 22px;
  overflow: visible;
}

.speakeasy-settings::before {
  content: '✦  ·  🎙  ·  ✦';
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  letter-spacing: 5px;
  color: var(--sk-pink);
  background: #fdf4ff;
  padding: 0 12px;
  white-space: nowrap;
  pointer-events: none;
}

.speakeasy-setting {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.speakeasy-settings label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  color: var(--sk-smoke);
  margin: 0;
}

/* Voice select pill */
.speakeasy-voice-select {
  padding: 9px 34px 9px 16px;
  border: 1.5px solid rgba(124, 58, 237, 0.28);
  border-radius: 32px;
  background: #fff;
  color: var(--sk-smoke);
  font-size: 0.9rem;
  font-weight: 600;
  min-width: 200px;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'%3E%3Cpath fill='%237c3aed' d='M5 7L0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.speakeasy-voice-select:focus,
.speakeasy-voice-select:hover {
  border-color: var(--sk-pink);
  box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.14);
}

/* Speed slider */
#speakeasy-speed {
  width: 145px;
  height: 4px;
  border-radius: 10px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(
    to right,
    var(--sk-purple) 0%,
    rgba(124, 58, 237, 0.2) 100%
  );
  accent-color: var(--sk-purple);
  cursor: pointer;
  outline: none;
}

#speakeasy-speed::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 38%, var(--sk-purple), var(--sk-smoke));
  box-shadow: 0 2px 10px rgba(91, 33, 182, 0.52);
  border: 2.5px solid #fff;
  cursor: pointer;
  transition: transform 0.2s ease;
}

#speakeasy-speed:hover::-webkit-slider-thumb {
  transform: scale(1.3);
}

#speakeasy-speed::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 38%, var(--sk-purple), var(--sk-smoke));
  box-shadow: 0 2px 10px rgba(91, 33, 182, 0.52);
  border: 2.5px solid #fff;
  cursor: pointer;
}

/* ── Highlighted text while reading ─────────────────────────── */
.speakeasy-current {
  background: linear-gradient(
    135deg,
    rgba(245, 158, 11, 0.35),
    rgba(236, 72, 153, 0.18)
  );
  border-radius: 3px;
  padding: 0 3px;
  transition: background 0.3s;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 600px) {
  .speakeasy-media-player {
    flex-wrap: wrap;
    border-radius: 22px;
    padding: 10px 14px;
    gap: 7px;
  }

  .speakeasy-media-player::before {
    display: none;
  }

  .speakeasy-progress {
    flex-basis: 100%;
    width: 100%;
    order: 10;
  }

  .speakeasy-eq {
    order: 9;
  }

  .speakeasy-settings {
    border-radius: 18px;
  }

  .speakeasy-voice-select {
    min-width: unset;
    width: 100%;
  }

  #speakeasy-speed {
    width: 100%;
  }
}

/* ── Accessibility ──────────────────────────────────────────── */
.speakeasy-button:focus,
.speakeasy-link:focus {
  outline: 3px solid var(--sk-pink);
  outline-offset: 3px;
}
