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

.a11y-widget {
    --a11y-accent: var(--color-accent, #0066cc);
    --a11y-bg: #ffffff;
    --a11y-text: #1a1a1a;
    --a11y-border: #d0d0d0;
    --a11y-hover: #f0f0f0;
    --a11y-active: var(--a11y-accent);
    --a11y-active-text: #ffffff;

    position: fixed;
    inset-block-end: 20px;
    inset-inline-end: 20px;
    z-index: 9999;
    font-family: 'Heebo', 'Arial Hebrew', system-ui, sans-serif;
    direction: rtl;
}

/* Toggle button */
.a11y-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--a11y-accent);
    color: #ffffff;
    border: 3px solid #ffffff;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 200ms ease, box-shadow 200ms ease;
}

.a11y-toggle:hover,
.a11y-toggle:focus-visible {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0,0,0,.3);
    outline: 3px solid var(--a11y-accent);
    outline-offset: 2px;
}

/* Panel */
.a11y-panel {
    position: absolute;
    inset-block-end: 70px;
    inset-inline-end: 0;
    width: 320px;
    max-width: calc(100vw - 40px);
    background: var(--a11y-bg);
    color: var(--a11y-text);
    border: 1px solid var(--a11y-border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0,0,0,.15);
    overflow: hidden;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.a11y-panel[hidden] { display: none; }

.a11y-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--a11y-accent);
    color: #ffffff;
}

.a11y-panel-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
}

.a11y-close {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.a11y-close:hover,
.a11y-close:focus-visible {
    background: rgba(255,255,255,.2);
    outline: 2px solid #ffffff;
}

.a11y-panel-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

/* Font size group */
.a11y-group {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--a11y-border);
    border-radius: 8px;
}

.a11y-group-label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 14px;
}

.a11y-buttons {
    display: flex;
    gap: 8px;
}

.a11y-buttons button {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--a11y-border);
    background: var(--a11y-bg);
    color: var(--a11y-text);
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    transition: background 150ms ease;
}

.a11y-buttons button:hover,
.a11y-buttons button:focus-visible {
    background: var(--a11y-hover);
    outline: 2px solid var(--a11y-accent);
    outline-offset: 1px;
}

/* Feature toggles */
.a11y-feature {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 6px;
    border: 1px solid var(--a11y-border);
    background: var(--a11y-bg);
    color: var(--a11y-text);
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 15px;
    text-align: start;
    transition: background 150ms ease, border-color 150ms ease;
}

.a11y-feature:hover,
.a11y-feature:focus-visible {
    background: var(--a11y-hover);
    outline: 2px solid var(--a11y-accent);
    outline-offset: 1px;
}

.a11y-feature[aria-pressed="true"] {
    background: var(--a11y-active);
    color: var(--a11y-active-text);
    border-color: var(--a11y-active);
}

.a11y-feature[aria-pressed="true"]::before {
    content: '✓';
    margin-inline-end: 8px;
    font-weight: 700;
}

.a11y-feature-label { flex: 1; }

/* Reset all */
.a11y-reset-all {
    width: 100%;
    padding: 12px;
    margin-top: 8px;
    background: transparent;
    color: var(--a11y-text);
    border: 1px solid var(--a11y-border);
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
}

.a11y-reset-all:hover,
.a11y-reset-all:focus-visible {
    background: var(--a11y-hover);
    outline: 2px solid var(--a11y-accent);
}

/* Panel footer */
.a11y-panel-footer {
    padding: 12px 20px;
    border-block-start: 1px solid var(--a11y-border);
    background: #fafafa;
    font-size: 14px;
}

.a11y-panel-footer a {
    color: var(--a11y-accent);
    text-decoration: none;
}

.a11y-panel-footer a:hover { text-decoration: underline; }

/* ==========================================================================
   Body classes applied by the widget — these affect the WHOLE PAGE
   ========================================================================== */

/* High contrast mode */
body.a11y-high-contrast {
    background: #000000 !important;
    color: #ffffff !important;
}
body.a11y-high-contrast * {
    background-color: transparent !important;
    color: #ffffff !important;
    border-color: #ffff00 !important;
}
body.a11y-high-contrast a,
body.a11y-high-contrast a * {
    color: #ffff00 !important;
    text-decoration: underline !important;
}
body.a11y-high-contrast .a11y-widget,
body.a11y-high-contrast .a11y-widget * {
    /* Don't break the widget itself */
    background-color: initial !important;
    color: initial !important;
    border-color: initial !important;
}

/* Inverted colors */
body.a11y-invert-colors {
    filter: invert(1) hue-rotate(180deg);
}
body.a11y-invert-colors img,
body.a11y-invert-colors video,
body.a11y-invert-colors picture,
body.a11y-invert-colors .a11y-widget {
    filter: invert(1) hue-rotate(180deg);
}

/* Highlight links */
body.a11y-highlight-links a:not(.a11y-widget a) {
    text-decoration: underline !important;
    font-weight: 700 !important;
    outline: 1px dotted currentColor !important;
    outline-offset: 2px !important;
}

/* Readable font */
body.a11y-readable-font,
body.a11y-readable-font * {
    font-family: Arial, 'Arial Hebrew', sans-serif !important;
    letter-spacing: normal !important;
}

/* 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;
    scroll-behavior: auto !important;
}

/* 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='48' height='48' viewBox='0 0 48 48'><path d='M6 2 L6 38 L16 28 L22 44 L28 42 L22 26 L36 26 Z' fill='black' stroke='white' stroke-width='2'/></svg>") 0 0, auto !important;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .a11y-widget {
        inset-block-end: 12px;
        inset-inline-end: 12px;
    }
    .a11y-toggle {
        width: 48px;
        height: 48px;
    }
    .a11y-panel {
        inset-block-end: 60px;
        width: calc(100vw - 24px);
        inset-inline-end: -10px;
    }
}
