/* ============================================================
   ACCESSIBILITY STYLES - WCAG 2.1 AA Compliance
   Kesar Securities - Global Accessibility Stylesheet
   ============================================================ */

/* ===== 1. Skip Navigation Link (WCAG 2.4.1) ===== */
.skip-to-main {
    position: absolute;
    top: -100%;
    left: 16px;
    background: #2660B5;
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 0 0 8px 8px;
    font-weight: 700;
    font-size: 1rem;
    z-index: 10000;
    transition: top 0.2s ease;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.skip-to-main:focus {
    top: 0;
    color: #ffffff;
    outline: 3px solid #ffd700;
    outline-offset: 2px;
}

/* ===== 2. Screen Reader Only Utility (WCAG 1.3.1) ===== */
.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;
}

/* Show element on focus (for skip links and similar) */
.sr-only-focusable:focus,
.sr-only-focusable:active {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: inherit !important;
    margin: inherit !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
}

/* ===== 3. Focus Indicators (WCAG 2.4.7) ===== */
/* Enhanced focus outline for keyboard users */
*:focus-visible {
    outline: 3px solid #2660B5 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 5px rgba(38, 96, 181, 0.25) !important;
}

/* Remove default focus for mouse clicks */
*:focus:not(:focus-visible) {
    outline: none !important;
    box-shadow: none !important;
}

/* Special focus styles for links */
a:focus-visible {
    outline: 3px solid #2660B5 !important;
    outline-offset: 2px !important;
    border-radius: 2px;
}

/* Focus styles for buttons */
button:focus-visible,
.btn_theme:focus-visible,
.btn_theme_active:focus-visible {
    outline: 3px solid #2660B5 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 5px rgba(38, 96, 181, 0.25) !important;
}

/* Focus styles for form inputs */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid #2660B5 !important;
    outline-offset: 0 !important;
    border-color: #2660B5 !important;
    box-shadow: 0 0 0 4px rgba(38, 96, 181, 0.2) !important;
}

/* ===== 4. High Contrast / Forced Colors (WCAG 1.4.11) ===== */
@media (forced-colors: active) {
    .skip-to-main {
        border: 2px solid ButtonText;
    }

    .skip-to-main:focus {
        outline: 3px solid Highlight;
    }

    a:focus-visible,
    button:focus-visible {
        outline: 3px solid Highlight !important;
    }

    .btn_theme,
    .btn_theme_active {
        border: 1px solid ButtonText;
    }
}

/* ===== 5. Reduced Motion (WCAG 2.3.1) ===== */
@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;
    }

    .wow {
        animation: none !important;
        visibility: visible !important;
    }

    .preloader {
        display: none !important;
    }
}

/* ===== 6. Live Region Styles ===== */
[role="alert"],
[role="status"],
[aria-live] {
    /* Ensure live regions are not visually hidden if they have content */
}

.aria-live-region {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== 7. Preloader Accessibility ===== */
.preloader[aria-hidden="true"] {
    display: none;
}

/* ===== 8. Scroll to Top Button Enhancement ===== */
.scrollToTop:focus-visible {
    outline: 3px solid #ffffff !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 5px rgba(38, 96, 181, 0.5) !important;
}

/* ===== 9. Improved Link Visibility (WCAG 1.4.1) ===== */
/* Ensure links in body text are distinguishable by more than color */
main a:not(.btn_theme):not(.btn_theme_active):not(.nav-link) {
    text-decoration: underline;
    text-underline-offset: 2px;
}

main a:not(.btn_theme):not(.btn_theme_active):not(.nav-link):hover {
    text-decoration-thickness: 2px;
}

/* ===== 10. Text Spacing Override Support (WCAG 1.4.12) ===== */
/* Ensure content remains accessible with increased text spacing */
body {
    word-spacing: normal;
    letter-spacing: normal;
}

/* ===== 11. Target Size Enhancement (WCAG 2.5.5) ===== */
/* Ensure minimum touch target size of 44x44px for interactive elements */
.social a,
.social_box,
.scrollToTop {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ===== 12. Accessibility Widget Trigger ===== */
.a11y-widget-trigger {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: #2660B5;
    color: #ffffff;
    border: none;
    border-radius: 50%;
    font-size: 1.6rem;
    cursor: pointer;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    transition: background 0.3s ease, transform 0.3s ease;
}

.a11y-widget-trigger:hover {
    background: #1a4a8a;
    transform: scale(1.1);
}

.a11y-widget-trigger:focus-visible {
    outline: 3px solid #ffd700 !important;
    outline-offset: 2px !important;
}

.a11y-widget-trigger .a11y-icon {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

/* ===== 13. Accessibility Widget Panel ===== */
.a11y-widget-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: #ffffff;
    z-index: 10002;
    box-shadow: -4px 0 30px rgba(0, 0, 0, 0.25);
    transition: right 0.35s ease;
    overflow-y: auto;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.a11y-widget-panel.open {
    right: 0;
    pointer-events: auto;
}

.a11y-widget-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10001;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.a11y-widget-overlay.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.a11y-panel-header {
    background: #2660B5;
    color: #ffffff;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1;
}

.a11y-panel-header h2 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.a11y-panel-header h2 svg {
    width: 24px;
    height: 24px;
    fill: #ffffff;
}

.a11y-panel-close {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.a11y-panel-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.a11y-panel-body {
    padding: 16px 20px 100px;
}

.a11y-section {
    margin-bottom: 24px;
}

.a11y-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #6b7280;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid #e5e7eb;
}

.a11y-options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.a11y-option-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 8px;
    background: #f3f4f6;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
    text-align: center;
    min-height: 80px;
}

.a11y-option-btn:hover {
    background: #e0e7ff;
    border-color: #2660B5;
}

.a11y-option-btn.active {
    background: #dbeafe;
    border-color: #2660B5;
    color: #1e40af;
    box-shadow: 0 0 0 3px rgba(38, 96, 181, 0.15);
}

.a11y-option-btn svg,
.a11y-option-btn .a11y-opt-icon {
    width: 28px;
    height: 28px;
    font-size: 1.5rem;
}

.a11y-option-btn span {
    font-size: 0.75rem;
    line-height: 1.2;
}

/* Font size slider */
.a11y-font-control {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #f3f4f6;
    border-radius: 12px;
    border: 2px solid #e5e7eb;
}

.a11y-font-control label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}

.a11y-font-control .a11y-font-btns {
    display: flex;
    gap: 6px;
    flex: 1;
    justify-content: flex-end;
}

.a11y-font-btn {
    width: 38px;
    height: 38px;
    border: 2px solid #d1d5db;
    background: #ffffff;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.85rem;
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.a11y-font-btn:hover {
    border-color: #2660B5;
    background: #e0e7ff;
}

.a11y-font-btn.active {
    background: #2660B5;
    color: #ffffff;
    border-color: #2660B5;
}

/* Reset button */
.a11y-reset-btn {
    display: block;
    width: 100%;
    padding: 14px;
    background: #fee2e2;
    border: 2px solid #fca5a5;
    border-radius: 12px;
    color: #dc2626;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    margin-top: 8px;
}

.a11y-reset-btn:hover {
    background: #fecaca;
    border-color: #f87171;
}

/* ===== 14. Font Size Override Classes ===== */
body.a11y-font-1 { font-size: 100% !important; }
body.a11y-font-2 { font-size: 115% !important; }
body.a11y-font-3 { font-size: 130% !important; }
body.a11y-font-4 { font-size: 150% !important; }

/* ===== 15. High Contrast Mode ===== */
body.a11y-high-contrast {
    filter: contrast(1.5);
}
body.a11y-high-contrast img {
    filter: contrast(0.75);
}

/* ===== 16. Invert Colors ===== */
body.a11y-invert {
    filter: invert(1) hue-rotate(180deg);
}
body.a11y-invert img,
body.a11y-invert video {
    filter: invert(1) hue-rotate(180deg);
}

/* ===== 17. Grayscale ===== */
body.a11y-grayscale {
    filter: grayscale(1);
}

/* ===== 18. Highlight Links ===== */
body.a11y-highlight-links a {
    outline: 3px solid #ff6600 !important;
    outline-offset: 2px !important;
    background: #fff3cd !important;
    color: #000000 !important;
    text-decoration: underline !important;
}

/* ===== 19. Big Cursor ===== */
body.a11y-big-cursor,
body.a11y-big-cursor * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'%3E%3Cpath d='M5 3l14 8-6.5 1.5L11 19z' fill='%23000' stroke='%23fff' stroke-width='1'/%3E%3C/svg%3E"), auto !important;
}

/* ===== 20. Text Spacing ===== */
body.a11y-text-spacing {
    letter-spacing: 0.12em !important;
    word-spacing: 0.16em !important;
}
body.a11y-text-spacing p,
body.a11y-text-spacing li,
body.a11y-text-spacing span,
body.a11y-text-spacing td {
    line-height: 1.8 !important;
}

/* ===== 21. Dyslexia-Friendly Font ===== */
body.a11y-dyslexia-font,
body.a11y-dyslexia-font * {
    font-family: 'OpenDyslexic', 'Comic Sans MS', 'Verdana', sans-serif !important;
}

/* ===== 22. Reading Guide ===== */
.a11y-reading-guide {
    position: fixed;
    left: 0;
    width: 100%;
    height: 12px;
    background: rgba(255, 204, 0, 0.4);
    border-top: 2px solid rgba(255, 153, 0, 0.6);
    border-bottom: 2px solid rgba(255, 153, 0, 0.6);
    pointer-events: none;
    z-index: 99999;
    display: none;
}

body.a11y-reading-guide-on .a11y-reading-guide {
    display: block;
}

/* ===== 23. Stop Animations ===== */
body.a11y-stop-animations *:not(.preloader):not(.loader),
body.a11y-stop-animations *:not(.preloader):not(.loader)::before,
body.a11y-stop-animations *:not(.preloader):not(.loader)::after {
    animation: none !important;
    transition: none !important;
}

/* Always allow preloader to be hidden */
body.a11y-stop-animations .preloader[style*="display: none"],
body.a11y-stop-animations .preloader[style*="opacity: 0"] {
    display: none !important;
}

/* ===== 24. Hide Images (for screen reader users who want less clutter) ===== */
body.a11y-hide-images img:not(.logo):not([src*="logo"]) {
    opacity: 0.1;
}

/* ===== 25. Saturation ===== */
body.a11y-low-saturation {
    filter: saturate(0.5);
}
body.a11y-high-saturation {
    filter: saturate(2);
}

/* ===== 26. Combined filter handling (only one filter at a time) ===== */
body.a11y-high-contrast.a11y-grayscale { filter: contrast(1.5) grayscale(1); }
body.a11y-high-contrast.a11y-low-saturation { filter: contrast(1.5) saturate(0.5); }

/* ===== 27. Text-to-Speech Player ===== */
.a11y-tts-section {
    background: #eef2ff;
    border: 2px solid #c7d2fe;
    border-radius: 12px;
    padding: 16px;
}

.a11y-tts-section .a11y-section-title {
    border-bottom-color: #c7d2fe;
}

.a11y-tts-start-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 20px;
    background: #2660B5;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.a11y-tts-start-btn:hover {
    background: #1a4a8a;
}

.a11y-tts-start-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.a11y-tts-speed {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    gap: 8px;
}

.a11y-tts-speed label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}

.a11y-tts-speed select {
    padding: 6px 10px;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    background: #ffffff;
    color: #374151;
    cursor: pointer;
}

/* Floating TTS Player Bar */
.a11y-tts-player {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #1e293b;
    color: #ffffff;
    z-index: 10003;
    padding: 12px 20px;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 16px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.a11y-tts-player.active {
    display: flex;
}

.a11y-tts-player-btn {
    background: none;
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: background 0.2s, border-color 0.2s;
}

.a11y-tts-player-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
}

.a11y-tts-player-btn.playing {
    background: #2660B5;
    border-color: #2660B5;
}

.a11y-tts-player-text {
    flex: 1;
    max-width: 500px;
    font-size: 0.85rem;
    line-height: 1.4;
    color: #94a3b8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.a11y-tts-player-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #94a3b8;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: background 0.2s, color 0.2s;
}

.a11y-tts-player-close:hover {
    background: #dc2626;
    color: #ffffff;
}

/* TTS highlight on current text being read */
.a11y-tts-highlight {
    background: #fef08a !important;
    color: #000000 !important;
    box-shadow: 0 0 0 3px #fef08a;
    border-radius: 3px;
    transition: background 0.15s;
}

@media (max-width: 600px) {
    .a11y-tts-player {
        flex-wrap: wrap;
        gap: 10px;
        padding: 10px 14px;
    }
    .a11y-tts-player-text {
        order: 3;
        max-width: 100%;
        width: 100%;
        text-align: center;
    }
}

/* ===== 28. Panel responsive ===== */
@media (max-width: 480px) {
    .a11y-widget-panel {
        width: 100vw;
        right: -100vw;
    }
    .a11y-options-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .a11y-option-btn {
        padding: 10px 6px;
        min-height: 70px;
    }
}
