/* ============================================================
   ACCESSIBILITY MENU — INSaNE | A Broken Hero  v4
   Layout fixes:
   - Panel se abre ENCIMA del botón (bottom: calc desde toggle)
   - Grid 2 columnas con altura uniforme en todas las celdas
   - Ancho suficiente para etiquetas sin wrap
   - Botón toggle visible y separado del panel
   ============================================================ */

/* ── Botón flotante ─────────────────────────────────────────── */
#a11y-toggle {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 99999;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    /* Azul — color universalmente asociado a accesibilidad */
    background: #1a6fb5;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(26,111,181,0.55);
    transition: transform 0.2s ease, box-shadow 0.25s ease,
                background 0.35s ease, color 0.35s ease;
    pointer-events: auto;
    padding: 0;
    outline: none;
    isolation: isolate;
}
#a11y-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 22px rgba(26,111,181,0.7);
}
/* Panel abierto — amarillo Billie Eilish, icono negro */
#a11y-toggle.a11y-open-state {
    background: #f5d800;
    color: #000;
    box-shadow: 0 4px 20px rgba(245,216,0,0.6);
}
#a11y-toggle.a11y-open-state:hover {
    box-shadow: 0 6px 26px rgba(245,216,0,0.75);
}
#a11y-toggle:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}
/* SVG no intercepta clicks */
#a11y-toggle svg,
#a11y-toggle svg * { pointer-events: none; }

/* ── Panel ──────────────────────────────────────────────────── */
#a11y-panel {
    position: fixed;
    /* Se posiciona encima del botón con espacio de 12px */
    bottom: 84px;   /* 48px botón + 24px offset + 12px gap */
    left: 24px;
    z-index: 99998;
    /* Ancho calculado para 2 columnas sin wrap en etiquetas */
    width: 300px;
    background: #111;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px;
    padding: 14px 12px 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.65);
    display: none;
    flex-direction: column;
    gap: 0;
    /* Animación de apertura */
    transform-origin: bottom left;
}
#a11y-panel.a11y-open {
    display: flex;
    animation: a11yPanelOpen 0.18s ease-out;
}
@keyframes a11yPanelOpen {
    from { opacity: 0; transform: scale(0.95) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Título */
#a11y-panel h2 {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.35);
    margin: 0 0 10px 2px;
    padding: 0;
    border: none;
    background: none;
}

/* ── Grid 2 columnas ────────────────────────────────────────── */
#a11y-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    /* Reset y separador van a ancho completo */
}

/* ── Botones de feature ─────────────────────────────────────── */
.a11y-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 5px;
    padding: 10px 6px 8px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.03);
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    text-align: center;
    /* Altura fija para que todas las celdas sean iguales */
    height: 90px;
    box-sizing: border-box;
    overflow: hidden;
}
.a11y-btn:hover { background: rgba(255,255,255,0.08); }
.a11y-btn:focus-visible {
    outline: 2px solid #e83b2e;
    outline-offset: 2px;
}
.a11y-btn svg,
.a11y-btn svg * { pointer-events: none; }

/* Contenedor del ícono */
.a11y-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 34px;
    border-radius: 18px;
    background: #1c1c1c;
    flex-shrink: 0;
    transition: background 0.15s;
}

/* Etiqueta — tamaño fijo, sin wrap */
.a11y-label {
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Dots de stage */
.a11y-stages {
    display: flex;
    gap: 3px;
    margin-top: auto;
    padding-bottom: 2px;
}
.a11y-stage-dot {
    width: 14px;
    height: 2px;
    border-radius: 2px;
    background: rgba(255,255,255,0.18);
    transition: background 0.2s;
}
.a11y-stage-dot.active { background: rgba(255,255,255,0.75); }

/* ── Estados activos ────────────────────────────────────────── */
.a11y-btn.a11y-stage-1 {
    border-color: rgba(0,200,120,0.35);
    background: rgba(0,200,120,0.07);
    color: #00c878;
}
.a11y-btn.a11y-stage-1 .a11y-icon-wrap { background: rgba(0,200,120,0.12); }
.a11y-btn.a11y-stage-1 .a11y-stage-dot.active { background: #00c878; }

.a11y-btn.a11y-stage-2 {
    border-color: rgba(0,200,120,0.55);
    background: rgba(0,200,120,0.12);
    color: #00e88a;
}
.a11y-btn.a11y-stage-2 .a11y-icon-wrap { background: rgba(0,200,120,0.2); }
.a11y-btn.a11y-stage-2 .a11y-stage-dot.active { background: #00e88a; }

.a11y-btn.a11y-stage-3 {
    border-color: #00c878;
    background: rgba(0,200,120,0.18);
    color: #00ffaa;
}
.a11y-btn.a11y-stage-3 .a11y-icon-wrap { background: rgba(0,200,120,0.28); }
.a11y-btn.a11y-stage-3 .a11y-stage-dot.active { background: #00ffaa; }

/* ── Separador y Reset ──────────────────────────────────────── */
.a11y-separator {
    grid-column: 1 / -1;
    height: 1px;
    background: rgba(255,255,255,0.07);
    margin: 4px 0;
}

#a11y-reset {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: center;
    height: 38px;
    gap: 7px;
    color: rgba(255,255,255,0.4);
    font-size: 13px;
    font-weight: 500;
    border-color: transparent;
    background: transparent;
    border-radius: 8px;
}
#a11y-reset:hover { color: #fff; background: rgba(255,255,255,0.05); }
/* Ocultar elementos que no aplican al reset */
#a11y-reset .a11y-icon-wrap,
#a11y-reset .a11y-stages { display: none; }
#a11y-reset .a11y-label { white-space: nowrap; font-size: 13px; }


/* ============================================================
   FEATURE STATES
   ============================================================ */

/* ── 1. Bigger Text — 3 niveles ─────────────────────────────── */
body.a11y-bigger-text-1 p, body.a11y-bigger-text-1 li,
body.a11y-bigger-text-1 .faq-title, body.a11y-bigger-text-1 .faq-answer p,
body.a11y-bigger-text-1 label, body.a11y-bigger-text-1 input,
body.a11y-bigger-text-1 textarea { font-size: 1.15em !important; line-height: 1.65 !important; }

body.a11y-bigger-text-2 p, body.a11y-bigger-text-2 li,
body.a11y-bigger-text-2 .faq-title, body.a11y-bigger-text-2 .faq-answer p,
body.a11y-bigger-text-2 label, body.a11y-bigger-text-2 input,
body.a11y-bigger-text-2 textarea { font-size: 1.3em !important; line-height: 1.75 !important; }

body.a11y-bigger-text-3 p, body.a11y-bigger-text-3 li,
body.a11y-bigger-text-3 .faq-title, body.a11y-bigger-text-3 .faq-answer p,
body.a11y-bigger-text-3 label, body.a11y-bigger-text-3 input,
body.a11y-bigger-text-3 textarea { font-size: 1.5em !important; line-height: 1.9 !important; }

/* ── 2. Highlight Links — 2 niveles ─────────────────────────── */
body.a11y-highlight-links-1 a:not(.a11y-btn) {
    background: rgba(255,235,59,0.22) !important;
    text-decoration: underline !important;
    border-radius: 3px; padding: 0 2px;
}
body.a11y-highlight-links-2 a:not(.a11y-btn) {
    background: #ffeb3b !important; color: #000 !important;
    text-decoration: underline !important;
    border-radius: 3px; padding: 0 2px;
    outline: 2px solid #f57f17;
}

/* ── 3. Text Spacing — 3 niveles ────────────────────────────── */
body.a11y-text-spacing-1 p, body.a11y-text-spacing-1 li,
body.a11y-text-spacing-1 .faq-title, body.a11y-text-spacing-1 .faq-answer p {
    letter-spacing: 0.06em !important; word-spacing: 0.08em !important; line-height: 1.6 !important;
}
body.a11y-text-spacing-2 p, body.a11y-text-spacing-2 li,
body.a11y-text-spacing-2 .faq-title, body.a11y-text-spacing-2 .faq-answer p {
    letter-spacing: 0.12em !important; word-spacing: 0.16em !important; line-height: 1.8 !important;
}
body.a11y-text-spacing-3 p, body.a11y-text-spacing-3 li,
body.a11y-text-spacing-3 .faq-title, body.a11y-text-spacing-3 .faq-answer p {
    letter-spacing: 0.2em !important; word-spacing: 0.25em !important; line-height: 2.1 !important;
}

/* ── 4. Saturation — 6 niveles ──────────────────────────────── */
/*
   Via body::before para no romper position:fixed.
   Stages 1-3: saturación reducida → B&N
   Stages 4-6: saturación aumentada → hypersaturado

   backdrop-filter: saturate() valores:
     1.0 = normal
     < 1 = desaturado
     0   = escala de grises
     > 1 = supersaturado
*/
body.a11y-saturation-1::before,
body.a11y-saturation-2::before,
body.a11y-saturation-3::before,
body.a11y-saturation-4::before,
body.a11y-saturation-5::before,
body.a11y-saturation-6::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 99990;
    pointer-events: none;
}

/* Baja saturación */
body.a11y-saturation-1::before {
    backdrop-filter: saturate(0.55);
    -webkit-backdrop-filter: saturate(0.55);
}
body.a11y-saturation-2::before {
    backdrop-filter: saturate(0.2);
    -webkit-backdrop-filter: saturate(0.2);
}
/* Escala de grises completa */
body.a11y-saturation-3::before {
    backdrop-filter: saturate(0) brightness(1.05);
    -webkit-backdrop-filter: saturate(0) brightness(1.05);
}
/* Alta saturación */
body.a11y-saturation-4::before {
    backdrop-filter: saturate(1.8);
    -webkit-backdrop-filter: saturate(1.8);
}
body.a11y-saturation-5::before {
    backdrop-filter: saturate(3);
    -webkit-backdrop-filter: saturate(3);
}
/* Hypersaturado */
body.a11y-saturation-6::before {
    backdrop-filter: saturate(6) contrast(1.1);
    -webkit-backdrop-filter: saturate(6) contrast(1.1);
}

/* ── 5. Big Cursor — 1 nivel ────────────────────────────────── */
body.a11y-big-cursor-1,
body.a11y-big-cursor-1 *:not(.cursor-container *):not(.dynamic-video-wrapper *) {
    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='M7 3l26 15-10 3-6 11z' fill='white' stroke='black' stroke-width='1.8'/%3E%3C/svg%3E") 7 3, auto !important;
}

/* ── 6. Reading Mask — 1 nivel ──────────────────────────────── */
/*
   3 elementos separados para poder aplicar backdrop-filter: blur()
   en las franjas oscuras. Un solo elemento con gradiente no permite
   blur parcial — backdrop-filter necesita su propio elemento con área.

   #a11y-reading-mask        → contenedor (solo posicionamiento)
   #a11y-mask-top            → franja superior oscura + blur
   #a11y-mask-bottom         → franja inferior oscura + blur
   (el hueco entre top y bottom es la zona visible — sin elemento)
*/
#a11y-reading-mask {
    position: fixed;
    inset: 0;
    z-index: 99991;
    pointer-events: none;
    display: none;
}
body.a11y-reading-mask-1 #a11y-reading-mask { display: block; }

#a11y-mask-top,
#a11y-mask-bottom {
    /* Posición y tamaño los establece GSAP en ensureMaskEls() */
    pointer-events: none;
    z-index: 99991;
    /* Fondo semitransparente + blur sobre el contenido */
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    /* display y transforms los gestiona GSAP — no definir aquí */
}
body.a11y-reading-mask-1 #a11y-mask-top,
body.a11y-reading-mask-1 #a11y-mask-bottom { /* display gestionado por GSAP */ }

/* ── 7. Dyslexia — 2 niveles ────────────────────────────────── */
@font-face {
    font-family: 'OpenDyslexic';
    src: url('https://cdn.jsdelivr.net/npm/open-dyslexic@1.0.3/ttf/OpenDyslexic-Regular.ttf') format('truetype');
    font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'OpenDyslexic';
    src: url('https://cdn.jsdelivr.net/npm/open-dyslexic@1.0.3/ttf/OpenDyslexic-Bold.ttf') format('truetype');
    font-weight: 700; font-style: normal; font-display: swap;
}
body.a11y-dyslexia-1 p, body.a11y-dyslexia-1 li,
body.a11y-dyslexia-1 .faq-title, body.a11y-dyslexia-1 .faq-answer p,
body.a11y-dyslexia-1 .content-text {
    letter-spacing: 0.05em !important; word-spacing: 0.15em !important; line-height: 1.9 !important;
}
body.a11y-dyslexia-2 p, body.a11y-dyslexia-2 li,
body.a11y-dyslexia-2 .faq-title, body.a11y-dyslexia-2 .faq-answer p,
body.a11y-dyslexia-2 .content-text, body.a11y-dyslexia-2 label,
body.a11y-dyslexia-2 input, body.a11y-dyslexia-2 textarea {
    font-family: 'OpenDyslexic', sans-serif !important;
    letter-spacing: 0.05em !important; word-spacing: 0.15em !important; line-height: 1.9 !important;
}

/* ── Focus visible global (WCAG 2.1 AA) ────────────────────── */
*:focus-visible {
    outline: 3px solid #e83b2e !important;
    outline-offset: 3px !important;
}