﻿/* ========================================
   SRSD Accessibility Plugin Styles
   Version: 2.0 - Final Production
   ======================================== */

/* ==================== CORE UTILITIES ==================== */

/* Skip Link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 8px 12px;
    text-decoration: none;
    z-index: 10000;
    font-weight: bold;
    border-radius: 0 0 4px 0;
}

    .skip-link:focus {
        top: 0;
        outline: 3px solid #ffbf47;
        outline-offset: 0;
    }

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ==================== TOOLBAR STRUCTURE ==================== */

/* Toolbar Container */
.a11y-toolbar {
    position: fixed !important;
    z-index: 99999 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Position Classes */
.a11y-toolbar-top-right {
    top: 20px;
    right: 20px;
}

.a11y-toolbar-top-left {
    top: 20px;
    left: 20px;
}

.a11y-toolbar-bottom-right {
    bottom: 20px;
    right: 20px;
}

.a11y-toolbar-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Toolbar Toggle Button */
.a11y-toolbar-toggle {
    background: #0066cc;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

    .a11y-toolbar-toggle i {
        font-size: 24px;
    }

    .a11y-toolbar-toggle:hover,
    .a11y-toolbar-toggle:focus {
        background: #0052a3;
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
        transform: scale(1.05);
    }

    .a11y-toolbar-toggle:focus {
        outline: 3px solid #ffbf47;
        outline-offset: 2px;
    }

/* Toolbar Panel */
.a11y-toolbar-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    min-width: 320px;
    max-width: 360px;
    animation: slideIn 0.3s ease;
}

.a11y-toolbar-top-left .a11y-toolbar-panel,
.a11y-toolbar-top-right .a11y-toolbar-panel {
    top: 70px;
    bottom: auto;
}

.a11y-toolbar-top-left .a11y-toolbar-panel,
.a11y-toolbar-bottom-left .a11y-toolbar-panel {
    left: 0;
    right: auto;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Toolbar Header */
.a11y-toolbar-header {
    padding: 16px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

    .a11y-toolbar-header h2 {
        margin: 0;
        font-size: 16px;
        font-weight: 600;
        color: #333;
    }

/* Toolbar Content with Scrolling */
.a11y-toolbar-content {
    padding: 12px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
}

    .a11y-toolbar-content::-webkit-scrollbar {
        width: 6px;
    }

    .a11y-toolbar-content::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 3px;
    }

    .a11y-toolbar-content::-webkit-scrollbar-thumb {
        background: #888;
        border-radius: 3px;
    }

        .a11y-toolbar-content::-webkit-scrollbar-thumb:hover {
            background: #555;
        }

/* ==================== TOOLBAR SECTIONS ==================== */

/* Section Container */
.a11y-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e9ecef;
}

    .a11y-section:last-child {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }

/* Section Title */
.a11y-section-title {
    font-size: 14px;
    font-weight: 600;
    color: #495057;
    margin: 0 0 12px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

    .a11y-section-title i {
        font-size: 16px;
        color: #0066cc;
    }

/* ==================== CONTROLS ==================== */

/* Control Container */
.a11y-control {
    margin-bottom: 12px;
}

    .a11y-control:last-child {
        margin-bottom: 0;
    }

    .a11y-control label {
        display: block;
        font-size: 13px;
        font-weight: 600;
        margin-bottom: 8px;
        color: #555;
    }

/* Button Group */
.a11y-btn-group {
    display: flex;
    gap: 8px;
}

/* Buttons */
.a11y-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    justify-content: center;
    font-weight: 500;
    white-space: nowrap;
}

    .a11y-btn:hover {
        background: #e9ecef;
        border-color: #adb5bd;
    }

    .a11y-btn:focus {
        outline: 3px solid #0066cc;
        outline-offset: 2px;
        background: #e9ecef;
    }

    .a11y-btn:active {
        transform: scale(0.98);
    }

    .a11y-btn[aria-pressed="true"] {
        background: #0066cc;
        border-color: #0066cc;
        color: #fff;
    }

    .a11y-btn i {
        font-size: 14px;
        flex-shrink: 0;
    }

.a11y-btn-sm {
    padding: 6px 10px;
    font-size: 13px;
}

/* Font Sizer Specific */
.a11y-font-sizer {
    display: flex;
    flex-direction: column;
}

.a11y-font-size-value {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-top: 8px;
}

/* Reset Button */
.a11y-reset {
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
    width: 100%;
}

    .a11y-reset:hover {
        background: #c82333;
        border-color: #bd2130;
    }

/* Text-to-Speech Hint */
.a11y-tts-hint {
    font-size: 11px;
    color: #6c757d;
    font-style: italic;
    margin-top: 6px;
    padding: 6px;
    background: #f8f9fa;
    border-radius: 4px;
    text-align: center;
}

/* ==================== ACCESSIBILITY FEATURES ==================== */

/* Enhanced Focus Indicators - Visible and accessible */
body.a11y-focus-indicators *:focus {
    /* Primary outline */
    outline: 3px solid #ffbf47 !important;
    outline-offset: 2px !important;
    /* Backup box-shadow (doesn't get clipped like outline) */
    box-shadow: 0 0 0 3px rgba(255, 191, 71, 0.6) !important;
    /* Ensure element scrolls into view properly */
    scroll-margin: 8px !important;
    scroll-padding: 8px !important;
}

/* Stronger focus for interactive elements */
body.a11y-focus-indicators button:focus,
body.a11y-focus-indicators a:focus,
body.a11y-focus-indicators input:focus,
body.a11y-focus-indicators select:focus,
body.a11y-focus-indicators textarea:focus,
body.a11y-focus-indicators [tabindex]:focus {
    /* Double outline effect */
    outline: 3px solid #ffbf47 !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 3px rgba(255, 191, 71, 0.9), 0 0 0 7px rgba(255, 191, 71, 0.4) !important;
    /* Ensure visibility */
    position: relative !important;
    z-index: 1000 !important;
}

/* Prevent outline clipping in containers */
body.a11y-focus-indicators {
    /* Ensure parent containers don't clip outlines */
}

    body.a11y-focus-indicators *:focus-visible {
        /* Modern browsers with focus-visible support */
        outline: 3px solid #ffbf47 !important;
        outline-offset: 3px !important;
    }

    /* Special handling for elements in overflow containers */
    body.a11y-focus-indicators [style*="overflow"]:focus-within {
        overflow: visible !important;
    }

/* Text Spacing - WCAG 2.1 SC 1.4.12 */
body.a11y-text-spacing * {
    line-height: 1.5 !important;
    letter-spacing: 0.12em !important;
    word-spacing: 0.16em !important;
}

body.a11y-text-spacing p,
body.a11y-text-spacing li {
    margin-bottom: 2em !important;
}

/* Text Align Left */
body.a11y-text-align,
body.a11y-text-align * {
    text-align: left !important;
}

/* Readable Font */
body.a11y-readable-font,
body.a11y-readable-font * {
    font-family: 'Arial', 'Helvetica Neue', 'Helvetica', sans-serif !important;
    letter-spacing: 0.03em !important;
    line-height: 1.6 !important;
}

/* Dyslexia Font */
body.a11y-dyslexia-font,
body.a11y-dyslexia-font * {
    font-family: 'OpenDyslexic', 'Comic Sans MS', 'Arial', sans-serif !important;
}

/* Reduce Motion - WCAG 2.1 SC 2.3.3 */
body.a11y-reduce-motion,
body.a11y-reduce-motion *,
body.a11y-reduce-motion *::before,
body.a11y-reduce-motion *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}

/* High Contrast Mode */
body.a11y-high-contrast {
    background: #000 !important;
    color: #fff !important;
}

    body.a11y-high-contrast *:not(svg):not(path):not(use):not(i) {
        background-color: #000 !important;
        color: #ffff00 !important;
        border-color: #fff !important;
    }

    body.a11y-high-contrast a {
        color: #00ff00 !important;
        text-decoration: underline !important;
    }

    body.a11y-high-contrast button,
    body.a11y-high-contrast .btn {
        background-color: #fff !important;
        color: #000 !important;
        border: 2px solid #fff !important;
    }

    body.a11y-high-contrast .a11y-toolbar-toggle {
        background: #fff !important;
        color: #000 !important;
    }

    body.a11y-high-contrast .a11y-toolbar-panel {
        background: #000 !important;
        border: 2px solid #fff !important;
    }

    body.a11y-high-contrast img {
        filter: contrast(1.5) brightness(1.2);
    }

/* Grayscale - FIXED: Apply to content wrapper only */
body.a11y-grayscale {
    background: #fff;
}

    body.a11y-grayscale #a11y-content-wrapper {
        filter: grayscale(100%);
        -webkit-filter: grayscale(100%);
    }

/* Negative Contrast / Dark Mode - FIXED: Apply to content wrapper only */
body.a11y-negative-contrast {
    background: #000 !important;
}

    body.a11y-negative-contrast #a11y-content-wrapper {
        filter: invert(1) hue-rotate(180deg);
        background: transparent;
    }

        body.a11y-negative-contrast #a11y-content-wrapper img,
        body.a11y-negative-contrast #a11y-content-wrapper video,
        body.a11y-negative-contrast #a11y-content-wrapper [style*="background-image"] {
            filter: invert(1) hue-rotate(180deg);
        }

    /* FIXED: Ensure toolbar is never affected by filters */
    body.a11y-grayscale .a11y-toolbar,
    body.a11y-negative-contrast .a11y-toolbar,
    body.a11y-grayscale .a11y-toolbar *,
    body.a11y-negative-contrast .a11y-toolbar * {
        filter: none !important;
        -webkit-filter: none !important;
    }

/* Underline Links */
body.a11y-underline-links a {
    text-decoration: underline !important;
}

/* Highlight Links */
body.a11y-highlight-links a {
    background-color: #ffff00 !important;
    color: #000 !important;
    /* padding: 2px 4px !important;*/
    padding: 2px 4px;
    border-radius: 2px !important;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

    body.a11y-highlight-links a:hover {
        background-color: #ffeb3b !important;
    }

/* Hide Images */
body.a11y-hide-images img:not(.a11y-toolbar *):not(.a11y-toolbar-toggle *) {
    opacity: 0.1 !important;
    position: relative;
}

body.a11y-hide-images img[alt]:not(.a11y-toolbar *)::after {
    content: "🖼️ " attr(alt);
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 1;
    font-size: 14px;
    color: #666;
    padding: 10px;
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* Big Cursor */
body.a11y-big-cursor,
body.a11y-big-cursor * {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40"><path fill="black" stroke="white" stroke-width="2" d="M3 3 L3 35 L13 25 L19 38 L23 36 L17 23 L30 23 Z"/></svg>') 2 2, auto !important;
}

    body.a11y-big-cursor a,
    body.a11y-big-cursor button {
        cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40"><path fill="blue" stroke="white" stroke-width="2" d="M20 5 L25 18 L40 20 L25 22 L20 35 L15 22 L0 20 L15 18 Z"/></svg>') 20 20, pointer !important;
    }

/* Reading Guide Line - Using unique class */
.a11y-reading-guide-line {
    position: fixed !important;
    left: 0 !important;
    width: 100% !important;
    height: 3px !important;
    background: rgba(255, 0, 0, 0.7) !important;
    pointer-events: none !important;
    z-index: 99998 !important;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.8) !important;
    will-change: top !important;
}

    /* Optional: Add gradient effect above and below */
    .a11y-reading-guide-line::before {
        content: '' !important;
        position: absolute !important;
        top: -30px !important;
        left: 0 !important;
        right: 0 !important;
        height: 30px !important;
        background: linear-gradient(to bottom, transparent, rgba(255, 0, 0, 0.15)) !important;
    }

    .a11y-reading-guide-line::after {
        content: '' !important;
        position: absolute !important;
        bottom: -30px !important;
        left: 0 !important;
        right: 0 !important;
        height: 30px !important;
        background: linear-gradient(to top, transparent, rgba(255, 0, 0, 0.15)) !important;
    }

/* ==================== RESPONSIVE DESIGN ==================== */

/* Mobile Responsive */
@media (max-width: 576px) {
    .a11y-toolbar-panel {
        min-width: 280px;
        max-width: calc(100vw - 40px);
    }

    .a11y-toolbar-toggle {
        width: 48px;
        height: 48px;
    }

        .a11y-toolbar-toggle i {
            font-size: 20px;
        }

    .a11y-btn {
        padding: 6px 10px;
        font-size: 13px;
    }

        .a11y-btn i {
            font-size: 12px;
        }

    .a11y-section-title {
        font-size: 13px;
    }

    .a11y-tts-hint {
        font-size: 10px;
    }
}

/* ==================== PRINT & MOTION PREFERENCES ==================== */

/* Print Styles */
@media print {
    .a11y-toolbar,
    .skip-link,
    .a11y-reading-guide {
        display: none !important;
    }
}

/* Reduced Motion Preference */
@media (prefers-reduced-motion: reduce) {
    .a11y-toolbar-panel {
        animation: none;
    }

    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
