/* ==========================================================================
   Acessibilidade (LBI 13.146/2015 / eMAG)
   Estado em classes no <html>, definidas por static/js/acessibilidade.js.
   ========================================================================== */

/* --- Escala de fonte ------------------------------------------------------
   Todo font-size em px do projeto usa calc(Npx * var(--a11y-escala, 1)) e o
   html (site.css) tambem, entao tudo em rem escala junto. Com o fator em 1 o
   site normal nao muda um pixel. */
:root { --a11y-escala: 1; }
:root.fonte-maior { --a11y-escala: 1.18; }
:root.fonte-menor { --a11y-escala: 0.9; }

/* --- Utilitarios ---------------------------------------------------------- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Foco visivel em todo controle (WCAG 2.4.7). Especificidade zero: qualquer
   componente pode sobrescrever. Anel duplo para ler sobre fundo claro e escuro. */
:where(a, button, summary, input, select, textarea, [tabindex]):focus-visible {
    outline: 3px solid #3b429f;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px #fff;
}

.a11y-skip {
    position: fixed;
    top: -100px;
    left: 8px;
    z-index: 100000;
    padding: 12px 20px;
    background: #fff;
    color: #1d1f4f;
    font-weight: 700;
    border: 2px solid #3b429f;
    border-radius: 8px;
}
.a11y-skip:focus { top: 8px; color: #1d1f4f; }

/* Alvo do skip link: so recebe foco por script, nao e controle. */
#conteudo:focus { outline: none; box-shadow: none; }

/* --- Widget --------------------------------------------------------------- */
.a11y-widget,
.a11y-widget * {
    box-sizing: border-box;
    letter-spacing: normal;
    font-family: 'Din', sans-serif;
}

.a11y-toggle {
    position: fixed;
    /* Direita, um pouco abaixo do centro: o centro e do VLibras. */
    top: 60%;
    right: 0;
    z-index: 10000;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    background: #3b429f;
    color: #fff;
    border: 0;
    border-radius: 12px 0 0 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
    cursor: pointer;
}
.a11y-toggle:hover { background: #2d3380; }

/* Clique de mouse nao mostra anel (o Bootstrap poe outline em button:focus);
   o foco por teclado segue com o anel de :focus-visible. */
.a11y-widget button:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}

.a11y-painel {
    position: fixed;
    top: 50%;
    right: 56px;
    z-index: 10000;
    transform: translateY(-50%);
    width: min(300px, calc(100vw - 68px));
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    padding: 16px;
    background: #fff;
    color: #1d1f4f;
    border: 2px solid #3b429f;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
    font-size: 16px;
    line-height: 1.3;
}
/* O atributo hidden perde para qualquer display declarado; garante que saia
   da tela e da ordem de tabulacao mesmo assim. */
.a11y-painel[hidden] { display: none; }

.a11y-titulo {
    margin: 0 0 12px;
    font-size: 18px !important;
    font-weight: 700;
    color: #1d1f4f;
}

.a11y-grupo { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.a11y-rotulo { font-size: 14px; font-weight: 700; }
.a11y-linha { display: flex; gap: 8px; }

.a11y-btn,
.a11y-opcao {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 12px;
    background: #fff;
    color: #1d1f4f;
    border: 2px solid #3b429f;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
}
.a11y-btn { flex: 1; font-size: 18px; }
.a11y-opcao { width: 100%; }
.a11y-btn:hover,
.a11y-opcao:hover { background: #e8eaf8; }

/* Ligado: preenchido e com marca, para nao depender so da cor. */
.a11y-btn[aria-pressed="true"],
.a11y-opcao[aria-pressed="true"] {
    background: #3b429f;
    color: #fff;
}
.a11y-opcao[aria-pressed="true"]::before {
    content: "\2713";
    content: "\2713" / "";
}

.a11y-restaurar { border-style: dashed; }

.a11y-declaracao {
    display: block;
    margin-top: 12px;
    color: #1d1f4f;
    text-align: center;
    text-decoration: underline;
}
.a11y-declaracao:hover { color: #3b429f; }

@media print { .a11y-widget, .a11y-skip { display: none !important; } }

/* --- Parar animacoes -------------------------------------------------------
   Duracao quase zero e uma iteracao em vez de "none": o elemento chega ao
   estado final do keyframe em vez de ficar preso no inicial (por ex. opacity 0).
   O JS (acessibilidade.js) cuida do que CSS nao alcanca: video e Owl autoplay. */
html.sem-animacoes *,
html.sem-animacoes *::before,
html.sem-animacoes *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
}

/* Independe do widget: quem ja pediu menos movimento no sistema nao precisa clicar. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-delay: 0s !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        transition-delay: 0s !important;
        scroll-behavior: auto !important;
    }
}

/* --- Alto contraste --------------------------------------------------------
   O widget e o VLibras ([vw]) ficam de fora: ja tem contraste proprio.
   :where() mantem a especificidade baixa; as regras de link vem depois e
   vencem por terem mais um seletor de tipo. */
html.alto-contraste,
html.alto-contraste body {
    background: #fff !important;
    color: #000 !important;
}
html.alto-contraste :where(body *):not(.a11y-widget, .a11y-widget *, [vw], [vw] *) {
    background-color: #fff !important;
    color: #000 !important;
    border-color: #000 !important;
    text-shadow: none !important;
    box-shadow: none !important;
}
html.alto-contraste :where(body *):not(.a11y-widget, .a11y-widget *, [vw], [vw] *, .navbar-toggler-icon) {
    background-image: none !important;
}
/* Sobreposicoes decorativas (::before/::after) nao podem tapar o conteudo. */
html.alto-contraste :where(body *):not(.a11y-widget, .a11y-widget *, [vw], [vw] *)::before,
html.alto-contraste :where(body *):not(.a11y-widget, .a11y-widget *, [vw], [vw] *)::after {
    background-color: transparent !important;
    text-shadow: none !important;
    box-shadow: none !important;
}
html.alto-contraste a:not(.a11y-widget *, [vw], [vw] *),
html.alto-contraste a *:not(.a11y-widget *, [vw], [vw] *) {
    color: #0000b8 !important;
    text-decoration: underline !important;
}
html.alto-contraste :where(button, .btn, input, select, textarea):not(.a11y-widget *, [vw], [vw] *) {
    border: 2px solid #000 !important;
}
html.alto-contraste a svg:not(.a11y-widget *, [vw], [vw] *),
html.alto-contraste a svg *:not(.a11y-widget *, [vw], [vw] *),
html.alto-contraste button svg:not(.a11y-widget *, [vw], [vw] *),
html.alto-contraste button svg *:not(.a11y-widget *, [vw], [vw] *) {
    fill: currentColor !important;
}
/* O hamburger e desenhado em branco; no claro vira preto. */
html.alto-contraste .navbar-toggler-icon { filter: invert(1); }
/* Video decorativo atras de texto: esmaece para o texto ler. */
html.alto-contraste video[autoplay] { opacity: .25 !important; }

/* Alto contraste escuro */
html.alto-contraste-escuro,
html.alto-contraste-escuro body {
    background: #000 !important;
    color: #fff !important;
}
html.alto-contraste-escuro :where(body *):not(.a11y-widget, .a11y-widget *, [vw], [vw] *) {
    background-color: #000 !important;
    color: #fff !important;
    border-color: #fff !important;
    text-shadow: none !important;
    box-shadow: none !important;
}
html.alto-contraste-escuro :where(body *):not(.a11y-widget, .a11y-widget *, [vw], [vw] *, .navbar-toggler-icon) {
    background-image: none !important;
}
html.alto-contraste-escuro :where(body *):not(.a11y-widget, .a11y-widget *, [vw], [vw] *)::before,
html.alto-contraste-escuro :where(body *):not(.a11y-widget, .a11y-widget *, [vw], [vw] *)::after {
    background-color: transparent !important;
    text-shadow: none !important;
    box-shadow: none !important;
}
html.alto-contraste-escuro a:not(.a11y-widget *, [vw], [vw] *),
html.alto-contraste-escuro a *:not(.a11y-widget *, [vw], [vw] *) {
    color: #ffff00 !important;
    text-decoration: underline !important;
}
html.alto-contraste-escuro :where(button, .btn, input, select, textarea):not(.a11y-widget *, [vw], [vw] *) {
    border: 2px solid #fff !important;
}
html.alto-contraste-escuro a svg:not(.a11y-widget *, [vw], [vw] *),
html.alto-contraste-escuro a svg *:not(.a11y-widget *, [vw], [vw] *),
html.alto-contraste-escuro button svg:not(.a11y-widget *, [vw], [vw] *),
html.alto-contraste-escuro button svg *:not(.a11y-widget *, [vw], [vw] *) {
    fill: currentColor !important;
}
/* Setas desenhadas em cinza escuro (acordeao do FAQ) somem no preto. */
html.alto-contraste-escuro .accordion-button::after { filter: invert(1); }
html.alto-contraste-escuro video[autoplay] { opacity: .25 !important; }

/* --- Destacar links --------------------------------------------------------
   Depois dos contrastes: com os dois ligados, o destaque prevalece. */
html.destacar-links a:not(.a11y-widget *, [vw], [vw] *),
html.destacar-links a *:not(.a11y-widget *, [vw], [vw] *) {
    text-decoration: underline !important;
    text-decoration-thickness: .12em !important;
    text-underline-offset: .2em;
}
html.destacar-links a:not(.a11y-widget *, [vw], [vw] *) {
    background-color: #fff2a8 !important;
    color: #000 !important;
    outline: 2px solid #000;
    outline-offset: 1px;
}
html.destacar-links a *:not(.a11y-widget *, [vw], [vw] *) { color: #000 !important; }
