/*
 * IntelliSee accessibility layer.
 *
 * Adds skip-to-content link, consistent focus rings, screen-reader helpers,
 * reduced-motion guards, and a small contrast bump for muted text on dark
 * surfaces (the previous 0.76 alpha sits at the border of WCAG AA on the
 * --macc-brand-midnight canvas).
 */

@layer base {

    /* ----- Skip to main content -------------------------------------- */
    .macc-skip-link {
        position: absolute;
        top: 0;
        left: 0;
        z-index: 1080;
        padding: 0.6rem 1rem;
        background-color: var(--macc-brand-gold);
        color: var(--macc-brand-midnight);
        font-weight: 600;
        text-decoration: none;
        border-radius: 0 0 var(--macc-radius-md) 0;
        transform: translateY(-110%);
        transition: transform 150ms ease-in-out;
    }

    .macc-skip-link:focus,
    .macc-skip-link:focus-visible {
        transform: translateY(0);
        outline: 2px solid var(--macc-brand-midnight);
        outline-offset: 2px;
    }

    /* ----- Visually hidden (screen reader only) --------------------- */
    .macc-sr-only,
    .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;
    }

    /* ----- Universal focus-visible ring ------------------------------ */
    /* Ensure every interactive element gets a visible focus indicator.
       !important here is intentional: page CSS in this codebase frequently
       sets `outline: none !important` on hover/active states without
       preserving a keyboard alternative, which would otherwise defeat this. */
    :where(a, button, [role="button"], [role="link"], [role="tab"], [role="menuitem"],
           input, select, textarea, summary, [tabindex]):focus-visible {
        outline: 2px solid var(--macc-focus-border) !important;
        outline-offset: 2px !important;
        border-radius: var(--macc-radius-sm);
    }

    /* Remove the default focus outline only when focus-visible is also
       supported (preserves keyboard accessibility). */
    :focus:not(:focus-visible) {
        outline: none;
    }

    /* ----- Active nav indicator ------------------------------------- */
    [aria-current="page"] {
        font-weight: 600;
    }

    /* ----- Contrast bump for muted text on dark surfaces ----------- */
    /* The dark theme's --macc-text-muted (alpha 0.76) is borderline on the
       midnight canvas. Bump it slightly without introducing a new token. */
    html[data-bs-theme="dark"] {
        --macc-text-muted: rgba(221, 246, 255, 0.84);
    }

    /* ----- 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;
        }

        .macc-skeleton::after {
            animation: none !important;
            background-image: none !important;
        }
    }

    /* ----- Forced-colors mode (Windows high contrast) -------------- */
    @media (forced-colors: active) {
        .macc-skip-link {
            border: 2px solid CanvasText;
        }
    }
}
