/**
 * IONOS CLOUD Learn - Audio Narration Player styles
 * A fixed, collapsible dock (bottom-right): a compact launcher button that
 * slides up a full player panel, so controls stay reachable at any scroll
 * position. Plus subtle inline "Listen to this section" buttons in the content.
 * Uses the design tokens from ionos-cloud-learn.css.
 */

/* ==========================================================================
   Fixed dock
   ========================================================================== */
.audio-dock {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: var(--font-body);
}

/* --- Collapsed launcher button --- */
.audio-fab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: var(--border-radius-pill, 9999px);
  cursor: pointer;
  color: #fff;
  background: var(--ionos-cloud-blue, #3196d6);
  box-shadow: var(--shadow-lg, 0 10px 15px rgba(0, 27, 65, 0.1));
  font-weight: var(--font-semibold, 600);
  font-size: var(--text-sm, 0.875rem);
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.audio-fab:hover { background: var(--ionos-cloud-blue-dark, #0b2a63); }
.audio-fab:active { transform: scale(0.96); }
.audio-fab-icon { width: 1.3rem; height: 1.3rem; }
.audio-fab-label { line-height: 1; }

/* Equalizer shown on the launcher while audio is playing (collapsed). */
.audio-fab-eq { display: none; align-items: flex-end; gap: 2px; height: 1rem; }
.audio-fab-eq i {
  width: 3px; height: 100%;
  background: #fff; border-radius: 2px;
  transform-origin: bottom;
  animation: ua-eq 0.9s ease-in-out infinite;
}
.audio-fab-eq i:nth-child(1) { animation-delay: 0s; }
.audio-fab-eq i:nth-child(2) { animation-delay: 0.2s; }
.audio-fab-eq i:nth-child(3) { animation-delay: 0.4s; }
@keyframes ua-eq { 0%, 100% { transform: scaleY(0.35); } 50% { transform: scaleY(1); } }

.audio-dock.is-playing .audio-fab-icon { display: none; }
.audio-dock.is-playing .audio-fab-eq { display: inline-flex; }

/* --- Expanded panel --- */
.audio-panel {
  width: 340px;
  max-width: calc(100vw - 2.5rem);
  background: var(--bg-white, #fff);
  border: 1px solid var(--border-light, #e8ebef);
  border-top: 3px solid var(--ionos-cloud-blue, #3196d6);
  border-radius: var(--border-radius-lg, 8px);
  box-shadow: var(--shadow-lg, 0 10px 15px rgba(0, 27, 65, 0.1));
  padding: 0.85rem 1rem 1rem;
  animation: ua-slide-up 0.2s ease;
}
@keyframes ua-slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* State switching */
.audio-dock.is-collapsed .audio-panel { display: none; }
.audio-dock:not(.is-collapsed) .audio-fab { display: none; }

.ap-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.ap-eyebrow {
  font-size: var(--text-xs, 0.75rem);
  font-weight: var(--font-bold, 700);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ionos-cloud-blue-dark, #0b2a63);
}
.ap-collapse {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem; height: 1.9rem;
  border: none; background: transparent; cursor: pointer;
  color: var(--text-muted, #718095);
  border-radius: 50%;
}
.ap-collapse:hover { background: var(--bg-light, #f5f7fa); color: var(--text-secondary, #465a75); }
.ap-collapse svg { width: 1.05rem; height: 1.05rem; }

.ap-now {
  font-size: var(--text-sm, 0.875rem);
  font-weight: var(--font-semibold, 600);
  color: var(--text-primary, #001b41);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.6rem;
}

/* ==========================================================================
   Shared controls (seek, play/pause, prev/next, time, speed)
   ========================================================================== */
.ua-seek {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: var(--border-radius-pill, 9999px);
  background: var(--border-color, #dfe2e7);
  cursor: pointer;
}
.ua-seek:disabled { cursor: default; opacity: 0.6; }
.ua-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--ionos-cloud-blue, #3196d6);
  border: 2px solid #fff;
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 27, 65, 0.05));
}
.ua-seek::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--ionos-cloud-blue, #3196d6);
  border: 2px solid #fff;
}

.ap-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.7rem;
}

.ua-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem; height: 2.5rem;
  padding: 0; border: none; border-radius: 50%;
  cursor: pointer; color: #fff;
  background: var(--ionos-cloud-blue, #3196d6);
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 27, 65, 0.05));
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.ua-toggle:hover { background: var(--ionos-cloud-blue-dark, #0b2a63); }
.ua-toggle:active { transform: scale(0.94); }
.ua-toggle svg { width: 1.2rem; height: 1.2rem; margin-left: 1px; }
.ua-icon-pause { margin-left: 0; }

.ua-prev, .ua-next {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem; height: 1.9rem;
  padding: 0; border: none; border-radius: 50%;
  cursor: pointer;
  color: var(--text-secondary, #465a75);
  background: transparent;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.ua-prev:hover, .ua-next:hover { background: rgba(49, 150, 214, 0.12); color: var(--ionos-cloud-blue-dark, #0b2a63); }
.ua-prev:disabled, .ua-next:disabled { opacity: 0.35; cursor: default; background: transparent; }
.ua-prev svg, .ua-next svg { width: 1rem; height: 1rem; }

.ua-time {
  font-size: var(--text-xs, 0.75rem);
  color: var(--text-muted, #718095);
  font-variant-numeric: tabular-nums;
  margin-left: 0.25rem;
}
.ua-spacer { flex: 1 1 auto; }

.ua-speeds {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--bg-light, #f5f7fa);
  border: 1px solid var(--border-color, #dfe2e7);
  border-radius: var(--border-radius-pill, 9999px);
}
.ua-speed {
  border: none; background: transparent; cursor: pointer;
  font-size: var(--text-xs, 0.75rem);
  font-weight: var(--font-medium, 500);
  color: var(--text-secondary, #465a75);
  padding: 0.1rem 0.45rem;
  border-radius: var(--border-radius-pill, 9999px);
  line-height: 1.4;
}
.ua-speed.active { background: var(--ionos-cloud-navy, #001b41); color: #fff; }

/* ==========================================================================
   Inline per-section "Listen" button
   ========================================================================== */
.section-audio { margin: 0 0 var(--space-3, 0.75rem); }
.section-listen {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  padding: 0.25rem 0.7rem;
  font-size: var(--text-xs, 0.75rem);
  font-weight: var(--font-semibold, 600);
  color: var(--ionos-cloud-blue-dark, #0b2a63);
  background: transparent;
  border: 1px solid var(--border-color, #dfe2e7);
  border-radius: var(--border-radius-pill, 9999px);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.section-listen:hover,
.section-listen:focus-visible {
  background: var(--ionos-cloud-blue, #3196d6);
  border-color: var(--ionos-cloud-blue, #3196d6);
  color: #fff;
  outline: none;
}
.section-listen-icon { width: 0.8rem; height: 0.8rem; }
.section-audio.is-active .section-listen {
  background: var(--ionos-cloud-blue, #3196d6);
  border-color: var(--ionos-cloud-blue, #3196d6);
  color: #fff;
}

/* ==========================================================================
   Responsive + motion + print
   ========================================================================== */
@media (max-width: 600px) {
  /* Full-width bottom sheet; controls wrap instead of overflowing. */
  .audio-dock { right: 0.5rem; left: 0.5rem; bottom: 0.5rem; align-items: stretch; }
  .audio-panel { width: auto; max-width: none; padding: 0.85rem 0.9rem 1rem; }
  .audio-fab { align-self: flex-end; }
  .ap-row { flex-wrap: wrap; row-gap: 0.6rem; column-gap: 0.5rem; }
  /* Speeds drop to their own full-width line when space is tight. */
  .ua-spacer { display: none; }
  .ua-speeds { margin-left: auto; }
  /* Larger touch targets on the previous/next controls. */
  .ua-prev, .ua-next { width: 2.25rem; height: 2.25rem; }
}
@media (prefers-reduced-motion: reduce) {
  .audio-panel { animation: none; }
  .audio-fab-eq i { animation: none; }
}
@media print {
  .audio-dock, .section-audio { display: none; }
}
