/**
 * AHG Text-to-Speech Styles
 */

/* TTS Button Base Styles */
.tts-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--ahg-primary);
  background-color: transparent;
  border: 1px solid var(--ahg-primary);
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}

.tts-btn:hover {
  color: #fff;
  background-color: var(--ahg-primary);
  border-color: var(--ahg-primary);
}

.tts-btn:focus {
  outline: none;
  box-shadow: 0 0 0 0.2rem rgba(var(--ahg-primary-rgb), 0.25);
}

.tts-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Playing state */
.tts-btn.tts-playing {
  color: #fff;
  background-color: var(--ahg-primary);
  border-color: var(--ahg-primary);
}

.tts-btn.tts-playing i {
  animation: tts-pulse 1s infinite;
}

@keyframes tts-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Small variant */
.tts-btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

/* Icon-only variant */
.tts-btn-icon {
  padding: 0.375rem;
  border-radius: 50%;
  width: 2rem;
  height: 2rem;
}

.tts-btn-icon.tts-btn-sm {
  width: 1.5rem;
  height: 1.5rem;
  padding: 0.25rem;
}

/* TTS Controls Group */
.tts-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--ahg-light);
  border-radius: 0.5rem;
  border: 1px solid var(--ahg-border);
}

/* Speed control */
.tts-speed-control {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.tts-speed-control label {
  font-size: 0.75rem;
  color: var(--ahg-muted);
  margin: 0;
}

.tts-speed-control input[type="range"] {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  background: var(--ahg-border);
  border-radius: 2px;
  cursor: pointer;
}

.tts-speed-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--ahg-primary);
  border-radius: 50%;
  cursor: pointer;
}

.tts-speed-value {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ahg-primary);
  min-width: 2.5rem;
  text-align: center;
}

/* Floating TTS button for articles */
.tts-floating {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 1000;
}

.tts-floating .tts-btn {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  background: var(--ahg-primary);
  color: #fff;
  border: none;
}

.tts-floating .tts-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* TTS Bar (sticky controls) */
.tts-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: none;
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, var(--ahg-primary) 0%, var(--ahg-secondary) 100%);
  color: #fff;
  border-radius: 0 0 0.5rem 0.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tts-bar.active {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tts-bar .tts-btn {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

.tts-bar .tts-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.tts-bar .tts-status {
  font-size: 0.875rem;
  opacity: 0.9;
}

/* Inline TTS button (next to headings) */
.tts-inline {
  margin-left: 0.5rem;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.tts-inline:hover,
.tts-inline.tts-playing {
  opacity: 1;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .tts-btn {
    color: #7dd3c0;
    border-color: #7dd3c0;
  }

  .tts-btn:hover,
  .tts-btn.tts-playing {
    background-color: #7dd3c0;
    color: #1a1a1a;
  }

  .tts-controls {
    background: #2d2d2d;
    border-color: #404040;
  }

  .tts-speed-control label {
    color: #a0a0a0;
  }
}

/* Accessibility - reduced motion */
@media (prefers-reduced-motion: reduce) {
  .tts-btn,
  .tts-floating .tts-btn {
    transition: none;
  }

  .tts-btn.tts-playing i {
    animation: none;
  }
}

/* Screen reader only text */
.tts-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* TTS content highlight during reading */
[data-tts-content].tts-reading {
  outline: 2px solid rgba(var(--ahg-primary-rgb), 0.3);
  outline-offset: 4px;
  border-radius: 4px;
}
