/* =====================================================
   Modo accesibilidad / dislexia — PsicoPro Selección
   Fuente: extraído de web/enfermeria.html (inline → módulo)
   Regla: las clases solo aplican bajo body.a11y-* (opt-in)
   ===================================================== */

/* Fuente Atkinson Hyperlegible — cargada por a11y-dyslexia.js */

/* --- Fondo crema: reduce deslumbramiento --- */
body.a11y-cream { background-color: #FFFDD0 !important; }
body.a11y-cream section.bg-white { background-color: #FFFDD0 !important; }

/* Cards glassmorphism dentro del hero: texto oscuro cuando bg crema los ilumina */
body.a11y-cream [class*="gradient"] .bg-white.bg-opacity-10,
body.a11y-cream [class*="gradient"] .bg-white.bg-opacity-10 * {
    color: #1f2937 !important;
}

/* --- Fuente Atkinson Hyperlegible + interlineado + letter-spacing --- */
body.a11y-font,
body.a11y-font * {
    font-family: 'Atkinson Hyperlegible', sans-serif !important;
    line-height: 1.8 !important;
    letter-spacing: 0.12em !important;
}

/* Móvil: reducir letter-spacing para evitar texto apretado en pantallas estrechas
   (hallazgo prueba viabilidad 14-jun-2026: iPhone 390px, texto rozaba el borde) */
@media (max-width: 430px) {
    body.a11y-font,
    body.a11y-font * {
        letter-spacing: 0.06em !important;
    }
}

/* --- Texto ampliado +15% --- */
body.text-large { font-size: 115%; }

/* El panel de accesibilidad se mantiene compacto aunque el modo esté activo */
body.a11y-font #a11y-toggle,
body.a11y-font #a11y-toggle * {
    letter-spacing: normal !important;
    line-height: 1.4 !important;
}

/* --- Botón TTS dentro de tarjetas de temario --- */
.tts-btn {
    transition: transform 0.2s ease, background-color 0.2s ease;
}
.tts-btn:hover { transform: scale(1.1); }
.tts-btn.speaking {
    background-color: #ef4444 !important;
    color: #ffffff !important;
    animation: pulse-tts 1.2s ease-in-out infinite;
}
@keyframes pulse-tts {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.6; }
}

/* --- Botón accesibilidad por encima del asistente IA (evita solapamiento) --- */
/* El bot ProSelección IA vive en bottom-8 (~32px) + alto h-16 (~64px) + badge.
   Subimos el botón de accesibilidad a ~7rem desde abajo para que quede LIBRE encima.
   !important para ganar a las clases utility de Tailwind sin depender del timing. */
/* Encima de la barra fija de test.html (#test-footer ~74px con «Siguiente»). */
#a11y-toggle.a11y-above-footer {
    bottom: 6rem !important;   /* ~96px, despejado de la barra */
    right: 1.5rem !important;
    z-index: 50 !important;    /* por encima de la barra (z-40) */
}

#a11y-toggle.a11y-above-ai {
    bottom: 7rem !important;   /* ~112px, despejado del bot */
    right: 1.5rem !important;
    z-index: 60 !important;    /* por encima del bot (z-50) */
}

/* =====================================================================
   Botón ♿ (18-oct-2026, auditoría visual punto 2)
   - Posición propia: se colocaba con clases de Tailwind (fixed bottom-6 right-6) y en las
     páginas cuyo CSS no las trae (material de estudio) quedaba a media pantalla.
   - Teléfono: círculo de 44 px pegado al borde (como en el panel y el simulacro) y hueco al
     final de la página (#pp-hueco-flotantes, a11y-dyslexia.js) para que lo último no quede debajo.
   - Ordenador: con el asistente IA abierto se esconde (tapaba «enviar»); al cerrarlo vuelve.
   ===================================================================== */
#a11y-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 40;
}
#pp-hueco-flotantes { display: none; }
/* Páginas con WhatsApp flotante (web/tmb, mossos, enfermeria…): ♿ justo encima, no en la misma esquina */
html.pp-con-whatsapp:not(.pp-wa-enlinea) #a11y-toggle:not(.a11y-above-ai):not(.a11y-above-footer) {
    bottom: calc(1.5rem + 60px + 12px);
}
@media (max-width: 640px) {
    #a11y-toggle,
    #a11y-toggle.a11y-above-ai,
    #a11y-toggle.a11y-above-footer {
        right: 4px !important;
    }
    #a11y-toggle:not(.a11y-above-ai):not(.a11y-above-footer) {
        bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    }
    #a11y-toggle [data-a11y-open] {
        width: 44px !important;
        height: 44px !important;
        min-height: 44px !important;
        padding: 0 !important;
        border-radius: 9999px !important;
        font-size: 1.25rem !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    html.pp-con-whatsapp:not(.pp-wa-enlinea) #a11y-toggle:not(.a11y-above-ai):not(.a11y-above-footer) {
        bottom: calc(12px + 48px + 8px + env(safe-area-inset-bottom, 0px)) !important;
    }
    #pp-hueco-flotantes { display: block; height: 120px; }
    html:not(.pp-con-whatsapp) #pp-hueco-flotantes { height: 72px; }
    body:has(#test-footer) #pp-hueco-flotantes { display: none; }
}
@media (min-width: 641px) {
    /* Con el chat abierto se esconde (apartado tapaba tarjetas del panel); al cerrarlo vuelve */
    html:has(#ai-chat-window:not(.hidden)) #a11y-toggle {
        display: none !important;
    }
}
