/**
 * RayWP Accessibility Frontend Styles
 */

/* Screen Reader Text */
.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute !important;
    width: 1px;
    word-wrap: normal !important;
}

.screen-reader-text:focus {
    background-color: #f1f1f1;
    border-radius: 3px;
    box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
    clip: auto !important;
    clip-path: none;
    color: #21759b;
    display: block;
    font-size: 14px;
    font-size: 0.875rem;
    font-weight: bold;
    height: auto;
    left: 5px;
    line-height: normal;
    padding: 15px 23px 14px;
    text-decoration: none;
    top: 5px;
    width: auto;
    z-index: 100000;
}

/* Skip Links */
.raywp-skip-links {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 999999;
}

.raywp-skip-link {
    position: absolute;
    left: 9999px;
    padding: 10px 20px;
    background: #000;
    color: #fff;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    font-size: 14px;
    font-weight: 600;
}

.raywp-skip-link:focus,
.raywp-skip-link:active {
    left: 0;
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Focus Indicators Enhancement */
.raywp-enhanced-focus *:focus {
    outline-offset: 2px !important;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .raywp-skip-link {
        background: #fff;
        color: #000;
        border: 2px solid #000;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ARIA Live Region */
.raywp-aria-live {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Accessibility Fixes */
.raywp-visually-hidden {
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
}

/* Form Accessibility Enhancements */
.raywp-required-indicator {
    color: #d63638;
    font-weight: bold;
    margin-left: 4px;
}

.raywp-field-description {
    font-size: 0.9em;
    color: #666;
    margin-top: 5px;
}

/* Error Messages */
.raywp-error-message {
    color: #d63638;
    font-size: 0.9em;
    margin-top: 5px;
    padding: 5px;
    background: #fee;
    border-left: 4px solid #d63638;
}

/* Success Messages */
.raywp-success-message {
    color: #008a20;
    font-size: 0.9em;
    margin-top: 5px;
    padding: 5px;
    background: #efe;
    border-left: 4px solid #008a20;
}

/* Lighthouse Accessibility Fixes */

/* Improved Skip Links */
.raywp-skip-link,
.raywp-focusable-skip-link {
    position: absolute !important;
    left: -9999px !important;
    top: 0 !important;
    z-index: 999999 !important;
    padding: 12px 20px !important;
    background: #000000 !important;
    color: #ffffff !important;
    text-decoration: none !important;
    border-radius: 0 0 4px 0 !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    border: 2px solid #ffffff !important;
    display: block !important;
    width: auto !important;
    height: auto !important;
    clip: auto !important;
    clip-path: none !important;
    overflow: visible !important;
    white-space: nowrap !important;
}

.raywp-skip-link:focus,
.raywp-skip-link:active,
.raywp-focusable-skip-link:focus,
.raywp-focusable-skip-link:active {
    left: 10px !important;
    top: 10px !important;
    outline: 3px solid #ffffff !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.9) !important;
    transform: none !important;
    clip: auto !important;
    clip-path: none !important;
}

/* Override any theme styles that might hide skip links */
.raywp-skip-link:focus,
.raywp-focusable-skip-link:focus {
    position: absolute !important;
    left: 10px !important;
    top: 10px !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: 12px 20px !important;
    opacity: 1 !important;
    visibility: visible !important;
    background: #000000 !important;
    color: #ffffff !important;
    z-index: 999999 !important;
}

/* Ensure skip links work with screen reader text class */
.skip-link.screen-reader-text:focus,
.raywp-skip-link.screen-reader-text:focus {
    background-color: #000000 !important;
    border-radius: 0 0 4px 0 !important;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.9) !important;
    clip: auto !important;
    clip-path: none !important;
    color: #ffffff !important;
    display: block !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    height: auto !important;
    left: 10px !important;
    line-height: normal !important;
    padding: 12px 20px !important;
    text-decoration: none !important;
    top: 10px !important;
    width: auto !important;
    z-index: 999999 !important;
}

/* Contrast Improvements */
.raywp-contrast-fix {
    /* Ensure sufficient contrast ratios */
    color: #1a1a1a !important;
    background-color: transparent !important;
}

.raywp-contrast-fix h2,
.raywp-contrast-fix h3,
.raywp-contrast-fix h4,
.raywp-contrast-fix h5,
.raywp-contrast-fix h6 {
    color: #1a1a1a !important;
}

/* Dark backgrounds need light text */
.raywp-contrast-fix[style*="background-color: rgb(0"],
.raywp-contrast-fix[style*="background-color: #0"],
.raywp-contrast-fix[style*="background-color: #1"],
.raywp-contrast-fix[style*="background-color: #2"],
.raywp-contrast-fix[style*="background-color: #3"],
.raywp-contrast-fix[style*="background: rgb(0"],
.raywp-contrast-fix[style*="background: #0"],
.raywp-contrast-fix[style*="background: #1"],
.raywp-contrast-fix[style*="background: #2"],
.raywp-contrast-fix[style*="background: #3"] {
    color: #ffffff !important;
}

.raywp-contrast-fix[style*="background-color: rgb(0"] h2,
.raywp-contrast-fix[style*="background-color: rgb(0"] h3,
.raywp-contrast-fix[style*="background-color: #0"] h2,
.raywp-contrast-fix[style*="background-color: #0"] h3,
.raywp-contrast-fix[style*="background-color: #1"] h2,
.raywp-contrast-fix[style*="background-color: #1"] h3,
.raywp-contrast-fix[style*="background-color: #2"] h2,
.raywp-contrast-fix[style*="background-color: #2"] h3,
.raywp-contrast-fix[style*="background-color: #3"] h2,
.raywp-contrast-fix[style*="background-color: #3"] h3 {
    color: #ffffff !important;
}

/* Carousel/Slider Region Improvements */
[role="region"][aria-label*="carousel"],
[role="region"][aria-label*="slider"] {
    /* Ensure carousel regions are properly announced */
    position: relative;
}

/* Improved Focus Indicators for All Interactive Elements */
/* Commented out - These styles should only apply when enhance_focus setting is enabled
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus,
[tabindex]:focus:not(.gform_button):not(.gform_image_button) {
    outline: 3px solid #005fcc !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 5px rgba(0, 95, 204, 0.4) !important;
}
*/

/* High Contrast Mode Enhancements */
@media (prefers-contrast: high) {
    .raywp-contrast-fix {
        color: #000000 !important;
        background-color: #ffffff !important;
    }
    
    /* Commented out - These styles should only apply when enhance_focus setting is enabled
    a:focus,
    button:focus,
    input:focus,
    select:focus,
    textarea:focus,
    [tabindex]:focus:not(.gform_button):not(.gform_image_button) {
        outline: 3px solid #000000 !important;
        outline-offset: 2px !important;
        background-color: #ffff00 !important;
        color: #000000 !important;
    }
    */
}

/* Links without visible text improvements */
/* Removed overly broad selector that was affecting Google Maps and other links with content */
/* Touch target sizing should be handled more precisely via PHP classes */
/* DISABLED: This was causing layout issues with Google Maps and other dynamically added links
a.raywp-min-touch-target {
    min-width: 44px;
    min-height: 44px;
    display: inline-block;
}
*/

/* List structure fixes */
/* Only apply list styles to actual content lists, not sliders, carousels, or navigation */
ul li:not([role]):not([class*="slide"]):not([class*="carousel"]):not([class*="slider"]),
ol li:not([role]):not([class*="slide"]):not([class*="carousel"]):not([class*="slider"]) {
    /* Exclude common slider/carousel patterns from list styling */
    list-style-position: inside;
}

/* Explicitly hide list markers for known slider/carousel elements */
ul[class*="slide"] li,
ul[class*="carousel"] li,
ul[class*="slider"] li,
.slider ul li,
.carousel ul li,
[id*="slider"] ul li,
[id*="carousel"] ul li {
    list-style: none;
}

/* Ensure wrapped elements in lists maintain proper structure */
ul li > div:only-child,
ol li > div:only-child {
    display: contents;
}

/* Form field improvements */
input[aria-label]:not([type="hidden"]),
select[aria-label],
textarea[aria-label] {
    /* Ensure form fields with aria-labels are properly sized */
    min-height: 44px;
}

/* ARIA live regions styling - only for actual alert/status messages */
.raywp-aria-alert[role="alert"],
.raywp-status-message[aria-live="polite"],
.raywp-status-message[aria-live="assertive"] {
    /* Ensure live regions are visible when they have content */
    padding: 10px;
    border-left: 4px solid #0073aa;
    background-color: #f0f0f1;
    margin: 10px 0;
}

.raywp-aria-alert[role="alert"]:empty,
.raywp-status-message[aria-live="polite"]:empty,
.raywp-status-message[aria-live="assertive"]:empty {
    /* Hide empty live regions */
    display: none !important;
}