/* =====================================================================
   TTS Widget — Lector de artículos por voz
   Tanatología Pachuca · Accesibilidad para personas con discapacidad visual
   ===================================================================== */

/* Skip link para lectores de pantalla — permite saltarse el widget */
.tts-skip {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.tts-skip:focus {
  position: fixed;
  left: 12px;
  top: 12px;
  width: auto;
  height: auto;
  padding: 10px 16px;
  background: #4c1d95;
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  z-index: 100000;
  font-weight: 600;
}

/* Widget flotante */
.tts-widget {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9999;
  background: #fff;
  border: 1px solid #e5e0f4;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(76, 29, 149, 0.18);
  font-family: inherit;
  color: #1f1f1f;
  width: 320px;
  max-width: calc(100vw - 28px);
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.tts-widget[hidden] { display: none !important; }

/* Estado plegado: solo botón circular grande */
.tts-widget.tts-collapsed {
  width: auto;
  border-radius: 999px;
  padding: 0;
}
.tts-widget.tts-collapsed .tts-panel { display: none; }

/* Botón circular principal cuando está plegado */
.tts-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: linear-gradient(135deg, #7c3aed 0%, #4c1d95 100%);
  color: #fff;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.tts-toggle:hover { background: linear-gradient(135deg, #8b3fff 0%, #5b21b6 100%); }
.tts-toggle:focus-visible { outline: 3px solid #fbbf24; outline-offset: 2px; }
.tts-toggle .tts-icon { flex-shrink: 0; }

/* Panel expandido */
.tts-panel { padding: 16px 18px; }

.tts-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f0ebfa;
}
.tts-title {
  font-weight: 700;
  font-size: 1rem;
  color: #4c1d95;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tts-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #6b6b6b;
  font-size: 1.1rem;
  line-height: 1;
  border-radius: 4px;
}
.tts-close:hover { color: #1f1f1f; background: #f5f5f5; }
.tts-close:focus-visible { outline: 2px solid #7c3aed; outline-offset: 1px; }

/* Controles principales */
.tts-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.tts-btn {
  flex: 1;
  padding: 10px 12px;
  background: #f7f3fc;
  border: 1px solid #e5e0f4;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: #4c1d95;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  transition: background 0.15s, transform 0.05s;
  min-height: 44px; /* WCAG: tap target mínimo */
}
.tts-btn:hover:not(:disabled) { background: #ebe1fb; }
.tts-btn:active:not(:disabled) { transform: scale(0.97); }
.tts-btn:focus-visible { outline: 3px solid #fbbf24; outline-offset: 1px; }
.tts-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tts-btn.tts-primary {
  background: #7c3aed;
  color: #fff;
  border-color: #7c3aed;
}
.tts-btn.tts-primary:hover:not(:disabled) { background: #6d28d9; }

/* Sliders */
.tts-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 0.85rem;
}
.tts-row label {
  flex-shrink: 0;
  color: #4b4b4b;
  font-weight: 500;
  min-width: 70px;
}
.tts-row input[type="range"] {
  flex: 1;
  accent-color: #7c3aed;
  height: 28px; /* tap target */
}
.tts-row select {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #d1c4e9;
  border-radius: 8px;
  background: #fff;
  font-family: inherit;
  font-size: 0.85rem;
  color: #1f1f1f;
  min-height: 32px;
}
.tts-row select:focus-visible { outline: 2px solid #7c3aed; outline-offset: 1px; }
.tts-value {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  color: #6b6b6b;
  min-width: 38px;
  text-align: right;
}

/* Indicador de progreso / texto que está leyendo */
.tts-status {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #f0ebfa;
  font-size: 0.8rem;
  color: #6b6b6b;
  line-height: 1.4;
  min-height: 1.4em;
}
.tts-status.tts-active { color: #4c1d95; }

/* Resaltado del párrafo que se está leyendo */
.tts-reading {
  background: linear-gradient(transparent 60%, rgba(124, 58, 237, 0.18) 60%);
  border-radius: 4px;
  transition: background 0.3s;
}

/* Reducir motion para usuarios que lo prefieren */
@media (prefers-reduced-motion: reduce) {
  .tts-widget,
  .tts-btn,
  .tts-reading { transition: none; }
}

/* Modo alto contraste */
@media (prefers-contrast: more) {
  .tts-widget { border-width: 2px; border-color: #000; }
  .tts-btn { border-width: 2px; }
  .tts-reading { background: #fff59d; }
}

/* Responsive */
@media (max-width: 480px) {
  .tts-widget {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
  }
}
