/*
 * Karma CJCE v1 — accessibility.css
 * Botón flotante de accesibilidad (asistencia para personas ciegas o con baja
 * visión). Usa los tokens de marca de custom.css (--brand-*, radios, sombras,
 * fuentes). Sin dependencias externas: la lectura en voz alta usa el propio
 * navegador (speechSynthesis), sin llamadas de red (RGPD).
 *
 * Se coloca en la esquina inferior IZQUIERDA para no solaparse con el launcher
 * del asistente de chat (esquina inferior derecha).
 */

/* ---- Botón flotante ---- */
.karma-a11y-launcher {
  position: fixed;
  left: clamp(1rem, 3vw, 1.75rem);
  bottom: clamp(1rem, 3vw, 1.75rem);
  z-index: 90;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--brand-secondary);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: background 0.18s ease, transform 0.15s ease, box-shadow 0.18s ease;
}
.karma-a11y-launcher:hover {
  background: var(--brand-secondary-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.karma-a11y-launcher:focus-visible {
  outline: 3px solid var(--brand-accent);
  outline-offset: 3px;
}
.karma-a11y-launcher svg { width: 28px; height: 28px; }

/* ---- Panel ---- */
.karma-a11y-panel {
  position: fixed;
  left: clamp(1rem, 3vw, 1.75rem);
  bottom: calc(56px + clamp(1rem, 3vw, 1.75rem) + 0.75rem);
  z-index: 95;
  width: min(320px, calc(100vw - 2rem));
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-raised);
  border: 1px solid var(--neutral-100);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-body);
  animation: karma-a11y-in 0.2s ease;
}
.karma-a11y-panel.is-open { display: flex; }

@keyframes karma-a11y-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.karma-a11y-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.9rem 1.1rem;
  background: var(--brand-secondary);
  color: #fff;
}
.karma-a11y-header__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.15;
}
.karma-a11y-close {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.14);
  color: #fff;
  cursor: pointer;
  transition: background 0.18s ease;
}
.karma-a11y-close:hover { background: rgba(255,255,255,0.28); }
.karma-a11y-close svg { width: 18px; height: 18px; }

.karma-a11y-body {
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--bg-sunken);
}

.karma-a11y-btn {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  text-align: left;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  background: var(--bg-raised);
  color: var(--ink-strong);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.karma-a11y-btn svg { width: 22px; height: 22px; flex-shrink: 0; color: var(--brand-primary); }
.karma-a11y-btn:hover {
  background: var(--tint-primary);
  border-color: var(--brand-primary);
}
.karma-a11y-btn:focus-visible {
  outline: 3px solid var(--brand-accent);
  outline-offset: 2px;
}
.karma-a11y-btn[aria-pressed="true"] {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
}
.karma-a11y-btn[aria-pressed="true"] svg { color: #fff; }

.karma-a11y-btn--reset {
  justify-content: center;
  font-weight: 700;
  color: var(--brand-secondary);
}

/* Estado «escuchando» del asistente de voz: pulso suave sobre el resaltado. */
.karma-a11y-btn[data-action="voice"][aria-pressed="true"] {
  animation: karma-a11y-listening 1.3s ease-in-out infinite;
}
@keyframes karma-a11y-listening {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192, 79, 106, 0.45); }
  50%      { box-shadow: 0 0 0 6px rgba(192, 79, 106, 0); }
}

.karma-a11y-status {
  padding: 0 1.1rem 0.85rem;
  margin: 0;
  font-size: 0.72rem;
  color: var(--ink-muted);
  background: var(--bg-sunken);
  text-align: center;
}

/* ---- Estados aplicados a la página (persisten mientras dure la sesión) ---- */
html.karma-a11y-contrast {
  filter: contrast(1.35) saturate(1.15);
}
html.karma-a11y-bigtext body,
html.karma-a11y-bigtext body * {
  line-height: 1.7 !important;
}

/* Resalta el bloque que se está leyendo en voz alta. */
.karma-a11y-reading {
  outline: 3px solid var(--brand-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  .karma-a11y-panel { animation: none; }
  .karma-a11y-launcher:hover { transform: none; }
  .karma-a11y-btn[data-action="voice"][aria-pressed="true"] { animation: none; }
}
