/* ============================================================
   KCM WCAG 2.1 AA — Accessibility CSS Fixes
   ============================================================ */

/* ── 2.4.1 Skip-to-content link ── */
.kcm-wcag-skip-nav {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 100000;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.kcm-wcag-skip-nav:focus-within {
    width: auto;
    height: auto;
    overflow: visible;
}

.kcm-wcag-skip-link {
    position: absolute;
    top: -100%;
    left: 16px;
    z-index: 100000;
    padding: 12px 24px;
    background: #1b3a5c;
    color: #fff !important;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
    transition: top .15s ease;
}

.kcm-wcag-skip-link:focus {
    top: 0;
    outline: 3px solid #e87722;
    outline-offset: 2px;
}

/* ── 2.4.7 Focus Visible — universal focus ring ── */
*:focus-visible {
    outline: 3px solid #e87722 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 5px rgba(232, 119, 34, .25) !important;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
[role="button"]:focus-visible {
    outline: 3px solid #e87722 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 5px rgba(232, 119, 34, .25) !important;
}

/* ── 1.4.3 Contrast fixes — breadcrumb ── */
.breadcrumb-item,
.breadcrumb-item a,
.elementor-breadcrumb,
.elementor-breadcrumb a,
nav[aria-label="breadcrumbs"] a,
nav[aria-label="breadcrumbs"] span {
    color: #3a3a3a !important;
}

nav[aria-label="breadcrumbs"] a:hover,
nav[aria-label="breadcrumbs"] a:focus {
    color: #1b3a5c !important;
    text-decoration: underline !important;
}

/* ── 1.4.3 Contrast fixes — footer ── */
footer,
footer a,
footer p,
footer span,
.site-footer,
.site-footer a,
.site-footer p,
.elementor-location-footer,
.elementor-location-footer a,
.elementor-location-footer p {
    color: #e8e8e8 !important;
}

footer a:hover,
footer a:focus,
.site-footer a:hover,
.site-footer a:focus,
.elementor-location-footer a:hover,
.elementor-location-footer a:focus {
    color: #fff !important;
    text-decoration: underline !important;
}

/* ── 1.4.3 Contrast fixes — light body text ── */
body,
p,
li,
span,
div {
    /* Only override when inherited color is too light — handled via JS class */
}

.kcm-wcag-low-contrast {
    color: #3a3a3a !important;
}

.kcm-wcag-low-contrast-link {
    color: #1a5276 !important;
    text-decoration: underline !important;
}

/* ── 1.4.11 Non-text contrast — form borders ── */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="url"],
input[type="password"],
input[type="search"],
textarea,
select {
    border: 2px solid #5a5a5a !important;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
input[type="url"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus {
    border-color: #1b3a5c !important;
}

/* ── 1.4.11 Non-text contrast — accordion chevrons ── */
.elementor-accordion .elementor-accordion-icon,
.elementor-toggle .elementor-toggle-icon,
.elementor-accordion-icon svg,
.elementor-toggle-icon svg {
    color: #3a3a3a !important;
    fill: #3a3a3a !important;
}

/* ── 2.4.7 Sticky header offset for focused elements ── */
html {
    font-size: 100%;
    scroll-padding-top: 100px !important;
}

a:focus-visible,
button:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
[role="button"]:focus-visible {
    scroll-margin-top: 100px;
}

/* ── 1.4.4 / 1.4.10 Resize & reflow ── */

@media (max-width: 320px) {
    body {
        overflow-x: hidden;
    }

    img,
    video,
    iframe,
    object,
    embed,
    table {
        max-width: 100% !important;
        height: auto !important;
    }

    .elementor-section,
    .elementor-container,
    .elementor-column-wrap,
    .elementor-widget-wrap {
        flex-wrap: wrap !important;
    }

    .elementor-column {
        width: 100% !important;
    }
}

/* ── 1.4.12 Text spacing override resilience ── */
body.kcm-wcag-text-spacing p,
body.kcm-wcag-text-spacing li,
body.kcm-wcag-text-spacing span,
body.kcm-wcag-text-spacing td,
body.kcm-wcag-text-spacing th {
    line-height: 1.5 !important;
    letter-spacing: 0.12em !important;
    word-spacing: 0.16em !important;
}

body.kcm-wcag-text-spacing p {
    margin-bottom: 2em !important;
}

/* ── 1.4.13 Content on Hover or Focus ── */
[data-tooltip],
[title] {
    position: relative;
}

/* ── Screenreader-only utility ── */
.sr-only,
.kcm-wcag-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;
}

/* ── Visible label for icon-only links/buttons ── */
.kcm-wcag-icon-label {
    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;
}

/* ── 2.5.8 Target Size (enhanced, but useful for AA) ── */
a,
button,
[role="button"],
input[type="submit"],
input[type="button"],
input[type="reset"] {
    min-height: 24px;
    min-width: 24px;
}

/* ── Ensure accordion panels are visually associated ── */
.elementor-tab-content[role="region"] {
    border-left: 3px solid #1b3a5c;
    padding-left: 16px;
}

/* ── Ensure links within text are distinguishable (1.4.1) ── */
article a,
.entry-content a,
.elementor-widget-text-editor a,
main a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

article a:hover,
.entry-content a:hover,
.elementor-widget-text-editor a:hover,
main a:hover {
    text-decoration-thickness: 2px;
}

/* ── Reduced motion preference (2.3.3 AA) ── */
@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;
    }
}

/* ── High contrast mode improvements ── */
@media (forced-colors: active) {
    .kcm-wcag-skip-link {
        border: 2px solid;
    }

    *:focus-visible {
        outline: 3px solid Highlight !important;
    }
}

/* ── Accessibility Statement page ── */
.kcm-wcag-statement {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 0;
    line-height: 1.7;
    color: #2d2d2d;
}

.kcm-wcag-statement__section {
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #e0e0e0;
}

.kcm-wcag-statement__section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.kcm-wcag-statement h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1b3a5c;
    margin-bottom: 0.75rem;
}

.kcm-wcag-statement p {
    margin-bottom: 1rem;
}

.kcm-wcag-statement ul {
    margin: 1rem 0 1rem 1.5rem;
    padding: 0;
}

.kcm-wcag-statement li {
    margin-bottom: 0.5rem;
    padding-left: 0.25rem;
}

.kcm-wcag-statement a {
    color: #1a5276;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.kcm-wcag-statement a:hover,
.kcm-wcag-statement a:focus {
    color: #1b3a5c;
    text-decoration-thickness: 2px;
}

.kcm-wcag-statement strong {
    font-weight: 700;
}
