/**
 * The Events Calendar - Accessibility Fixes
 * CSS for accessibility enhancements
 * Version: 1.1.0
 */

/* Screen reader only content */
.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.focusable:active,
.sr-only.focusable:focus,
.screen-reader-text:focus {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* Skip links */
.skip-link {
    background-color: #f1f1f1;
    box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.2);
    color: #21759b;
    display: block;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 14px;
    font-weight: 700;
    left: -9999em;
    outline: none;
    padding: 15px 23px 14px;
    text-decoration: none;
    text-transform: none;
    top: -9999em;
}

.skip-link:focus {
    clip: auto;
    height: auto;
    left: 6px;
    top: 7px;
    width: auto;
    z-index: 100000;
}

/* Enhanced focus styles for keyboard navigation */
.has-keyboard-focus,
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus,
[tabindex="0"]:focus {
    outline: 2px solid #0073aa !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #0073aa !important;
}

/* Remove outline on mouse click */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible),
[tabindex]:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}

/* Calendar specific focus improvements */
.fc-button:focus,
.tribe-events-button:focus {
    outline: 2px solid #0073aa !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #0073aa !important;
    position: relative;
    z-index: 10;
}

/* Event items focus */
.tribe-events-calendar-list__event-row:focus,
.fc-event:focus {
    outline: 2px solid #0073aa !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #0073aa !important;
    z-index: 10;
}

/* Modal accessibility improvements */
.eaelec-modal[role="dialog"],
.tribe-modal[role="dialog"] {
    /* Ensure modal is properly announced */
}

.eaelec-modal:focus,
.tribe-modal:focus {
    outline: none;
}

/* Calendar table improvements */
.fc-daygrid-day:focus,
.fc-timegrid-slot:focus {
    outline: 2px solid #0073aa !important;
    outline-offset: -2px !important;
    position: relative;
    z-index: 5;
}

/* Column header improvements */
.fc-col-header-cell {
    /* Ensure proper header semantics */
}

.fc-col-header-cell-cushion {
    /* Ensure content is accessible */
    display: block;
    padding: 8px 4px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .has-keyboard-focus,
    a:focus,
    button:focus,
    [tabindex="0"]:focus {
        outline: 3px solid #000 !important;
        outline-offset: 2px !important;
    }
}

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

/* Dark mode support for focus indicators */
@media (prefers-color-scheme: dark) {
    .has-keyboard-focus,
    a:focus,
    button:focus,
    [tabindex="0"]:focus {
        outline-color: #4a9eff !important;
        box-shadow: 0 0 0 2px #1a1a1a, 0 0 0 4px #4a9eff !important;
    }
    
    .skip-link {
        background-color: #1a1a1a;
        color: #4a9eff;
    }
}

/* Live region for announcements */
#tec-live-announcer {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Ensure interactive elements are clearly identifiable */
.fc-event,
.tribe-events-calendar-list__event-row {
    cursor: pointer;
}

/* Improve clickable area for better accessibility */
.fc-col-header-cell-cushion,
.fc-daygrid-day-top {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ARIA live region styling */
[aria-live="polite"],
[aria-live="assertive"] {
    /* Ensure live regions are properly positioned */
    position: relative;
}

/* Error message accessibility */
.tribe-events-error,
[role="alert"] {
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid #dc3545;
    border-radius: 4px;
    background-color: #f8d7da;
    color: #721c24;
}

/* Loading state announcement */
.tribe-events-loading[aria-busy="true"] {
    /* Ensure loading state is properly conveyed */
    position: relative;
}

.tribe-events-loading[aria-busy="true"]::after {
    content: 'Loading...';
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
