/*
 * Capa transversal de accesibilidad del portal municipal.
 * Se habilita gradualmente por módulo desde los encabezados compartidos.
 */

.a11y-skip-link {
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 10000;
    padding: 0.75rem 1rem;
    border: 2px solid #ffffff;
    border-radius: 0.75rem;
    background: #123f55;
    color: #ffffff;
    font-weight: 800;
    text-decoration: none;
    transform: translateY(-160%);
    transition: transform 120ms ease-in-out;
}

.a11y-skip-link:focus {
    transform: translateY(0);
}

.a11y-page :is(a, button, input, select, textarea, summary):focus-visible {
    outline: 3px solid #f59e0b !important;
    outline-offset: 3px !important;
    box-shadow: none !important;
}

.a11y-page :is(button, select, summary, a[class*="rounded"]):not(.a11y-compact-control) {
    min-height: 44px;
}

.a11y-page button:disabled,
.a11y-page select:disabled,
.a11y-page input:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.a11y-page [role="alert"],
.a11y-page [role="status"] {
    overflow-wrap: anywhere;
}

/*
 * El cambio de tamaño debe conservar todo el contenido sin recortes. Los
 * módulos pueden usar los estados enlarged y maximum para reordenar sus grillas.
 */
html[data-a11y-text-scale] .a11y-page {
    overflow-wrap: anywhere;
}

html.a11y-text-enlarged .a11y-page :is(img, video, iframe, canvas, svg) {
    max-width: 100%;
}

.a11y-page table caption {
    color: #334155;
    font-weight: 700;
    text-align: left;
}

.a11y-page nav ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

/*
 * El shell conserva el mismo ancho en dashboard, listados y formularios.
 * En pantallas de captura se limita sólo el formulario interior.
 */
.a11y-page--staff > :is(main, [role="region"]) {
    width: 100%;
    max-width: 1500px !important;
}

.a11y-page--staff .a11y-form-content {
    width: 100%;
    max-width: 64rem;
    margin-right: auto;
    margin-left: auto;
}

.a11y-page abbr[title="Campo obligatorio"] {
    color: #b91c1c;
    text-decoration: none;
}

/*
 * Herramientas voluntarias. Complementan el zoom y las ayudas técnicas del
 * navegador; no sustituyen el marcado semántico ni las pruebas WCAG.
 */
.a11y-tools {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1090;
    color: #0f172a;
    font-size: 1rem;
    line-height: 1.4;
}

.a11y-tools__toggle,
.a11y-tools__action,
.a11y-tools__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 2px solid #123f55;
    border-radius: 0.75rem;
    background: #ffffff;
    color: #123f55;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.a11y-tools__toggle {
    gap: 0.5rem;
    padding: 0.65rem 0.9rem;
    box-shadow: 0 10px 30px rgb(15 23 42 / 22%);
}

.a11y-tools__toggle:hover,
.a11y-tools__action:hover,
.a11y-tools__action.is-active {
    background: #123f55;
    color: #ffffff;
}

.a11y-tools :is(button):focus-visible {
    outline: 3px solid #f59e0b !important;
    outline-offset: 3px !important;
}

.a11y-tools__panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 0.75rem);
    box-sizing: border-box;
    width: min(21rem, calc(100vw - 1.5rem));
    max-height: min(34rem, calc(100vh - 6rem));
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    border: 2px solid #cbd5e1;
    border-radius: 1rem;
    background: #ffffff;
    box-shadow: 0 20px 45px rgb(15 23 42 / 28%);
}

.a11y-tools__panel[hidden] {
    display: none;
}

.a11y-tools__heading {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    font-size: 1.125rem;
}

.a11y-tools__close {
    width: 44px;
    padding: 0;
    border-color: transparent;
}

.a11y-tools__hint {
    margin: 0.5rem 0;
}

.a11y-tools__hint {
    color: #475569;
}

.a11y-tools__status {
    margin: 0.75rem 0 0;
    color: #334155;
    font-weight: 700;
}

.a11y-tools__status:empty {
    display: none;
}

.a11y-tools__actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 4rem minmax(0, 1fr);
    gap: 0.5rem;
}

.a11y-tools__action {
    width: 100%;
    min-width: 0;
    gap: 0.5rem;
    justify-content: flex-start;
    padding: 0.6rem 0.75rem;
    text-align: left;
}

.a11y-tools__action > span:last-child {
    min-width: 0;
    overflow-wrap: anywhere;
}

.a11y-tools__action[data-a11y-action="text-decrease"],
.a11y-tools__action[data-a11y-action="text-increase"] {
    justify-content: center;
    padding-right: 0.5rem;
    padding-left: 0.5rem;
}

.a11y-tools__action[data-a11y-action="contrast"],
.a11y-tools__action[data-a11y-action="speech"],
.a11y-tools__action[data-a11y-action="reset"] {
    grid-column: 1 / -1;
}

.a11y-tools__scale {
    display: inline-flex;
    min-width: 4rem;
    align-items: center;
    justify-content: center;
    color: #0f172a;
    font-weight: 800;
}

/*
 * OIRS público ya utiliza la esquina inferior derecha para el chatbot.
 * La herramienta conserva su componente común y cambia sólo de anclaje.
 */
body[data-a11y-portal="public"][data-a11y-module="oirs"] .a11y-tools {
    right: auto;
    left: 1rem;
}

body[data-a11y-portal="public"][data-a11y-module="oirs"] .a11y-tools__panel {
    right: auto;
    left: 0;
}

/* Paleta de contraste reforzado sin invertir fotografías, mapas ni logotipos. */
html.a11y-high-contrast {
    color-scheme: dark;
}

html.a11y-high-contrast body,
html.a11y-high-contrast .a11y-page,
html.a11y-high-contrast .a11y-page :is(section, article, aside, header, footer, nav, div, form, table, thead, tbody, tr, th, td, ul, ol, li) {
    border-color: #ffffff !important;
    background-color: #000000 !important;
    color: #ffffff !important;
    background-image: none !important;
}

html.a11y-high-contrast .a11y-page :is(h1, h2, h3, h4, h5, h6, p, span, label, legend, strong, small, caption) {
    color: #ffffff !important;
}

html.a11y-high-contrast .a11y-page a {
    color: #ffff00 !important;
    text-decoration: underline !important;
    text-decoration-thickness: 0.12em !important;
}

html.a11y-high-contrast .a11y-page :is(input, select, textarea) {
    border: 2px solid #ffffff !important;
    background: #000000 !important;
    color: #ffffff !important;
}

html.a11y-high-contrast .a11y-page :is(button, [role="button"]),
html.a11y-high-contrast .a11y-tools :is(button) {
    border: 2px solid #ffff00 !important;
    background: #000000 !important;
    color: #ffff00 !important;
}

html.a11y-high-contrast .a11y-tools__panel,
html.a11y-high-contrast .a11y-tools__panel * {
    border-color: #ffffff !important;
    background-color: #000000 !important;
    color: #ffffff !important;
}

html.a11y-high-contrast .a11y-tools__action.is-active {
    background: #ffff00 !important;
    color: #000000 !important;
}

@media (max-width: 640px) {
    .a11y-tools {
        right: 0.75rem;
        bottom: 0.75rem;
    }

    .a11y-tools__toggle > span:last-child {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }

    body[data-a11y-portal="public"][data-a11y-module="oirs"] .a11y-tools {
        left: 0.75rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .a11y-page *,
    .a11y-page *::before,
    .a11y-page *::after,
    .a11y-skip-link {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

@media (forced-colors: active) {
    .a11y-page :is(a, button, input, select, textarea, summary):focus-visible {
        outline-color: Highlight !important;
    }
}
