/* =========================================================================
   WCAG 2.2 AA accessibility baseline overrides for AAB Portal.
   Loaded last in the ~/Content/css bundle so these rules take precedence
   over Bootstrap, jQuery UI, and other framework styles.
   Scope: public (applicant) side of the portal.
   ========================================================================= */


/* ---- Screen-reader-only utility (visually hidden, still announced) ---- */
.sr-only,
.visually-hidden {
    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;
}

.sr-only-focusable:focus,
.sr-only-focusable:active {
    position: static !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
}


/* ---- Skip-to-main-content link (WCAG 2.4.1 Bypass Blocks, Level A) ---- */
.skip-to-main {
    position: absolute;
    top: -60px;
    left: 0;
    background: #0b5c8a;
    color: #ffffff;
    padding: 10px 18px;
    z-index: 10000;
    text-decoration: none;
    font-weight: 700;
    border-radius: 0 0 4px 0;
    transition: top 0.15s ease-in-out;
}

    .skip-to-main:focus,
    .skip-to-main:active {
        top: 0;
        outline: 3px solid #ffc107;
        outline-offset: 2px;
        color: #ffffff;
        text-decoration: underline;
    }


/* ---- Focus-visible indicator (WCAG 2.4.7 Focus Visible, Level AA) ---- */
/* Strong, high-contrast focus ring that survives vendor styling. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible,
[role="button"]:focus-visible,
[role="link"]:focus-visible,
[role="menuitem"]:focus-visible,
[role="tab"]:focus-visible,
[contenteditable="true"]:focus-visible {
    outline: 3px solid #005fcc !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 1px #ffffff !important;
}

/* Fallback for browsers without :focus-visible support (older Safari). */
@supports not selector(:focus-visible) {
    a:focus,
    button:focus,
    input:focus,
    select:focus,
    textarea:focus,
    [tabindex]:focus {
        outline: 3px solid #005fcc !important;
        outline-offset: 2px !important;
    }
}


/* ---- Error text & invalid field contrast (WCAG 1.4.3, Level AA) ----
   Bootstrap's .text-danger (#dc3545) is 4.53:1 on white — borderline pass.
   Darken slightly to comfortably exceed 4.5:1 and remain visible on #f0f0f0. */
.text-danger,
.field-validation-error,
.help-block-error {
    color: #b00020 !important;
}

.form-control.is-invalid,
.form-control[aria-invalid="true"] {
    border-color: #b00020 !important;
    border-width: 2px !important;
}


/* ---- Placeholder text contrast (WCAG 1.4.3, Level AA) ---- */
::placeholder {
    color: #6c6c6c !important;  /* 4.74:1 on white */
    opacity: 1 !important;
}

::-ms-input-placeholder {
    color: #6c6c6c !important;
}


/* ---- Minimum target size utility (WCAG 2.5.8, Level AA — new in 2.2) ----
   Opt-in class. Apply to small icon-only buttons or table-row actions. */
.a11y-target,
.a11y-target-min {
    min-width: 24px;
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}


/* ---- Required field marker (WCAG 1.4.1 — do not rely on color alone) ----
   Combine with aria-required / required attribute and visible "(required)"
   or * with text. Asterisk alone should never be the only indicator. */
.required-marker {
    color: #b00020;
    font-weight: 700;
    margin-left: 0.2em;
}


/* ---- Reduced-motion preference (respect OS-level setting) ---- */
@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;
    }
}


/* ---- Live-region utility for dynamic announcements (WCAG 4.1.3, AA) ----
   Mark a container with role="status" aria-live="polite" for non-urgent
   updates (e.g. "Saved"); use role="alert" for errors. Keep off-screen. */
.aab-live-region {
    position: absolute !important;
    left: -10000px !important;
    top: auto !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}


/* ---- Toastr container — ensure ARIA live semantics survive ---- */
#toast-container {
    pointer-events: auto;
}

    #toast-container > .toast {
        /* Existing toastr styles keep the visual look.
           aria-live is set via JS (see _Layout.cshtml toastr options). */
    }


/* ---- Ensure links are distinguishable from body text (WCAG 1.4.1) ----
   The site uses a lot of .nounderline links; these rely on color alone to
   signal "this is a link", which fails 1.4.1 unless contrast ratio to body
   text is >= 3:1 AND the link has a hover/focus non-color indicator.
   Add a subtle underline on hover/focus to satisfy the latter. */
a.nounderline {
    text-decoration: none;
}

    a.nounderline:hover,
    a.nounderline:focus,
    a.nounderline:focus-visible {
        text-decoration: underline !important;
    }


/* ---- Support 200% text zoom without content clipping (WCAG 1.4.4) ----
   Remove fixed heights on text-bearing containers so they reflow. */
.btn,
.form-control,
label {
    word-wrap: break-word;
    overflow-wrap: break-word;
}


/* ---- High-contrast mode (Windows forced colors) ---- */
@media (forced-colors: active) {
    .btn,
    .form-control {
        border: 1px solid ButtonText;
    }

    a:focus-visible,
    button:focus-visible,
    input:focus-visible,
    select:focus-visible,
    textarea:focus-visible {
        outline: 3px solid Highlight !important;
    }
}
