/**
 * TTS Play Button Styles
 * Accessible, responsive styles for TTS play buttons
 */

.tts-wrapper {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

.tts-play-button {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

.tts-play-button:hover {
  background: rgba(0, 0, 0, 0.85);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.tts-play-button:focus {
  outline: 3px solid #4CAF50;
  outline-offset: 2px;
}

.tts-play-button:active {
  transform: scale(0.95);
}

/* Loading state */
.tts-play-button.tts-loading {
  background: rgba(66, 133, 244, 0.85);
  cursor: wait;
}

.tts-play-button.tts-loading .tts-icon-loading {
  animation: tts-spin 1s linear infinite;
}

/* Playing state */
.tts-play-button.tts-playing {
  background: rgba(76, 175, 80, 0.85);
}

/* Icon animations */
@keyframes tts-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* For slide/figure captions */
figure .tts-wrapper,
.slide .tts-wrapper {
  width: 100%;
}

figure img,
.slide img {
  display: block;
  width: 100%;
  height: auto;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  .tts-play-button,
  .tts-icon-loading {
    animation: none;
    transition: none;
  }
}

/* Mobile responsive */
@media (max-width: 768px) {
  .tts-play-button {
    width: 40px;
    height: 40px;
    bottom: 8px;
    right: 8px;
  }

  .tts-play-button svg {
    width: 20px;
    height: 20px;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .tts-play-button {
    background: black;
    border: 2px solid white;
  }

  .tts-play-button:hover {
    background: #333;
  }

  .tts-play-button:focus {
    outline-color: yellow;
  }
}

/* Ensure button is visible on light and dark images */
.tts-play-button::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 0, 0, 0.3), transparent);
  z-index: -1;
}

/* Text element TTS styles */
.tts-text {
  transition: all 0.2s ease;
  padding: 4px 8px;
  margin: -4px -8px;
  border-radius: 4px;
}

.tts-text:hover {
  background: rgba(33, 150, 243, 0.08);
}

.tts-text:focus {
  outline: 2px solid #2196F3;
  outline-offset: 2px;
}

.tts-text.tts-playing {
  background: rgba(76, 175, 80, 0.12);
  border-left: 4px solid #4CAF50;
  padding-left: 12px;
  margin-left: -12px;
  animation: tts-pulse 2s ease-in-out infinite;
}

@keyframes tts-pulse {
  0%, 100% {
    background: rgba(76, 175, 80, 0.12);
  }
  50% {
    background: rgba(76, 175, 80, 0.2);
  }
}

/* Read all controls */
.tts-read-all-button,
.tts-stop-all-button {
  font-family: inherit;
}

.tts-read-all-button svg,
.tts-stop-all-button svg {
  flex-shrink: 0;
}

/* Accessibility - ensure text elements are keyboard accessible */
.tts-text[role="button"] {
  outline: none;
}

.tts-text[role="button"]:focus-visible {
  outline: 2px solid #2196F3;
  outline-offset: 2px;
}
