/*! Softme.Accesibilidad | (c) Softme | MIT */
/* =====================================================================
   Menú de accesibilidad de Softme
   - Correcciones siempre activas (saltar al contenido, foco visible, movimiento reducido)
   - Estilos del menú (pestaña lateral y panel en lista con interruptores)
   - Ajustes que elige el visitante: clases "a11y-*" en <html>

   Diseño de cada web: cambia las variables en su propio CSS, p. ej.
     :root { --a11y-acento: #001e7b; --a11y-franja-v: linear-gradient(...); }
   ===================================================================== */

:where(:root) {
    --a11y-acento: #1d3f8f;          /* color principal: pestaña, títulos, botones, interruptores */
    --a11y-acento-suave: #e9edf8;    /* fondos de iconos y filas al pasar el ratón */
    --a11y-sobre-acento: #fff;       /* texto sobre el color principal */
    --a11y-texto: #1d2433;
    --a11y-gris: #5a6268;
    --a11y-borde: #d6dbe8;
    --a11y-fondo: #fff;
    --a11y-fondo-pie: #f7f8fb;
    --a11y-foco: #ffbf47;            /* anillo de foco con teclado */
    --a11y-franja-v: var(--a11y-acento);  /* franja vertical de la pestaña */
    --a11y-franja-h: var(--a11y-acento);  /* franja horizontal del panel */
    --a11y-fuente: Arial, Helvetica, sans-serif;
    --a11y-fuente-legible: Verdana, Tahoma, Arial, Helvetica, sans-serif;
    --a11y-capa: 2147483647;         /* el máximo: con el mismo z-index gana el widget, que va al final del body */
}

/* ---------- Utilidades ---------- */
.a11y-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.a11y-icono {
    display: inline-block;
    flex: none;
    width: 1em;
    height: 1em;
    vertical-align: middle;
}

[data-a11y-oculto] {
    display: none !important;
}

/* ---------- Correcciones (siempre activas) ---------- */

/* Enlace "Saltar al contenido principal" (WCAG 2.4.1) */
.a11y-saltar {
    position: absolute;
    top: -100px;
    left: 16px;
    z-index: 2147483647;
    padding: 12px 20px;
    background: var(--a11y-acento);
    color: var(--a11y-sobre-acento) !important;
    font: 600 16px/1.2 var(--a11y-fuente);
    border-radius: 0 0 6px 6px;
    text-decoration: underline;
    transition: none !important;
}

.a11y-saltar:focus {
    top: 0;
    outline: 3px solid var(--a11y-foco);
    outline-offset: 0;
}

.a11y-destino:focus,
.a11y-destino:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

/* Foco visible con teclado (WCAG 2.4.7) */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--a11y-foco) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 5px var(--a11y-acento) !important;
}

/* Preferencia del sistema operativo "reducir movimiento" (WCAG 2.3.3) */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* Zoom al 400 % / pantallas de 320 px sin desplazamiento horizontal (WCAG 1.4.10).
   Solo en pantallas muy estrechas: se reducen los márgenes interiores grandes de Bootstrap,
   se parten las palabras largas y las tablas se desplazan dentro de su caja. */
@media (max-width: 400px) {
    html.a11y-reflow .p-5 { padding: 1rem !important; }
    html.a11y-reflow .px-5 { padding-left: 1rem !important; padding-right: 1rem !important; }
    html.a11y-reflow .pl-5, html.a11y-reflow .ps-5 { padding-left: 1rem !important; }
    html.a11y-reflow .pr-5, html.a11y-reflow .pe-5 { padding-right: 1rem !important; }

    html.a11y-reflow :is(main, [role="main"]) :is(p, li, a, h1, h2, h3, h4, h5, h6, td, th) {
        overflow-wrap: break-word;
        word-wrap: break-word;
    }

    html.a11y-reflow :is(main, [role="main"]) table {
        display: block !important;
        max-width: 100%;
        overflow-x: auto;
    }

    /* Elementos flexibles que no encogen por debajo de su contenido */
    html.a11y-reflow :is(main, [role="main"]) :is(.d-flex, .row) > * {
        min-width: 0;
    }

    /* Filas de Bootstrap fuera de un .container: sus márgenes negativos desbordan la pantalla */
    html.a11y-reflow :is(main, [role="main"]) .row:not(.m-0):not(.g-0) {
        margin-left: 0;
        margin-right: 0;
    }

    /* Contenido incrustado de terceros (Facebook, Twitter, Instagram...) con ancho fijo */
    html.a11y-reflow :is(main, [role="main"]) :is(.fb-page, .fb-page span, .fb-page iframe) {
        min-width: 0 !important;
        max-width: 100% !important;
    }

    html.a11y-reflow :is(main, [role="main"]) :is(iframe, embed, video) {
        max-width: 100% !important;
    }
}

/* Submenú cerrado con Esc (WCAG 1.4.13); se vuelve a abrir al salir y volver a entrar */
.a11y-submenu-oculto {
    display: none !important; /* display y no visibility: algunos hijos llevan visibility:visible en línea (WOW) */
}

/* Botón de pausa de los carruseles (lo añade el JS) */
.a11y-pausa {
    position: absolute;
    right: 16px;
    bottom: 16px;
    z-index: 20;
    width: 44px;
    height: 44px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--a11y-acento);
    color: var(--a11y-sobre-acento);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: .92;
}

.a11y-pausa:hover {
    opacity: 1;
}

/* ---------- Menú de accesibilidad ---------- */
.a11y-widget {
    font-family: var(--a11y-fuente);
    font-size: 16px;
    line-height: 1.4;
}

/* Pestaña lateral */
.a11y-toggle {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: var(--a11y-capa);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 10px 14px 10px 16px;
    border: 0;
    border-radius: 0 10px 10px 0;
    background: var(--a11y-fondo);
    color: var(--a11y-acento);
    font: 700 15px/1 var(--a11y-fuente);
    box-shadow: 0 3px 12px rgba(0, 0, 0, .28);
    cursor: pointer;
}

.a11y-toggle::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background: var(--a11y-franja-v);
}

.a11y-toggle > .a11y-icono {
    font-size: 24px;
}

.a11y-toggle:hover,
.a11y-toggle[aria-expanded="true"] {
    background: var(--a11y-acento);
    color: var(--a11y-sobre-acento);
}

/* Panel junto a la pestaña */
.a11y-panel {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: var(--a11y-capa);
    width: 380px;
    max-width: calc(100vw - 16px);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    background: var(--a11y-fondo);
    color: var(--a11y-texto);
    border-radius: 0 12px 12px 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
    overflow: hidden;
    text-align: left;
}

.a11y-panel::before {
    content: "";
    display: block;
    flex: 0 0 6px;
    background: var(--a11y-franja-h);
}

.a11y-panel[hidden] {
    display: none;
}

/* Pestaña y panel a la derecha */
.a11y-widget--derecha .a11y-toggle {
    left: auto;
    right: 0;
    padding: 10px 16px 10px 14px;
    border-radius: 10px 0 0 10px;
}

.a11y-widget--derecha .a11y-toggle::before {
    left: auto;
    right: 0;
}

.a11y-widget--derecha .a11y-panel {
    left: auto;
    right: 0;
    border-radius: 12px 0 0 12px;
}

.a11y-panel-cabecera {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--a11y-borde);
}

.a11y-panel-titulo {
    margin: 0 0 4px !important;
    padding: 0 !important;
    color: var(--a11y-acento) !important;
    font: 700 21px/1.2 var(--a11y-fuente) !important;
    text-transform: none !important;
}

.a11y-panel-subtitulo {
    margin: 0 !important;
    color: var(--a11y-gris);
    font-size: 14px;
}

.a11y-cerrar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 8px 12px;
    border: 2px solid var(--a11y-acento);
    border-radius: 999px;
    background: var(--a11y-fondo);
    color: var(--a11y-acento);
    font: 700 14px/1 var(--a11y-fuente);
    cursor: pointer;
}

.a11y-cerrar:hover {
    background: var(--a11y-acento);
    color: var(--a11y-sobre-acento);
}

.a11y-panel-cuerpo {
    padding: 4px 16px 12px;
    overflow-y: auto;
}

.a11y-grupo-titulo {
    margin: 14px 0 4px !important;
    padding: 0 0 4px !important;
    border-bottom: 2px solid var(--a11y-acento-suave);
    color: var(--a11y-gris) !important;
    font: 700 13px/1.2 var(--a11y-fuente) !important;
    text-transform: uppercase;
    letter-spacing: .06em !important;
}

/* Filas: icono + texto + interruptor */
.a11y-lista {
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

.a11y-lista > li {
    margin: 0;
    padding: 0;
    list-style: none;
}

.a11y-lista > li::before,
.a11y-lista > li::marker {
    content: none;
}

.a11y-opcion,
.a11y-tamano {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 56px;
    margin: 0;
    padding: 8px 6px;
    border: 0;
    border-bottom: 1px solid var(--a11y-acento-suave);
    background: transparent;
    color: var(--a11y-texto);
    font: inherit;
    text-align: left;
    text-transform: none;
}

.a11y-opcion {
    cursor: pointer;
    border-radius: 6px;
}

.a11y-opcion:hover {
    background: var(--a11y-acento-suave);
}

.a11y-opcion-icono {
    flex: 0 0 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--a11y-acento-suave);
    color: var(--a11y-acento);
    font-size: 19px;
}

.a11y-opcion-texto {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.a11y-opcion-titulo {
    font-weight: 700;
    font-size: 15px;
}

.a11y-opcion-descripcion {
    color: var(--a11y-gris);
    font-size: 13px;
}

/* Interruptor (la posición del círculo indica el estado, no solo el color) */
.a11y-interruptor {
    flex: 0 0 46px;
    position: relative;
    height: 26px;
    border: 2px solid var(--a11y-gris);
    border-radius: 999px;
    background: var(--a11y-fondo);
}

.a11y-interruptor > span {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--a11y-gris);
}

.a11y-opcion[aria-pressed="true"] .a11y-interruptor {
    border-color: var(--a11y-acento);
    background: var(--a11y-acento);
}

.a11y-opcion[aria-pressed="true"] .a11y-interruptor > span {
    left: 23px;
    background: var(--a11y-sobre-acento);
}

.a11y-opcion[aria-pressed="true"] .a11y-opcion-icono {
    background: var(--a11y-acento);
    color: var(--a11y-sobre-acento);
}

/* Tamaño del texto: control de pasos */
.a11y-paso {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    border: 2px solid var(--a11y-acento);
    border-radius: 999px;
    overflow: hidden;
}

.a11y-btn-tamano {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 32px;
    margin: 0;
    padding: 0;
    border: 0;
    background: var(--a11y-fondo);
    color: var(--a11y-acento);
    font-size: 16px;
    cursor: pointer;
}

.a11y-btn-tamano:hover {
    background: var(--a11y-acento-suave);
}

.a11y-btn-tamano:disabled {
    color: #9aa1ad;
    cursor: not-allowed;
    background: var(--a11y-fondo);
}

.a11y-tamano-valor {
    min-width: 52px;
    text-align: center;
    font-weight: 700;
    font-size: 14px;
    color: var(--a11y-texto);
}

/* Pie */
.a11y-panel-pie {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--a11y-borde);
    background: var(--a11y-fondo-pie);
}

.a11y-restablecer {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 8px 14px;
    border: 2px solid var(--a11y-acento);
    border-radius: 6px;
    background: var(--a11y-fondo);
    color: var(--a11y-acento);
    font: 700 14px var(--a11y-fuente);
    cursor: pointer;
}

.a11y-restablecer:hover {
    background: var(--a11y-acento);
    color: var(--a11y-sobre-acento);
}

.a11y-declaracion {
    color: var(--a11y-acento) !important;
    font: 600 14px var(--a11y-fuente);
    text-decoration: underline !important;
    text-align: right;
}

/* El widget no se ve afectado por los ajustes de espaciado */
.a11y-widget,
.a11y-widget * {
    letter-spacing: normal !important;
    word-spacing: normal !important;
}

/* ---------- Ajustes del visitante ---------- */

/* Prioridad de las reglas: los ":not(#a11y-nX)" (ids que no existen) suben la especificidad
   por encima de las reglas !important de la web; el selector general va dentro de :where()
   para que las reglas de enlaces le ganen. */

/* Alto contraste: fondo negro, texto blanco, enlaces amarillos */
/* El fondo solo se pinta donde la web ya tenía color de fondo: los elementos transparentes
   (capas sobre imágenes, etc.) los marca el JS con data-a11y-transparente y se respetan */
html.a11y-contraste-alto:not(#a11y-n1) body :where(*:not(.a11y-widget, .a11y-widget *, [data-a11y-transparente])) {
    background-color: #000 !important;
}

html.a11y-contraste-alto:not(#a11y-n1) body :where(*:not(.a11y-widget, .a11y-widget *)) {
    color: #fff !important;
    border-color: #fff !important;
    text-shadow: none !important;
    box-shadow: none !important;
}

/* El texto siempre sobre negro, aunque esté encima de una foto */
html.a11y-contraste-alto:not(#a11y-n1) body :where(h1, h2, h3, h4, h5, h6, p, li, a, span, label, small, strong, b, em, time):not(.a11y-widget *) {
    background-color: #000 !important;
}

html.a11y-contraste-alto body,
html.a11y-contraste-alto #page {
    background: #000 !important;
}

html.a11y-contraste-alto:not(#a11y-n1):not(#a11y-n2) body a:not(.a11y-widget *),
html.a11y-contraste-alto:not(#a11y-n1):not(#a11y-n2) body a:not(.a11y-widget *) * {
    color: #ffff00 !important;
}

html.a11y-contraste-alto body *::before,
html.a11y-contraste-alto body *::after {
    background-color: transparent !important;
}

/* Fondo claro: fondo blanco, texto negro */
html.a11y-fondo-claro:not(#a11y-n1) body :where(*:not(.a11y-widget, .a11y-widget *, [data-a11y-transparente])) {
    background-color: #fff !important;
}

html.a11y-fondo-claro:not(#a11y-n1) body :where(*:not(.a11y-widget, .a11y-widget *)) {
    color: #000 !important;
    text-shadow: none !important;
}

html.a11y-fondo-claro body,
html.a11y-fondo-claro #page {
    background: #fff !important;
}

html.a11y-fondo-claro:not(#a11y-n1):not(#a11y-n2) body a:not(.a11y-widget *),
html.a11y-fondo-claro:not(#a11y-n1):not(#a11y-n2) body a:not(.a11y-widget *) * {
    color: #00137f !important;
}

html.a11y-fondo-claro body *::before,
html.a11y-fondo-claro body *::after {
    background-color: transparent !important;
}

/* Colores invertidos: el filtro va en <html> (lo pone el JS); fotos, vídeos e imágenes de fondo
   (marcadas por el JS) se vuelven a invertir para verse como son. El widget se compensa en sus
   piezas fijas y NO en su contenedor: un filtro en el contenedor haría que los elementos
   position:fixed se colocaran respecto a él (al final de la página) y no respecto a la pantalla. */
html.a11y-contraste-negativo img,
html.a11y-contraste-negativo video,
html.a11y-contraste-negativo iframe,
html.a11y-contraste-negativo [data-a11y-imagen-fondo],
html.a11y-contraste-negativo .a11y-toggle,
html.a11y-contraste-negativo .a11y-panel {
    filter: invert(1) hue-rotate(180deg);
}

/* Lo que está dentro de una imagen de fondo ya queda compensado por ella */
html.a11y-contraste-negativo [data-a11y-imagen-fondo] img,
html.a11y-contraste-negativo [data-a11y-imagen-fondo] video,
html.a11y-contraste-negativo [data-a11y-imagen-fondo] iframe,
html.a11y-contraste-negativo [data-a11y-imagen-fondo] [data-a11y-imagen-fondo] {
    filter: none;
}

/* Fuente legible (sin tocar las fuentes de iconos) */
html.a11y-fuente-legible:not(#a11y-n1) body *:not(.fa, .fas, .far, .fab, .fa-solid, .fa-regular, .fa-brands, .bi, [class^="bi-"], [class*=" bi-"], [class^="icofont"], [class*=" icofont"], .a11y-widget *) {
    font-family: var(--a11y-fuente-legible) !important;
}

/* Espaciado de texto (valores de WCAG 1.4.12) */
html.a11y-espaciado:not(#a11y-n1) body *:not(.a11y-widget):not(.a11y-widget *) {
    line-height: 1.5 !important;
    letter-spacing: .12em !important;
    word-spacing: .16em !important;
}

html.a11y-espaciado body p:not(.a11y-widget *) {
    margin-bottom: 2em !important;
}

/* Subrayar enlaces */
html.a11y-subrayar-enlaces:not(#a11y-n1) body a:not(.a11y-widget *) {
    text-decoration: underline !important;
    text-underline-offset: 3px;
}

/* Resaltar enlaces */
html.a11y-resaltar-enlaces:not(#a11y-n1):not(#a11y-n2) body a:not(.a11y-widget *) {
    outline: 2px solid var(--a11y-foco) !important;
    outline-offset: 1px;
    background-color: #fff3c4 !important;
    color: #000 !important;
    text-decoration: underline !important;
}

html.a11y-resaltar-enlaces:not(#a11y-n1):not(#a11y-n2) body a:not(.a11y-widget *) * {
    color: #000 !important;
}

/* Resaltar foco (también con ratón) */
html.a11y-resaltar-foco body *:focus {
    outline: 4px solid #ff0000 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 7px #fff !important;
}

/* Detener animaciones */
html.a11y-detener-animaciones *,
html.a11y-detener-animaciones *::before,
html.a11y-detener-animaciones *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

html.a11y-detener-animaciones .wow {
    visibility: visible !important;
}

/* Cursor grande */
html.a11y-cursor-grande,
html.a11y-cursor-grande * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'%3E%3Cpath d='M4 2l15 11.5-6.5.8 3.9 7.6-3 1.5-3.8-7.6L4 20.5z' fill='%23000' stroke='%23fff' stroke-width='1.3' stroke-linejoin='round'/%3E%3C/svg%3E") 8 4, auto !important;
}

html.a11y-cursor-grande a,
html.a11y-cursor-grande a *,
html.a11y-cursor-grande button,
html.a11y-cursor-grande button *,
html.a11y-cursor-grande [role="button"],
html.a11y-cursor-grande label {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'%3E%3Cpath d='M9 2.5a1.5 1.5 0 013 0V10l1-.2a1.5 1.5 0 011.7 1l.3-.1a1.5 1.5 0 011.8 1l.4-.1a1.5 1.5 0 011.8 1.3V17c0 3-2 5.5-5.5 5.5H12c-2 0-3.3-.8-4.3-2.3L4.3 15a1.6 1.6 0 012.5-2L9 15z' fill='%23000' stroke='%23fff' stroke-width='1.2' stroke-linejoin='round'/%3E%3C/svg%3E") 18 4, pointer !important;
}

/* Guía de lectura */
.a11y-guia {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    height: 12px;
    z-index: 2147483645;
    background: var(--a11y-acento);
    opacity: .85;
    border-top: 2px solid var(--a11y-foco);
    border-bottom: 2px solid var(--a11y-foco);
    pointer-events: none;
}

html.a11y-guia-lectura .a11y-guia {
    display: block;
}

/* ---------- Móvil: pestaña más baja y panel que sube desde abajo ---------- */
@media (max-width: 575px) {
    .a11y-toggle,
    .a11y-widget--derecha .a11y-toggle {
        top: auto;
        bottom: 84px;
        transform: none;
        padding: 9px 12px 9px 14px;
        font-size: 14px;
    }

    .a11y-panel,
    .a11y-widget--derecha .a11y-panel {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        transform: none;
        width: auto;
        max-width: none;
        max-height: 85vh;
        border-radius: 14px 14px 0 0;
    }
}

@media print {
    .a11y-widget,
    .a11y-saltar,
    .a11y-pausa {
        display: none !important;
    }
}
