/*
 * Accessibility Styles for Asthir Theme
 * Improves keyboard navigation, focus indicators, and screen reader support
 */

/* ==================================================
   Skip Links
   ================================================== */
.skip-link {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
    background: #000;
    color: #fff;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 3px;
    font-weight: bold;
    z-index: 100000;
    transition: all 0.3s ease;
}

.skip-link:focus {
    position: absolute;
    left: 50%;
    top: 20px;
    transform: translateX(-50%);
    width: auto;
    height: auto;
    clip: auto;
    overflow: visible;
    white-space: normal;
    background: #315ff8;
    color: #fff;
    text-decoration: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* ==================================================
   Enhanced Focus Indicators
   ================================================== */
/* Universal focus styles */
*:focus,
*:focus-visible {
    outline: 2px solid #315ff8 !important;
    outline-offset: 2px !important;
    border-radius: 3px;
    transition: outline 0.2s ease;
}

/* Keyboard navigation focus */
.js-focus-visible :focus:not(.focus-visible) {
    outline: none;
}

.js-focus-visible .focus-visible {
    outline: 2px solid #315ff8 !important;
    outline-offset: 2px !important;
}

/* Navigation focus improvements */
.main-navigation a:focus,
.main-navigation button:focus {
    background-color: #315ff8;
    color: #fff;
    outline: 2px solid #fff;
    outline-offset: -2px;
}

/* Button focus styles */
button:focus,
input[type="button"]:focus,
input[type="submit"]:focus,
input[type="reset"]:focus,
.button:focus {
    background-color: #315ff8;
    border-color: #315ff8;
    color: #fff;
    outline: 2px solid #fff;
    outline-offset: -2px;
    box-shadow: 0 0 0 3px rgba(49, 95, 248, 0.3);
}

/* Menu toggle focus */
.menu-toggle:focus {
    background-color: #315ff8;
    border-color: #315ff8;
    color: #fff;
    outline: 2px solid #fff;
    outline-offset: -2px;
}

/* Form element focus */
input:focus,
textarea:focus,
select:focus {
    border-color: #315ff8;
    outline: 2px solid #315ff8;
    outline-offset: -2px;
    box-shadow: 0 0 0 3px rgba(49, 95, 248, 0.1);
}

/* ==================================================
   Screen Reader Support
   ================================================== */
/* Screen reader only 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: 0.875rem;
    font-weight: 700;
    height: auto;
    left: 5px;
    line-height: normal;
    padding: 15px 23px 14px;
    text-decoration: none;
    top: 5px;
    width: auto;
    z-index: 100000;
}

/* ==================================================
   High Contrast Support
   ================================================== */
@media (prefers-contrast: high) {
    /* Enhanced contrast for high contrast mode */
    .site-title a {
        color: #000 !important;
        text-shadow: none;
    }
    
    .main-navigation a {
        color: #fff !important;
        background-color: #000 !important;
    }
    
    .widget-title {
        background-color: #000 !important;
        color: #fff !important;
    }
}

/* ==================================================
   Reduced Motion Support
   ================================================== */
@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;
    }
}

/* ==================================================
   Color Contrast Improvements
   ================================================== */
/* Ensure text meets WCAG contrast ratios */
.bg-dark {
    background-color: #212529 !important;
}

.bg-dark .text-white {
    color: #ffffff !important;
}

/* Widget titles accessibility */
h3.widget-title {
    background-color: #2c5530 !important; /* Higher contrast green */
    color: #ffffff !important;
    border: 1px solid #1e3a23;
}

/* Link accessibility */
a {
    text-decoration: underline;
}

a:hover,
a:focus {
    text-decoration: none;
    outline: 2px solid #315ff8;
    outline-offset: 2px;
}

/* ==================================================
   Keyboard Navigation
   ================================================== */
/* Dropdown menu keyboard navigation */
.main-navigation ul ul {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.main-navigation .focus-within > ul,
.main-navigation li:focus-within > ul {
    opacity: 1;
    visibility: visible;
}

/* Mobile menu accessibility */
.menu-toggle {
    padding: 10px 15px;
    border: 2px solid transparent;
    background-color: transparent;
    cursor: pointer;
}

.menu-toggle[aria-expanded="true"] {
    background-color: #315ff8;
    color: #fff;
}

/* ==================================================
   Form Accessibility
   ================================================== */
/* Label improvements */
label {
    font-weight: 600;
    margin-bottom: 5px;
    display: block;
}

/* Required field indicators */
.required::after {
    content: " *";
    color: #d93025;
    font-weight: bold;
    margin-left: 3px;
}

/* Error message styling */
.error-message {
    color: #d93025;
    font-size: 0.875rem;
    margin-top: 5px;
    display: block;
}

/* Success message styling */
.success-message {
    color: #137333;
    font-size: 0.875rem;
    margin-top: 5px;
    display: block;
}

/* ==================================================
   Table Accessibility
   ================================================== */
table {
    border-collapse: collapse;
    width: 100%;
}

th {
    background-color: #f8f9fa;
    font-weight: 600;
    text-align: left;
    padding: 12px;
    border: 1px solid #dee2e6;
}

td {
    padding: 12px;
    border: 1px solid #dee2e6;
}

/* ==================================================
   Image Accessibility
   ================================================== */
img {
    height: auto;
    max-width: 100%;
}

/* Decorative images */
img[alt=""],
img[role="presentation"] {
    /* These images are decorative and should be ignored by screen readers */
}

/* ==================================================
   ARIA Live Regions
   ================================================== */
.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;
}

[aria-live] {
    font-weight: normal;
}

/* ==================================================
   Print Accessibility
   ================================================== */
@media print {
    .skip-link,
    .menu-toggle,
    .main-navigation {
        display: none !important;
    }
    
    a[href^="http"]:after {
        content: " (" attr(href) ")";
        font-size: 12px;
        color: #666;
    }
}