/**
 * Accessibility stylesheet — WCAG 2.2 AA
 * Skip links, focus, toolbar, contrast modes, reduced motion
 */

/* ==========================================================================
   Skip links
   ========================================================================== */
.skip-links {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10000;
    width: 100%;
}

.skip-links__link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: #000;
    color: #fff;
    padding: 0.75rem 1.25rem;
    font-weight: 700;
    text-decoration: none;
    border-radius: 0 0 0.25rem 0;
    min-height: var(--touch-target, 2.75rem);
    display: inline-flex;
    align-items: center;
}

.skip-links__link:focus {
    left: 0;
    outline: 3px solid #ffbf47;
    outline-offset: 2px;
}

/* ==========================================================================
   Focus indicators (WCAG 2.4.7, 2.4.11)
   ========================================================================== */
:focus {
    outline: none;
}

:focus-visible {
    outline: 3px solid var(--leo-focus, #005fcc);
    outline-offset: 2px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--leo-focus, #005fcc);
    outline-offset: 2px;
}

/* ==========================================================================
   Accessibility toolbar
   ========================================================================== */
.a11y-toolbar {
    position: fixed;
    top: 50%;
    right: 0.75rem;
    transform: translateY(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.a11y-toolbar__toggle {
    width: 3.25rem;
    height: 3.25rem;
    min-width: 3.25rem;
    min-height: 3.25rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #0066cc;
    color: #fff;
    border: 3px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.35);
    transition: background 0.2s ease, transform 0.2s ease;
}

.a11y-toolbar__toggle:hover,
.a11y-toolbar__toggle:focus-visible {
    background: #0052a3;
    color: #fff;
    transform: scale(1.06);
}

.a11y-toolbar__icon {
    display: block;
    width: 1.75rem;
    height: 1.75rem;
}

.a11y-toolbar__panel {
    display: none;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 70vh;
    overflow-y: auto;
    background: #0f2d52;
    border-radius: 0.5rem;
    padding: 0.5rem;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.3);
}

.a11y-toolbar__panel.is-open {
    display: flex;
}

.a11y-toolbar__panel button {
    min-height: var(--touch-target, 2.75rem);
    min-width: var(--touch-target, 2.75rem);
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 0.25rem;
    font-size: 0.7rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    text-align: left;
}

.a11y-toolbar__panel button[aria-pressed="true"] {
    background: var(--leo-blue);
    color: #fff;
    border-color: var(--leo-blue);
}

/* ==========================================================================
   User preference classes (applied via JS)
   ========================================================================== */
html.a11y-high-contrast {
    filter: contrast(1.4);
}

html.a11y-dark-mode {
    color-scheme: dark;
}

html.a11y-dark-mode body {
    background: #121212;
    color: #f5f5f5;
}

html.a11y-dark-mode .site-topbar,
html.a11y-dark-mode .card,
html.a11y-dark-mode .bg-light {
    background: #1e1e1e !important;
    color: #f5f5f5 !important;
}

html.a11y-grayscale {
    filter: grayscale(100%);
}

html.a11y-underline-links a:not(.btn) {
    text-decoration: underline !important;
    text-underline-offset: 0.15em;
}

html.a11y-highlight-links a:not(.btn) {
    background: #ffeb3b;
    color: #000 !important;
    padding: 0 0.15em;
}

html.a11y-large-cursor,
html.a11y-large-cursor * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Ccircle cx='16' cy='16' r='10' fill='%23000'/%3E%3C/svg%3E") 16 16, auto !important;
}

/* Reading guide */
.a11y-reading-guide {
    position: fixed;
    left: 0;
    width: 100%;
    height: 3rem;
    background: rgba(255, 235, 59, 0.35);
    border-top: 2px solid #f9a825;
    border-bottom: 2px solid #f9a825;
    pointer-events: none;
    z-index: 9998;
    display: none;
}

html.a11y-reading-guide-on .a11y-reading-guide {
    display: block;
}

/* Reading mask */
.a11y-reading-mask {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9997;
    display: none;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.65) 0%,
        transparent 35%,
        transparent 65%,
        rgba(0, 0, 0, 0.65) 100%
    );
}

html.a11y-reading-mask-on .a11y-reading-mask {
    display: block;
}

/* ==========================================================================
   Reduced motion (WCAG 2.3.3)
   ========================================================================== */
@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;
    }

    .home-pre-footer__ticker {
        animation: none;
        flex-wrap: wrap;
        width: 100%;
    }

    .home-pre-footer__ticker span[aria-hidden="true"] {
        display: none;
    }
}

/* ==========================================================================
   Screen reader utilities
   ========================================================================== */
.visually-hidden,
.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;
}

.visually-hidden-focusable:focus {
    position: static !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
}

/* Live regions */
#a11y-live-polite,
#a11y-live-assertive {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
