/**
 * YallaBalagan Accessibility Toolbar Styles
 * Version: 1.0
 */

/* ========================================
   OpenDyslexic Font Definition
   ======================================== */
@font-face {
    font-family: 'OpenDyslexic';
    src: url('/static/fonts/OpenDyslexic/OpenDyslexic-Regular.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'OpenDyslexic';
    src: url('/static/fonts/OpenDyslexic/OpenDyslexic-Bold.woff2') format('woff2');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

/* ========================================
   Accessibility Button (Trigger)
   ======================================== */
.a11y-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: var(--primary, #6366f1);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.a11y-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    background: var(--primary-dark, #4f46e5);
}

.a11y-button:focus {
    outline: 3px solid #FFD700;
    outline-offset: 2px;
}

/* RTL positioning */
html[dir="rtl"] .a11y-button {
    right: auto;
    left: 20px;
}

/* ========================================
   Accessibility Panel (Toolbar)
   ======================================== */
.a11y-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 360px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.a11y-panel:not([hidden]) {
    transform: translateX(0);
}

/* RTL panel positioning */
html[dir="rtl"] .a11y-panel {
    right: auto;
    left: 0;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    transform: translateX(-100%);
}

html[dir="rtl"] .a11y-panel:not([hidden]) {
    transform: translateX(0);
}

/* ========================================
   Panel Header
   ======================================== */
.a11y-panel-header {
    padding: 1.5rem;
    border-bottom: 2px solid var(--gray-200, #e5e7eb);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--gray-50, #f9fafb);
}

.a11y-panel-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--gray-900, #111827);
}

.a11y-header-controls {
    display: flex;
    gap: 0.5rem;
}

.a11y-lang-toggle,
.a11y-close {
    background: white;
    border: 1px solid var(--gray-300, #d1d5db);
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700, #374151);
    transition: background 0.2s, border-color 0.2s;
}

.a11y-lang-toggle:hover,
.a11y-close:hover {
    background: var(--gray-100, #f3f4f6);
    border-color: var(--gray-400, #9ca3af);
}

.a11y-close {
    font-size: 1.5rem;
    line-height: 1;
    padding: 0.25rem 0.75rem;
}

/* ========================================
   Panel Body
   ======================================== */
.a11y-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* Section */
.a11y-section {
    margin-bottom: 2rem;
}

.a11y-section:last-child {
    margin-bottom: 0;
}

.a11y-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-900, #111827);
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
}

/* Control */
.a11y-control {
    margin-bottom: 1rem;
}

.a11y-control label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700, #374151);
    margin-bottom: 0.5rem;
}

/* ========================================
   Button Group (Multi-option controls)
   ======================================== */
.a11y-button-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 0.5rem;
}

.a11y-option {
    background: white;
    border: 2px solid var(--gray-300, #d1d5db);
    border-radius: 0.375rem;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700, #374151);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.a11y-option:hover {
    background: var(--gray-50, #f9fafb);
    border-color: var(--primary, #6366f1);
}

.a11y-option.active {
    background: var(--primary, #6366f1);
    color: white;
    border-color: var(--primary, #6366f1);
}

.a11y-option:focus {
    outline: 2px solid var(--primary, #6366f1);
    outline-offset: 2px;
}

/* ========================================
   Toggle Switch Controls
   ======================================== */
.a11y-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    border: 2px solid var(--gray-300, #d1d5db);
    border-radius: 0.5rem;
    padding: 0.875rem 1rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--gray-700, #374151);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.a11y-toggle:hover {
    background: var(--gray-50, #f9fafb);
    border-color: var(--primary, #6366f1);
}

.a11y-toggle.active {
    background: var(--primary, #6366f1);
    color: white;
    border-color: var(--primary, #6366f1);
}

.a11y-toggle:focus {
    outline: 2px solid var(--primary, #6366f1);
    outline-offset: 2px;
}

.a11y-toggle-indicator {
    width: 44px;
    height: 24px;
    background: var(--gray-300, #d1d5db);
    border-radius: 12px;
    position: relative;
    transition: background 0.2s;
}

.a11y-toggle-indicator::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.a11y-toggle.active .a11y-toggle-indicator {
    background: white;
}

.a11y-toggle.active .a11y-toggle-indicator::after {
    transform: translateX(20px);
    background: var(--primary, #6366f1);
}

/* ========================================
   Panel Footer
   ======================================== */
.a11y-panel-footer {
    padding: 1.5rem;
    border-top: 2px solid var(--gray-200, #e5e7eb);
    background: var(--gray-50, #f9fafb);
}

.a11y-reset {
    width: 100%;
    background: var(--danger, #ef4444);
    color: white;
    border: none;
    border-radius: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.a11y-reset:hover {
    background: #dc2626;
}

.a11y-reset:focus {
    outline: 2px solid var(--danger, #ef4444);
    outline-offset: 2px;
}

/* ========================================
   Reading Guide
   ======================================== */
.a11y-reading-guide {
    position: fixed;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255, 215, 0, 0.6);
    pointer-events: none;
    z-index: 9997;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.8);
}

/* ========================================
   Accessibility Feature Classes
   ======================================== */

/* Font Size Scaling */
html {
    --a11y-font-scale: 1;
    --a11y-line-height: 1.6;
}

/* Contrast Modes */
html.a11y-contrast-dark {
    background: #000 !important;
}

html.a11y-contrast-dark body {
    background: #000 !important;
    color: #fff !important;
}

html.a11y-contrast-dark a {
    color: #FFD700 !important;
}

html.a11y-contrast-dark .event-card,
html.a11y-contrast-dark .event-detail,
html.a11y-contrast-dark header,
html.a11y-contrast-dark footer {
    background: #1a1a1a !important;
    color: #fff !important;
    border-color: #333 !important;
}

html.a11y-contrast-light {
    background: #fff !important;
}

html.a11y-contrast-light body {
    background: #fff !important;
    color: #000 !important;
}

html.a11y-contrast-light a {
    color: #0000EE !important;
}

html.a11y-contrast-light .event-card,
html.a11y-contrast-light .event-detail,
html.a11y-contrast-light header,
html.a11y-contrast-light footer {
    background: #fff !important;
    color: #000 !important;
    border-color: #ccc !important;
}

html.a11y-contrast-inverted {
    filter: invert(1) hue-rotate(180deg);
}

html.a11y-contrast-inverted img,
html.a11y-contrast-inverted video {
    filter: invert(1) hue-rotate(180deg);
}

/* Text Spacing */
html.a11y-text-spacing * {
    line-height: 1.8 !important;
    letter-spacing: 0.12em !important;
    word-spacing: 0.16em !important;
}

html.a11y-text-spacing p {
    margin-bottom: 2em !important;
}

/* Hide Images */
html.a11y-hide-images img:not([data-critical]) {
    display: none !important;
}

/* Highlight Links */
html.a11y-highlight-links a {
    background: rgba(255, 235, 59, 0.3) !important;
    text-decoration: underline !important;
    text-decoration-thickness: 2px !important;
    padding: 2px 4px !important;
    border-radius: 2px !important;
}

/* Keyboard Navigation Enhanced Focus */
html.a11y-keyboard-nav *:focus,
html.a11y-keyboard-nav *:focus-visible {
    outline: 3px solid #FFD700 !important;
    outline-offset: 2px !important;
}

/* Dyslexic Font */
html.a11y-dyslexic-font,
html.a11y-dyslexic-font * {
    font-family: 'OpenDyslexic', -apple-system, BlinkMacSystemFont, sans-serif !important;
}

/* Reduced Motion */
html.a11y-reduced-motion *,
html.a11y-reduced-motion *::before,
html.a11y-reduced-motion *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

/* Pause Animations */
html.a11y-pause-animations * {
    animation-play-state: paused !important;
}

/* ========================================
   Mobile Responsive
   ======================================== */
@media (max-width: 768px) {
    .a11y-button {
        width: 56px;
        height: 56px;
        bottom: 16px;
        right: 16px;
    }

    html[dir="rtl"] .a11y-button {
        right: auto;
        left: 16px;
    }

    .a11y-panel {
        width: 100%;
        height: 75vh;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
    }

    .a11y-panel:not([hidden]) {
        transform: translateY(0);
    }

    html[dir="rtl"] .a11y-panel {
        transform: translateY(100%);
    }

    html[dir="rtl"] .a11y-panel:not([hidden]) {
        transform: translateY(0);
    }

    .a11y-panel-header h2 {
        font-size: 1.25rem;
    }

    .a11y-panel-body {
        padding: 1rem;
    }

    .a11y-button-group {
        grid-template-columns: repeat(2, 1fr);
    }

    .a11y-section {
        margin-bottom: 1.5rem;
    }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .a11y-button,
    .a11y-panel,
    .a11y-reading-guide {
        display: none !important;
    }

    html {
        --a11y-font-scale: 1 !important;
        --a11y-line-height: 1.6 !important;
    }

    html.a11y-contrast-dark,
    html.a11y-contrast-light,
    html.a11y-contrast-inverted {
        filter: none !important;
        background: white !important;
        color: black !important;
    }
}

/* ========================================
   Browser Preference Support
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .a11y-panel,
    .a11y-button {
        transition: none;
    }
}
