/**
 * KCM Accessibility Fixer - Frontend CSS
 * WCAG AA compliant styles
 */

/* ========================================
   SKIP NAVIGATION LINK
   ======================================== */
.kcm-skip-link {
    position: absolute;
    top: -1000px;
    left: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
    background: #0073aa;
    color: #ffffff;
    padding: 10px 20px;
    text-decoration: none;
    font-weight: bold;
    z-index: 999999;
    border-radius: 0 0 4px 0;
}

.kcm-skip-link:focus {
    position: absolute;
    top: 0;
    left: 0;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    outline: 3px solid #ffbf47;
    outline-offset: 0;
}

/* ========================================
   KEYBOARD FOCUS INDICATORS
   ======================================== */
.kcm-keyboard-nav a:focus,
.kcm-keyboard-nav button:focus,
.kcm-keyboard-nav input:focus,
.kcm-keyboard-nav select:focus,
.kcm-keyboard-nav textarea:focus,
.kcm-keyboard-nav [tabindex]:focus {
    outline: 3px solid #0073aa !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.25) !important;
}

/* Enhanced focus for interactive elements */
.kcm-focus-enhanced:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Remove browser default focus, we'll add our own */
*:focus {
    outline: none;
}

/* But add visible focus for keyboard navigation */
.kcm-keyboard-nav *:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* ========================================
   CAROUSEL/SLIDER CONTROLS
   ======================================== */
.kcm-carousel-pause {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 100;
    background: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    border: 2px solid #ffffff;
    padding: 10px 15px;
    font-size: 16px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.kcm-carousel-pause:hover,
.kcm-carousel-pause:focus {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.05);
    outline: 2px solid #ffbf47;
    outline-offset: 2px;
}

.kcm-carousel-pause span {
    font-size: 14px;
}

/* ========================================
   FORM ENHANCEMENTS
   ======================================== */
/* Better focus states for form fields */
input:focus,
textarea:focus,
select:focus {
    border-color: #0073aa !important;
    box-shadow: 0 0 0 1px #0073aa !important;
}

/* Required field indicator */
[aria-required="true"]:not([type="hidden"])::after,
.required:not([type="hidden"])::after {
    content: "*";
    color: #d63638;
    margin-left: 4px;
    font-weight: bold;
}

/* Error states */
[aria-invalid="true"] {
    border-color: #d63638 !important;
    background-color: #fff5f5 !important;
}

/* ========================================
   MENU ENHANCEMENTS
   ======================================== */
/* Keyboard-accessible dropdown menus */
.menu-item-has-children > a[aria-expanded="true"] + .sub-menu {
    display: block !important;
}

.sub-menu.kcm-open {
    display: block !important;
}

/* Better focus for menu items */
.menu a:focus {
    background-color: rgba(0, 115, 170, 0.1);
    outline: 2px solid #0073aa;
    outline-offset: -2px;
}

/* ========================================
   COLOR CONTRAST ENHANCEMENTS
   ======================================== */
.kcm-contrast-enhanced {
    /* Ensure minimum contrast ratios */
}

.kcm-contrast-enhanced a {
    /* Ensure links have sufficient contrast */
    color: #0073aa;
}

.kcm-contrast-enhanced a:hover,
.kcm-contrast-enhanced a:focus {
    color: #005177;
}

/* Light text on dark backgrounds */
.kcm-contrast-enhanced .dark-bg {
    color: #ffffff;
    background-color: #1d1d1d;
}

/* ========================================
   ACCESSIBLE BUTTONS
   ======================================== */
button,
.button,
input[type="submit"],
input[type="button"] {
    min-height: 44px; /* WCAG AA minimum touch target */
    min-width: 44px;
    cursor: pointer;
}

button:focus,
.button:focus,
input[type="submit"]:focus,
input[type="button"]:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* ========================================
   TEXT SIZING AND SPACING
   ======================================== */
/* Ensure readable line height */
p, li, td, th {
    line-height: 1.5; /* WCAG AA recommendation */
}

/* Ensure readable letter spacing */
body {
    letter-spacing: 0.02em;
}

/* Ensure readable word spacing */
p {
    word-spacing: 0.16em;
}

/* ========================================
   REDUCED MOTION
   ======================================== */
/* Respect user's motion preferences */
@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;
    }
    
    .kcm-carousel-pause {
        /* Auto-pause carousels for users with motion sensitivity */
    }
}

/* ========================================
   HIGH CONTRAST MODE
   ======================================== */
@media (prefers-contrast: high) {
    .kcm-contrast-enhanced a {
        text-decoration: underline;
    }
    
    button,
    .button {
        border: 2px solid currentColor;
    }
}

/* ========================================
   SCREEN READER ONLY TEXT
   ======================================== */
.sr-only,
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.sr-only:focus,
.screen-reader-text:focus {
    position: static;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* ========================================
   CUSTOM ELEMENTOR FIXES
   ======================================== */
/* Fix Elementor heading accessibility */
.elementor-heading-title {
    color: inherit; /* Ensure contrast is maintained */
}

/* Fix Elementor icon list */
.elementor-icon-list-item {
    display: flex;
    align-items: center;
}

.elementor-icon-list-icon {
    flex-shrink: 0;
}

/* Fix Elementor tabs keyboard navigation */
.elementor-tab-title:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Fix Elementor accordion keyboard navigation */
.elementor-accordion-title:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* ========================================
   RESPONSIVE ACCESSIBILITY
   ======================================== */
@media (max-width: 768px) {
    /* Ensure touch targets are large enough on mobile */
    button,
    .button,
    a,
    input[type="submit"],
    input[type="button"] {
        min-height: 48px;
        min-width: 48px;
    }
    
    /* Larger text for better readability */
    body {
        font-size: 16px;
    }
}

/* ========================================
   PRINT ACCESSIBILITY
   ======================================== */
@media print {
    /* Ensure links are visible in print */
    a[href]::after {
        content: " (" attr(href) ")";
    }
    
    /* Skip navigation is not needed in print */
    .kcm-skip-link {
        display: none;
    }
}
