/*
 * ╔══════════════════════════════════════════════════════╗
 * ║  ZAGREVAT — a11y-widget.css                         ║
 * ║  Widget de Accesibilidad nativo · WCAG 2.2 AA        ║
 * ║  Usa los tokens CSS de styles.css (--pink, --cyan…)  ║
 * ╚══════════════════════════════════════════════════════╝
 */

/* ── TOKENS PROPIOS DEL WIDGET ──────────────────────── */
:root {
  --aw-grad:    linear-gradient(155deg, #9cd04d, #75b663, #4e9d78, #27838e, #0069a3);
  --aw-w:       318px;
  --aw-z:       9990;
  --aw-white:   #ffffff;
  --aw-dark:    #15243a;
  --aw-glass:   rgba(255,255,255,.13);
  --aw-glass-h: rgba(255,255,255,.22);
  --aw-bdr:     rgba(255,255,255,.2);
  --aw-on:      rgba(255,255,255,.92);
  --aw-shadow:  0 14px 50px rgba(0,0,0,.32), 0 2px 8px rgba(0,0,0,.18);
}

/* ════════════════════════════════════════════════════
   BOTÓN TRIGGER FLOTANTE
   ════════════════════════════════════════════════════ */
.aw-trigger {
  position: fixed;
  right: 22px;
  bottom: 26px;
  z-index: var(--aw-z);
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--aw-grad);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--aw-shadow);
  transition: transform .22s cubic-bezier(.4,0,.2,1), box-shadow .22s;
  -webkit-tap-highlight-color: transparent;
}
.aw-trigger svg { width: 27px; height: 27px; }

/* Tooltip */
.aw-trigger::before {
  content: 'Accesibilidad';
  position: absolute;
  right: calc(100% + 11px);
  top: 50%;
  transform: translateY(-50%) translateX(6px);
  background: var(--aw-dark);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .04em;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s, transform .15s;
}
.aw-trigger:hover::before,
.aw-trigger:focus-visible::before { opacity: 1; transform: translateY(-50%) translateX(0); }
.aw-trigger:hover  { transform: scale(1.1); box-shadow: 0 18px 58px rgba(0,0,0,.38); }
.aw-trigger:active { transform: scale(.94); }
.aw-trigger:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* Anillo de pulso — llama la atención al cargar (3 veces, luego para) */
.aw-trigger::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: var(--aw-grad);
  opacity: .3;
  z-index: -1;
  animation: awPulse 2.6s ease-out 1.2s 3;
}
@keyframes awPulse {
  0%   { transform: scale(1);   opacity: .3; }
  70%  { transform: scale(1.6); opacity: 0; }
  100% { transform: scale(1.6); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .aw-trigger::after { animation: none; }
}

/* ════════════════════════════════════════════════════
   PANEL
   ════════════════════════════════════════════════════ */
.aw-panel {
  position: fixed;
  right: 22px;
  bottom: calc(54px + 18px);
  z-index: var(--aw-z);
  width: var(--aw-w);
  max-height: min(84vh, 630px);
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  overflow: hidden;
  background: var(--aw-grad);
  box-shadow: var(--aw-shadow);
  border: 1px solid var(--aw-bdr);
  /* — estado cerrado — */
  visibility: hidden;
  opacity: 0;
  transform: translateY(16px) scale(.97);
  transform-origin: bottom right;
  transition:
    opacity .28s cubic-bezier(.4,0,.2,1),
    transform .28s cubic-bezier(.4,0,.2,1),
    visibility 0s .28s;
}
.aw-panel.is-open {
  visibility: visible;
  opacity: 1;
  transform: translateY(0) scale(1);
  transition:
    opacity .28s cubic-bezier(.4,0,.2,1),
    transform .28s cubic-bezier(.4,0,.2,1),
    visibility 0s 0s;
}

/* ── Cabecera ─────────────────────────────────────── */
.aw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  background: rgba(0,0,0,.12);
  border-bottom: 1px solid var(--aw-bdr);
  flex-shrink: 0;
  gap: 10px;
}
.aw-header-title {
  font-family: 'Syne', sans-serif;
  font-size: .9rem;
  font-weight: 700;
  color: var(--aw-white);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.aw-header-close {
  width: 32px; height: 32px; min-width: 32px;
  border-radius: 50%;
  background: var(--aw-glass);
  border: 1px solid var(--aw-bdr);
  color: var(--aw-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .2s;
  flex-shrink: 0;
}
.aw-header-close:hover  { background: var(--aw-glass-h); transform: rotate(90deg); }
.aw-header-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.aw-header-close svg { width: 14px; height: 14px; }

/* ── Cuerpo scrollable ────────────────────────────── */
.aw-body {
  overflow-y: auto;
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.28) transparent;
}
.aw-body::-webkit-scrollbar       { width: 4px; }
.aw-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.28); border-radius: 4px; }

/* ── Control tamaño de texto ──────────────────────── */
.aw-font-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--aw-glass);
  border: 1px solid var(--aw-bdr);
  border-radius: 12px;
}
.aw-font-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: 'DM Sans', sans-serif;
  font-size: .77rem;
  font-weight: 600;
  color: var(--aw-white);
}
.aw-font-controls { display: flex; align-items: center; gap: 6px; }
.aw-fs-btn {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--aw-glass);
  border: 1px solid var(--aw-bdr);
  color: var(--aw-white);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s;
  line-height: 1;
  min-height: 30px;
}
.aw-fs-btn:hover  { background: var(--aw-glass-h); }
.aw-fs-btn:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.aw-fs-val {
  font-family: 'DM Sans', sans-serif;
  font-size: .8rem; font-weight: 700;
  color: var(--aw-white);
  min-width: 38px; text-align: center;
}

/* ── Grid de funciones ────────────────────────────── */
.aw-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

/* ── Botón de función ─────────────────────────────── */
.aw-feat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 14px 8px 10px;
  background: var(--aw-glass);
  border: 1px solid var(--aw-bdr);
  border-radius: 12px;
  color: var(--aw-white);
  cursor: pointer;
  transition: background .15s, transform .12s, color .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  min-height: 76px;
  text-align: center;
}
.aw-feat:hover  { background: var(--aw-glass-h); }
.aw-feat:active { transform: scale(.95); }
.aw-feat:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Estado ON */
.aw-feat.is-on {
  background: var(--aw-on);
  border-color: transparent;
  color: var(--aw-dark);
  box-shadow: 0 2px 14px rgba(0,0,0,.18);
}
/* Check indicator */
.aw-feat.is-on::after {
  content: '✓';
  position: absolute;
  top: 6px; right: 7px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #27838e;
  color: #fff;
  font-size: .58rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 14px;
  text-align: center;
}

.aw-icon {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; flex-shrink: 0;
}
.aw-icon svg { width: 22px; height: 22px; }

.aw-name {
  font-family: 'DM Sans', sans-serif;
  font-size: .67rem; font-weight: 600;
  line-height: 1.2; text-align: center;
}

/* Dots de pasos */
.aw-dots { display: flex; gap: 3px; margin-top: 2px; }
.aw-dots i {
  display: block; width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,.32);
  font-style: normal;
}
.aw-feat.is-on .aw-dots i            { background: rgba(39,131,142,.4); }
.aw-feat.is-on .aw-dots i:first-child{ background: #27838e; }

/* ── Botón resetear ───────────────────────────────── */
.aw-reset-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  background: rgba(0,0,0,.15);
  border: 1.5px solid var(--aw-bdr);
  border-radius: 12px;
  color: var(--aw-white);
  font-family: 'DM Sans', sans-serif;
  font-size: .82rem; font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  min-height: 44px;
}
.aw-reset-btn:hover { background: rgba(0,0,0,.25); }
.aw-reset-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.aw-reset-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ── Pie del panel ────────────────────────────────── */
.aw-footer {
  padding: 9px 16px;
  background: rgba(0,0,0,.12);
  border-top: 1px solid var(--aw-bdr);
  text-align: center;
  flex-shrink: 0;
}
.aw-footer span {
  font-family: 'DM Sans', sans-serif;
  font-size: .63rem;
  color: rgba(255,255,255,.62);
  letter-spacing: .05em;
}

/* ════════════════════════════════════════════════════
   GUÍA DE LECTURA
   ════════════════════════════════════════════════════ */
.aw-reading-line {
  display: none;
  position: fixed;
  left: 0; right: 0;
  z-index: calc(var(--aw-z) - 2);
  height: 2px;
  background: #0069a3;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.13);
  transition: top .04s linear;
}
body.aw-reading .aw-reading-line { display: block; }

/* ════════════════════════════════════════════════════
   CLASES APLICADAS AL BODY (activadas por JS)
   ════════════════════════════════════════════════════ */

/* Contraste alto */
body.aw-contrast-high { filter: contrast(1.55) brightness(.95); }

/* Invertir colores (con corrección para imágenes y el propio widget) */
body.aw-invert { filter: invert(1) hue-rotate(180deg); }
body.aw-invert img,
body.aw-invert video,
body.aw-invert .orb,
body.aw-invert .aw-trigger,
body.aw-invert .aw-panel { filter: invert(1) hue-rotate(180deg); }

/* Resaltar enlaces */
body.aw-links a:not(.aw-trigger):not(.aw-feat):not(.aw-reset-btn):not(.nav-cta):not(.btn-primary) {
  text-decoration: underline !important;
  text-decoration-thickness: 2px !important;
  text-underline-offset: 3px !important;
  outline: 1px dashed currentColor !important;
  outline-offset: 1px !important;
}

/* Fuente apta para dislexia */
@font-face {
  font-family: 'OpenDyslexic';
  src: url('https://cdn.jsdelivr.net/npm/open-dyslexic@1.0.3/open-dyslexic-regular.woff') format('woff');
  font-display: swap;
}
body.aw-dyslexia,
body.aw-dyslexia *:not(.material-symbols-outlined):not(.nav-logo) {
  font-family: 'OpenDyslexic', cursive !important;
  letter-spacing: .05em !important;
}

/* Detener animaciones */
body.aw-no-anim *,
body.aw-no-anim *::before,
body.aw-no-anim *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

/* Cursor grande */
body.aw-big-cursor,
body.aw-big-cursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cpath d='M6 2L6 34L14 26L20 37L25 34L19 23L30 23Z' fill='%23111' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E") 6 2, auto !important;
}

/* Espaciado de texto */
body.aw-spacing p,
body.aw-spacing li,
body.aw-spacing span,
body.aw-spacing h1,
body.aw-spacing h2,
body.aw-spacing h3,
body.aw-spacing h4 {
  letter-spacing: .1em !important;
  word-spacing: .16em !important;
}

/* Altura de línea */
body.aw-lineheight p,
body.aw-lineheight li,
body.aw-lineheight span { line-height: 2.2 !important; }

/* Sin saturación */
body.aw-grayscale { filter: grayscale(1); }

/* Ocultar imágenes */
body.aw-hide-img img,
body.aw-hide-img video,
body.aw-hide-img .orb { visibility: hidden !important; }

/* Foco de teclado visible mejorado */
body.aw-focus *:focus,
body.aw-focus *:focus-visible {
  outline: 3px solid #0069a3 !important;
  outline-offset: 4px !important;
  border-radius: 4px !important;
}

/* ════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  :root { --aw-w: calc(100vw - 32px); }
  .aw-panel   { right: 16px; left: 16px; }
  .aw-trigger { right: 16px; }
}

/* ════════════════════════════════════════════════════
   COMPATIBILIDAD CON TEMA OSCURO DE styles.css
   El gradiente del widget es siempre el mismo —
   funciona bien tanto en light como en dark.
   ════════════════════════════════════════════════════ */
