/* ============================================
   Accessibility Widget Styles
   ============================================ */

/* --- Floating Toggle Button --- */
.a11y-toggle {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9999;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: #2563eb;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

[dir="rtl"] .a11y-toggle {
    left: auto;
    right: 20px;
}

.a11y-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(37, 99, 235, 0.5);
}

.a11y-toggle:focus-visible {
    outline: 3px solid white;
    outline-offset: 3px;
}

.a11y-toggle svg {
    width: 28px;
    height: 28px;
}

/* --- Panel --- */
.a11y-panel {
    position: fixed;
    bottom: 88px;
    left: 20px;
    z-index: 9998;
    width: 320px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    background: #1a1a2e;
    border: 1px solid #2a2a40;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    padding: 0;
    display: none;
}

[dir="rtl"] .a11y-panel {
    left: auto;
    right: 20px;
}

.a11y-panel.open {
    display: block;
}

.a11y-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #2a2a40;
}

.a11y-panel-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #f0f0f2;
    display: flex;
    align-items: center;
    gap: 8px;
}

.a11y-panel-title svg {
    width: 22px;
    height: 22px;
    color: #2563eb;
}

.a11y-panel-close {
    background: none;
    border: none;
    color: #8b8b96;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 1.3rem;
    transition: background 0.15s ease, color 0.15s ease;
}

.a11y-panel-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #f0f0f2;
}

.a11y-panel-close:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* --- Panel Body --- */
.a11y-panel-body {
    padding: 12px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* --- Widget Buttons --- */
.a11y-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid transparent;
    border-radius: 10px;
    color: #c8c8d0;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    text-align: inherit;
    font-family: inherit;
}

.a11y-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #f0f0f2;
}

.a11y-btn:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.a11y-btn.active {
    background: rgba(37, 99, 235, 0.15);
    border-color: rgba(37, 99, 235, 0.4);
    color: #93bbfc;
}

.a11y-btn-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.a11y-btn.active .a11y-btn-icon {
    background: rgba(37, 99, 235, 0.25);
}

/* --- Font Size Row --- */
.a11y-font-row {
    display: flex;
    gap: 6px;
}

.a11y-font-row .a11y-btn {
    flex: 1;
    justify-content: center;
    padding: 10px 8px;
    gap: 6px;
}

/* --- Divider --- */
.a11y-divider {
    height: 1px;
    background: #2a2a40;
    margin: 6px 0;
}

/* --- Reset Button --- */
.a11y-reset {
    margin-top: 4px;
    padding: 10px 16px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 10px;
    color: #f87171;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s ease;
    font-family: inherit;
    width: 100%;
}

.a11y-reset:hover {
    background: rgba(239, 68, 68, 0.15);
}

.a11y-reset:focus-visible {
    outline: 2px solid #f87171;
    outline-offset: 2px;
}

/* --- Responsive --- */
@media (max-width: 400px) {
    .a11y-panel {
        left: 10px;
        right: 10px;
        width: auto;
        bottom: 84px;
    }

    [dir="rtl"] .a11y-panel {
        left: 10px;
        right: 10px;
    }
}

/* ============================================
   Accessibility Mode Body Classes
   ============================================ */

/* High Contrast */
body.a11y-high-contrast {
    filter: contrast(1.4);
}

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

body.a11y-invert img,
body.a11y-invert video,
body.a11y-invert svg {
    filter: invert(1) hue-rotate(180deg);
}

/* Combined filters */
body.a11y-high-contrast.a11y-invert {
    filter: contrast(1.4) invert(1) hue-rotate(180deg);
}

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

body.a11y-grayscale.a11y-high-contrast {
    filter: grayscale(1) contrast(1.4);
}

/* Underline Links */
body.a11y-underline-links a {
    text-decoration: underline !important;
    text-underline-offset: 3px;
}

/* 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'%3E%3Cpath d='M4 4l14 30 4-12 12-4z' fill='black' stroke='white' stroke-width='2'/%3E%3C/svg%3E") 4 4, auto !important;
}

/* Reading Guide */
.a11y-reading-guide-bar {
    display: none;
    position: fixed;
    left: 0;
    width: 100%;
    height: 12px;
    background: rgba(37, 99, 235, 0.25);
    pointer-events: none;
    z-index: 99999;
    border-top: 2px solid rgba(37, 99, 235, 0.6);
    border-bottom: 2px solid rgba(37, 99, 235, 0.6);
}

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

/* Stop Animations */
body.a11y-stop-animations,
body.a11y-stop-animations *,
body.a11y-stop-animations *::before,
body.a11y-stop-animations *::after {
    animation: none !important;
    transition: none !important;
}

/* Line Height */
body.a11y-line-height-1 * {
    line-height: 1.8 !important;
}

body.a11y-line-height-2 * {
    line-height: 2.2 !important;
}

/* Letter Spacing */
body.a11y-letter-spacing-1 * {
    letter-spacing: 0.05em !important;
}

body.a11y-letter-spacing-2 * {
    letter-spacing: 0.12em !important;
}
