/* ==========================================================================
   FUNIR - Modo de Acessibilidade e navegação por teclado
   ========================================================================== */

/* --------------------------------------------------------------------------
   Utilitários
   -------------------------------------------------------------------------- */
.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;
}

/* Compensa o cabeçalho fixo ao saltar para âncoras */
html {
    scroll-padding-top: 160px;
}

/* --------------------------------------------------------------------------
   Links de salto ("Pular para o conteúdo")
   -------------------------------------------------------------------------- */
.skip-link {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 2147483647;
    padding: 12px 20px;
    background: #ffdd00;
    color: #0b0c0c !important;
    font-weight: 700;
    font-size: 1rem;
    text-decoration: underline;
    border: 3px solid #0b0c0c;
    border-radius: 6px;
    transform: translateY(-200%);
    transition: transform 0.15s ease;
}

.skip-link:focus,
.skip-link:focus-visible {
    transform: translateY(0);
    outline: 3px solid #0b0c0c !important;
    outline-offset: 2px !important;
}

.skip-link + .skip-link:focus {
    top: 64px;
}

/* --------------------------------------------------------------------------
   Indicador de foco visível em todo o site (WCAG 2.4.7)
   Sobrescreve "outline: none" usado em estilos inline dos formulários.
   -------------------------------------------------------------------------- */
:focus-visible {
    outline: 3px solid #f59e0b !important;
    outline-offset: 2px !important;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline-offset: 0 !important;
}

/* Contêineres que recebem foco programaticamente pelos atalhos */
#conteudo:focus,
#rodape:focus,
#menu:focus,
main:focus,
h1[tabindex="-1"]:focus {
    outline: none !important;
}

h1[tabindex="-1"]:focus-visible {
    outline: 3px dashed #f59e0b !important;
    outline-offset: 4px !important;
}

/* --------------------------------------------------------------------------
   Barra superior: atalhos + ferramentas (sempre em uma única linha)
   -------------------------------------------------------------------------- */
.top-bar .container {
    flex-wrap: nowrap;
    gap: 16px;
}

.top-bar .accessibility-tools {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 16px;
}

.a11y-shortcuts ul,
.a11y-tools {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
    white-space: nowrap;
}

.a11y-tools {
    margin-left: auto;
}

.accessibility-tools .a11y-shortcuts a {
    width: auto;
    height: auto;
    border-radius: 4px;
    background: transparent;
    padding: 2px 4px;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 500;
    gap: 6px;
    white-space: nowrap;
}

.accessibility-tools .a11y-shortcuts a:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: none;
    text-decoration: underline;
}

.a11y-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.2);
    font-size: 0.7rem;
    font-weight: 700;
}

.accessibility-tools button {
    font: inherit;
    border: 0;
    cursor: pointer;
}

.accessibility-tools button.access-link-text,
.accessibility-tools a.a11y-info-link {
    background: transparent;
    padding: 2px 4px;
    border-radius: 4px;
    white-space: nowrap;
}

.accessibility-tools a.a11y-info-link:hover,
.accessibility-tools button.access-link-text:hover {
    text-decoration: underline;
}

.accessibility-tools button.access-link {
    color: rgba(255, 255, 255, 0.9);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    font-weight: 700;
    font-size: 0.75rem;
    transition: var(--transition-smooth, all 0.3s ease);
}

.accessibility-tools button.access-link:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.accessibility-tools button[aria-pressed="true"] {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.a11y-panel-btn {
    background: rgba(255, 255, 255, 0.15) !important;
    padding: 4px 12px !important;
    border-radius: 999px !important;
}

/* Foco sobre fundo escuro da barra superior */
.top-bar :focus-visible {
    outline-color: #ffdd00 !important;
}

/* Telas médias: os atalhos aparecem apenas quando recebem foco */
@media (max-width: 1199px) {
    .a11y-shortcuts {
        position: absolute;
        left: 0;
        top: 0;
        z-index: 5;
    }

    .a11y-shortcuts li {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
    }

    .a11y-shortcuts li:focus-within {
        position: static;
        width: auto;
        height: auto;
        clip: auto;
        overflow: visible;
    }

    .accessibility-tools .a11y-shortcuts li:focus-within a {
        background: #ffdd00;
        color: #0b0c0c;
        padding: 6px 10px;
    }

    .top-bar {
        overflow: visible;
    }

}

@media (max-width: 1365px) {
    .accessibility-tools .a11y-hide-tablet {
        display: none;
    }
}

/* Celular: rótulos viram apenas ícones (texto continua para leitores de tela) */
@media (max-width: 767px) {
    .top-bar .container {
        justify-content: center;
    }

    .a11y-tools {
        gap: 6px;
        margin: 0 auto;
    }

    .a11y-tools .a11y-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }

    .accessibility-tools .a11y-hide-mobile {
        display: none;
    }

    .accessibility-tools button.access-link-text {
        width: 30px;
        height: 30px;
        padding: 0 !important;
        justify-content: center;
        border-radius: 50% !important;
        background: rgba(255, 255, 255, 0.1);
    }

}

/* --------------------------------------------------------------------------
   "Siga-nos" no cabeçalho principal (ao lado do menu)
   -------------------------------------------------------------------------- */
.header-actions {
    display: flex;
    align-items: center;
    gap: 18px;
}

.header-socials {
    display: none;
    align-items: center;
    gap: 8px;
    padding-left: 18px;
    border-left: 1px solid var(--header-border, #e2e8f0);
    white-space: nowrap;
}

.header-socials-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

.header-socials a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #f1f5f9;
    color: var(--header-primary, #003366);
    transition: background 0.2s ease, color 0.2s ease;
}

.header-socials a:hover {
    background: var(--header-primary, #003366);
    color: #fff;
}

/* Exibido no desktop; no celular as redes ficam no menu lateral e no rodapé */
@media (min-width: 1200px) {
    .header-socials {
        display: flex;
    }
}

/* --------------------------------------------------------------------------
   Submenus do menu principal operáveis pelo teclado
   -------------------------------------------------------------------------- */
@media (min-width: 992px) {
    /* visibility sem transição: o submenu precisa poder receber foco imediatamente */
    .nav-list li.submenu-open > .sub-menu {
        opacity: 1;
        visibility: visible;
        transform: translateX(-50%) translateY(0);
        transition: opacity 0.3s ease, transform 0.3s ease;
    }

    /* Os itens herdam "visibility"; sem isto o link fica "hidden" no início da animação */
    .nav-list .sub-menu li,
    .nav-list .sub-menu a {
        transition-property: background-color, color, padding;
    }

    .nav-list li.submenu-open > a .chevron-icon {
        transform: rotate(180deg);
        opacity: 1;
    }

    .nav-list li.submenu-dismissed > .sub-menu,
    .nav-list li.submenu-dismissed:hover > .sub-menu {
        opacity: 0;
        visibility: hidden;
    }

    .nav-list > li > a:focus-visible::before {
        opacity: 1;
        transform: scale(1);
    }

    .sub-menu a:focus-visible {
        background: #f1f5f9;
        color: var(--header-primary, #003366);
    }
}

/* --------------------------------------------------------------------------
   Painel "Modo de Acessibilidade"
   -------------------------------------------------------------------------- */
.a11y-panel {
    width: min(560px, calc(100vw - 24px));
    max-height: calc(100vh - 32px);
    padding: 0;
    border: 0;
    border-radius: 16px;
    background: #fff;
    color: #1e293b;
    box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.4);
    overflow: auto;
    font-size: 1rem;
    text-align: left;
}

.a11y-panel:not([open]) {
    display: none;
}

.a11y-panel::backdrop {
    background: rgba(15, 23, 42, 0.6);
}

.a11y-panel-inner {
    padding: 24px;
}

.a11y-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.a11y-panel-header h2 {
    margin: 0;
    font-size: 1.35rem;
    color: #003366;
}

.a11y-panel-close {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: #f1f5f9;
    color: #1e293b;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.a11y-panel-close:hover {
    background: #e2e8f0;
}

.a11y-panel-desc {
    margin: 8px 0 16px;
    color: #475569;
    font-size: 0.95rem;
}

.a11y-panel-section {
    border-top: 1px solid #e2e8f0;
    padding: 16px 0;
}

.a11y-panel-section h3 {
    margin: 0 0 12px;
    font-size: 1rem;
    color: #0f172a;
}

.a11y-font-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.a11y-font-value {
    min-width: 56px;
    text-align: center;
    font-weight: 700;
}

.a11y-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0 14px;
    border: 2px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    color: #0f172a;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

.a11y-btn:hover {
    border-color: #0056b3;
    color: #0056b3;
}

.a11y-btn-text {
    font-weight: 600;
}

.a11y-btn-primary {
    background: #003366;
    border-color: #003366;
    color: #fff;
}

.a11y-btn-primary:hover {
    background: #0056b3;
    border-color: #0056b3;
    color: #fff;
}

.a11y-options {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.a11y-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 48px;
    padding: 8px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    color: #0f172a;
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.a11y-option:hover {
    border-color: #93c5fd;
}

.a11y-option[aria-pressed="true"] {
    border-color: #0056b3;
    background: #eff6ff;
}

.a11y-switch {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 24px;
    border-radius: 999px;
    background: #94a3b8;
    transition: background 0.2s ease;
}

.a11y-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s ease;
}

.a11y-option[aria-pressed="true"] .a11y-switch {
    background: #0056b3;
}

.a11y-option[aria-pressed="true"] .a11y-switch::after {
    transform: translateX(20px);
}

.a11y-shortcuts-table {
    width: 100%;
    margin-top: 14px;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.a11y-shortcuts-table th,
.a11y-shortcuts-table td {
    padding: 8px 6px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    vertical-align: middle;
}

.a11y-shortcuts-table th {
    color: #475569;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

kbd {
    display: inline-block;
    min-width: 1.6em;
    padding: 2px 6px;
    border: 1px solid #cbd5e1;
    border-bottom-width: 3px;
    border-radius: 5px;
    background: #f8fafc;
    color: #0f172a;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.8em;
    text-align: center;
}

.a11y-note {
    margin: 10px 0 0;
    font-size: 0.85rem;
    color: #475569;
}

.a11y-panel-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    border-top: 1px solid #e2e8f0;
    padding-top: 16px;
}

/* --------------------------------------------------------------------------
   Preferências do usuário
   -------------------------------------------------------------------------- */

/* Destaque de foco reforçado (navegação por teclado) */
html.a11y-focus :focus-visible,
html.a11y-focus :focus {
    outline: 4px solid #0b0c0c !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 8px #ffdd00 !important;
    border-radius: 4px;
}

html.a11y-focus a:focus,
html.a11y-focus summary:focus {
    background-color: #ffdd00 !important;
    color: #0b0c0c !important;
    text-decoration: underline !important;
}

html.a11y-focus #conteudo:focus,
html.a11y-focus #rodape:focus,
html.a11y-focus main:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* Sublinhar links */
html.a11y-underline a:not(.skip-link) {
    text-decoration: underline !important;
    text-underline-offset: 3px;
    text-decoration-thickness: 2px;
}

/* Fonte mais legível (preserva fontes de ícones) */
html.a11y-readable-font body,
html.a11y-readable-font body *:not(i):not([class*="fa-"]):not(.fa):not(.material-icons):not(kbd) {
    font-family: Verdana, Tahoma, "Segoe UI", Arial, sans-serif !important;
}

/* Espaçamento de texto (WCAG 1.4.12) */
html.a11y-spacing body p,
html.a11y-spacing body li,
html.a11y-spacing body td,
html.a11y-spacing body th,
html.a11y-spacing body dd,
html.a11y-spacing body label,
html.a11y-spacing body summary,
html.a11y-spacing body blockquote,
html.a11y-spacing body .faq-card-content {
    line-height: 1.8 !important;
    letter-spacing: 0.12em !important;
    word-spacing: 0.16em !important;
}

html.a11y-spacing body p {
    margin-bottom: 2em !important;
}

/* Pausar animações e transições */
html.a11y-no-motion *,
html.a11y-no-motion *::before,
html.a11y-no-motion *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
}

@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;
    }
}

/* Escala de cinza (aplicada no <html> para não quebrar elementos fixos) */
html.a11y-grayscale {
    filter: grayscale(100%);
}

/* Cursor ampliado */
html.a11y-big-cursor,
html.a11y-big-cursor * {
    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 2l14 11.5-6.2.6 3.7 7.4-2.9 1.4-3.6-7.5L4 20z' fill='%23000' stroke='%23fff' stroke-width='1.2'/%3E%3C/svg%3E") 4 2, auto !important;
}

html.a11y-big-cursor a,
html.a11y-big-cursor button,
html.a11y-big-cursor [role="button"],
html.a11y-big-cursor summary,
html.a11y-big-cursor 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 11V4.5a1.5 1.5 0 013 0V10l.5-.1V8.5a1.5 1.5 0 013 0V10l.5.1V9.5a1.5 1.5 0 013 0v5.5c0 3.9-2.6 7-6.5 7-2.6 0-4.3-1.2-5.6-3.3L4.6 14a1.5 1.5 0 012.5-1.6L9 15z' fill='%23000' stroke='%23fff' stroke-width='1'/%3E%3C/svg%3E") 14 4, pointer !important;
}

/* --------------------------------------------------------------------------
   Ajustes do alto contraste para os novos componentes
   -------------------------------------------------------------------------- */
.high-contrast :focus-visible {
    outline: 3px solid #ffff00 !important;
    outline-offset: 3px !important;
}

.high-contrast .skip-link {
    background: #ffff00 !important;
    color: #000 !important;
    border-color: #000 !important;
}

.high-contrast .a11y-panel {
    background: #000 !important;
    border: 3px solid #ffff00 !important;
}

.high-contrast .a11y-panel h2,
.high-contrast .a11y-panel h3 {
    color: #ffff00 !important;
}

.high-contrast .a11y-option[aria-pressed="true"],
.high-contrast .accessibility-tools button[aria-pressed="true"] {
    background: #ffff00 !important;
    color: #000 !important;
}

.high-contrast .a11y-option[aria-pressed="true"] * {
    color: #000 !important;
}

.high-contrast .a11y-switch {
    border: 2px solid currentColor !important;
}

.high-contrast .a11y-switch::after {
    background: #ffff00 !important;
}

.high-contrast .a11y-option[aria-pressed="true"] .a11y-switch::after {
    background: #000 !important;
}


.high-contrast kbd {
    border-color: #ffff00 !important;
}

/* --------------------------------------------------------------------------
   Página "Acessibilidade"
   -------------------------------------------------------------------------- */
.a11y-page h2 {
    color: var(--primary-color, #003366);
    margin-top: 2rem;
}

.a11y-page table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.a11y-page th,
.a11y-page td {
    padding: 10px;
    border: 1px solid #e2e8f0;
    text-align: left;
}

.a11y-page th {
    background: #f1f5f9;
}

.a11y-page ul {
    padding-left: 1.25rem;
    list-style: disc;
}

.a11y-page li {
    margin-bottom: 0.4rem;
}

/* --------------------------------------------------------------------------
   Páginas "Acesso à Informação" e "Mapa do Site"
   -------------------------------------------------------------------------- */
.info-breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 20px;
    padding: 0;
    list-style: none;
    font-size: 0.9rem;
    color: #64748b;
}

.info-breadcrumb a {
    color: #0056b3;
    text-decoration: underline;
}

.info-hero {
    margin-bottom: 32px;
}

.info-hero h1 {
    margin: 0 0 12px;
    font-size: 2.25rem;
    font-weight: 800;
    color: #0f172a;
}

.info-hero p {
    max-width: 820px;
    font-size: 1.05rem;
    line-height: 1.8;
    color: #334155;
}

.info-index,
.info-block,
.info-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
}

.info-index {
    padding: 20px 24px;
    margin-bottom: 28px;
}

.info-index h2 {
    margin: 0 0 10px;
    font-size: 1rem;
    color: #0f172a;
}

.info-index ul {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.info-index a,
.info-card a,
.info-block a,
.info-footer-links a {
    color: #0056b3;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.info-index a:hover,
.info-card a:hover,
.info-block a:hover {
    color: #003366;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.info-card {
    padding: 24px;
}

.info-card h2,
.info-block h2 {
    margin: 0 0 10px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color, #003366);
}

.info-card p,
.info-block p {
    margin: 0 0 12px;
    line-height: 1.7;
    color: #475569;
}

.info-card ul {
    margin: 0;
    padding-left: 1.2rem;
    list-style: disc;
}

.info-card ul ul {
    margin-top: 6px;
    list-style: circle;
}

.info-card li {
    margin-bottom: 6px;
}

.info-block {
    padding: 28px;
    margin-bottom: 20px;
}

.info-block ul,
.info-steps {
    margin: 0 0 12px;
    padding-left: 1.4rem;
    line-height: 1.8;
    color: #334155;
}

.info-block ul {
    list-style: disc;
}

.info-steps {
    list-style: decimal;
}

.info-contacts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin: 0;
}

.info-contacts dt {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
}

.info-contacts dd {
    margin: 4px 0 0;
    color: #0f172a;
}

.info-footer-links {
    margin-top: 24px;
    color: #475569;
}

.sitemap-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

@media (max-width: 768px) {
    .info-hero h1 {
        font-size: 1.8rem;
    }

    .info-block,
    .info-card {
        padding: 20px;
    }
}

/* --------------------------------------------------------------------------
   Navegação por blocos (setas): indicador do bloco atual
   -------------------------------------------------------------------------- */
.a11y-block-hint {
    position: fixed;
    left: 50%;
    bottom: 20px;
    z-index: 2147483000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    max-width: calc(100vw - 32px);
    padding: 10px 18px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.92);
    color: #fff;
    font-size: 0.85rem;
    line-height: 1.4;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.a11y-block-hint.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.a11y-block-hint strong {
    font-size: 0.95rem;
    color: #ffdd00;
}

.a11y-block-hint span {
    opacity: 0.9;
    white-space: pre-wrap;
}

/* Títulos alcançados pelas setas */
h2[tabindex="-1"]:focus-visible,
h3[tabindex="-1"]:focus-visible {
    outline: 3px dashed #f59e0b !important;
    outline-offset: 4px !important;
}

.high-contrast .a11y-block-hint {
    background: #000 !important;
    border: 2px solid #ffff00 !important;
}

.high-contrast .a11y-block-hint strong {
    color: #ffff00 !important;
}
