/* ==================================================================
   Sesc PA — Acessibilidade (e-MAG inspired)
   - Skip link
   - Foco visível
   - Barra flutuante (fonte, contraste, sublinhar links, destacar foco)
   - Modal de atalhos de teclado
   - Suporte a prefers-reduced-motion
   ================================================================== */

:root {
    --a11y-focus: #1268eb;
    --a11y-focus-glow: rgba(18, 104, 235, 0.25);
}

/* ===== Skip link (Tab inicial pula para o conteúdo) ===== */
.skip-link {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100000;
    padding: 12px 22px;
    background: #004c99;
    color: #fff !important;
    font-weight: 700;
    font-size: 0.95rem;
    border-radius: 0 0 12px 12px;
    text-decoration: none;
    box-shadow: 0 8px 24px rgba(0, 30, 70, 0.4);
    transition: top 0.2s ease;
}

.skip-link:focus,
.skip-link:focus-visible {
    top: 0;
    outline: 3px solid #ffd84d;
    outline-offset: 2px;
}

/* ===== Foco visível global ===== */
*:focus {
    outline: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
[role="button"]:focus-visible,
[role="link"]:focus-visible {
    outline: 3px solid var(--a11y-focus);
    outline-offset: 3px;
    border-radius: 4px;
    box-shadow: 0 0 0 5px var(--a11y-focus-glow);
}

/* Inputs já têm border-color de foco próprio em telas de auth — só reforça */
.login-card .form-control:focus-visible {
    outline: none;
}

/* ===== Destacar foco (toggle da barra a11y) ===== */
body.a11y-highlight-focus *:focus-visible {
    outline: 4px solid #ffd84d !important;
    outline-offset: 4px !important;
    box-shadow: 0 0 0 8px rgba(255, 216, 77, 0.4) !important;
}

/* ===== Sublinhar todos os links (toggle) ===== */
body.a11y-underline-links a {
    text-decoration: underline !important;
    text-underline-offset: 3px;
}

/* ===== Escala de fonte (toggle) ===== */
html.a11y-font-110 { font-size: 110%; }
html.a11y-font-120 { font-size: 120%; }
html.a11y-font-130 { font-size: 130%; }

/* ===== Alto contraste (toggle) ===== */
body.a11y-high-contrast {
    background: #000 !important;
    color: #fff !important;
}

body.a11y-high-contrast,
body.a11y-high-contrast main,
body.a11y-high-contrast header,
body.a11y-high-contrast footer,
body.a11y-high-contrast section,
body.a11y-high-contrast div:not(.a11y-bar):not(.a11y-bar *):not(.a11y-shortcuts):not(.a11y-shortcuts *) {
    background-color: #000 !important;
    color: #fff !important;
    background-image: none !important;
    border-color: #fff !important;
}

body.a11y-high-contrast a,
body.a11y-high-contrast a * {
    color: #ffeb3b !important;
}

body.a11y-high-contrast a:hover,
body.a11y-high-contrast a:focus-visible {
    color: #fff !important;
    background: #ffeb3b !important;
}

body.a11y-high-contrast button,
body.a11y-high-contrast input,
body.a11y-high-contrast select,
body.a11y-high-contrast textarea {
    background: #000 !important;
    color: #fff !important;
    border: 2px solid #fff !important;
}

body.a11y-high-contrast img,
body.a11y-high-contrast video {
    filter: grayscale(1) contrast(1.2);
}

body.a11y-high-contrast .skip-link,
body.a11y-high-contrast .a11y-bar,
body.a11y-high-contrast .a11y-shortcuts {
    filter: none;
}

/* ===== Barra de acessibilidade flutuante ===== */
.a11y-bar {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9990;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 12px;
}

.a11y-bar-toggle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #004c99 0%, #0070d4 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 6px 18px rgba(0, 76, 153, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.a11y-bar-toggle:hover,
.a11y-bar-toggle:focus-visible {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 10px 24px rgba(0, 76, 153, 0.55);
}

.a11y-bar-panel {
    background: #fff;
    border-radius: 14px;
    padding: 14px;
    width: 280px;
    box-shadow: 0 16px 40px rgba(0, 30, 70, 0.2);
    border: 1px solid rgba(0, 76, 153, 0.1);
    display: none;
    flex-direction: column;
    gap: 10px;
}

.a11y-bar.is-open .a11y-bar-panel {
    display: flex;
    animation: a11yPanelIn 0.25s ease;
}

@keyframes a11yPanelIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.a11y-bar-panel h3 {
    margin: 0 0 4px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #004c99;
}

.a11y-bar-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.a11y-btn {
    flex: 1;
    height: 38px;
    border-radius: 8px;
    border: 1.5px solid rgba(0, 76, 153, 0.15);
    background: #fff;
    color: #1a2533;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.a11y-btn:hover {
    background: rgba(0, 76, 153, 0.06);
    border-color: rgba(0, 76, 153, 0.35);
}

.a11y-btn.is-active {
    background: #004c99;
    color: #fff;
    border-color: #004c99;
}

.a11y-btn-font-a { font-size: 0.85rem; }
.a11y-btn-font-aa { font-size: 1rem; }
.a11y-btn-font-aaa { font-size: 1.15rem; }
.a11y-btn-font-aaaa { font-size: 1.3rem; }

.a11y-bar-reset {
    margin-top: 4px;
    background: transparent;
    border: none;
    color: #5a6878;
    font-size: 0.78rem;
    text-decoration: underline;
    cursor: pointer;
    align-self: flex-start;
}

.a11y-bar-reset:hover {
    color: #004c99;
}

/* ===== Modal de atalhos de teclado ===== */
.a11y-shortcuts {
    position: fixed;
    inset: 0;
    z-index: 100001;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 20, 50, 0.55);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.a11y-shortcuts.is-open {
    display: flex;
    animation: a11yPanelIn 0.25s ease;
}

.a11y-shortcuts-content {
    background: #fff;
    border-radius: 16px;
    padding: 28px 32px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 30, 70, 0.35);
}

.a11y-shortcuts h2 {
    margin: 0 0 16px;
    font-size: 1.2rem;
    font-weight: 700;
    color: #004c99;
}

.a11y-shortcuts ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.a11y-shortcuts li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(0, 76, 153, 0.05);
    font-size: 0.92rem;
}

.a11y-shortcuts kbd {
    display: inline-block;
    padding: 3px 8px;
    background: #fff;
    border: 1px solid rgba(0, 76, 153, 0.2);
    border-radius: 6px;
    box-shadow: 0 2px 0 rgba(0, 76, 153, 0.15);
    font-family: 'Roboto Mono', 'Courier New', monospace;
    font-size: 0.8rem;
    font-weight: 600;
    color: #004c99;
}

.a11y-shortcuts-close {
    margin-top: 20px;
    height: 42px;
    width: 100%;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #004c99 0%, #0070d4 100%);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.2s ease, transform 0.2s ease;
}

.a11y-shortcuts-close:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

/* ===== prefers-reduced-motion ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .bg-photo,
    .bg-glow,
    .floating-shape {
        transform: none !important;
    }
}

/* ===== Aria-current visual ===== */
.main-menu ul.topo > li > a[aria-current="page"] {
    color: #004c99;
}

@media only screen and (min-width: 1200px) {
    .site-header .main-menu ul.topo > li.menu-has-child > a[aria-current="page"]::before {
        width: 100% !important;
    }
}

/* ===== Responsivo da barra ===== */
@media (max-width: 576px) {
    .a11y-bar {
        bottom: 14px;
        left: 14px;
    }
    .a11y-bar-toggle {
        width: 46px;
        height: 46px;
        font-size: 1.2rem;
    }
    .a11y-bar-panel {
        width: calc(100vw - 28px);
        max-width: 280px;
    }
}
