/* ============================================================
   Aviv Accessibility — rendering modes
   Applied via body classes toggled by widget.js
   Scope: `body.aviv-a11y--*` — non-invasive when disabled
   ============================================================ */

/* ── Text scaling (applied ALWAYS via custom prop, active only when scaled) ── */
:root { --aviv-a11y-text-scale: 100%; }

body.aviv-a11y--text-scaled,
body.aviv-a11y--text-scaled p,
body.aviv-a11y--text-scaled li,
body.aviv-a11y--text-scaled span,
body.aviv-a11y--text-scaled a,
body.aviv-a11y--text-scaled td,
body.aviv-a11y--text-scaled th,
body.aviv-a11y--text-scaled div:not(#aviv-a11y-root):not(#aviv-a11y-root *) {
    font-size: calc(1em * (var(--aviv-a11y-text-scale, 100%) / 100)) !important;
    line-height: 1.6 !important;
}
body.aviv-a11y--text-scaled h1 { font-size: calc(2em * (var(--aviv-a11y-text-scale) / 100)) !important; }
body.aviv-a11y--text-scaled h2 { font-size: calc(1.6em * (var(--aviv-a11y-text-scale) / 100)) !important; }
body.aviv-a11y--text-scaled h3 { font-size: calc(1.3em * (var(--aviv-a11y-text-scale) / 100)) !important; }

/* Never scale the widget itself */
body.aviv-a11y--text-scaled #aviv-a11y-root,
body.aviv-a11y--text-scaled #aviv-a11y-root * {
    font-size: revert !important;
    line-height: revert !important;
}

/* ── High contrast (black on white, aggressive) ── */
body.aviv-a11y--high-contrast,
body.aviv-a11y--high-contrast *:not(#aviv-a11y-root):not(#aviv-a11y-root *) {
    background-color: #ffffff !important;
    color: #000000 !important;
    text-shadow: none !important;
    box-shadow: none !important;
}
body.aviv-a11y--high-contrast a:not(#aviv-a11y-root a) { color: #0000ee !important; text-decoration: underline !important; }
body.aviv-a11y--high-contrast a:visited:not(#aviv-a11y-root a) { color: #551a8b !important; }
body.aviv-a11y--high-contrast img:not(#aviv-a11y-root img) { filter: contrast(1.1); }

/* ── Negative contrast (white on black) ── */
body.aviv-a11y--negative-contrast,
body.aviv-a11y--negative-contrast *:not(#aviv-a11y-root):not(#aviv-a11y-root *) {
    background-color: #000000 !important;
    color: #ffffff !important;
    text-shadow: none !important;
    box-shadow: none !important;
}
body.aviv-a11y--negative-contrast a:not(#aviv-a11y-root a) { color: #ffff00 !important; text-decoration: underline !important; }
body.aviv-a11y--negative-contrast img:not(#aviv-a11y-root img) { filter: invert(1) hue-rotate(180deg); }

/* ── Grayscale ── */
body.aviv-a11y--grayscale:not(#aviv-a11y-root) {
    filter: grayscale(1);
}
body.aviv-a11y--grayscale #aviv-a11y-root { filter: none; }

/* ── Readable font (dyslexia-friendly) ── */
body.aviv-a11y--readable-font,
body.aviv-a11y--readable-font *:not(#aviv-a11y-root):not(#aviv-a11y-root *) {
    font-family: "Assistant", "Arial", "Segoe UI", sans-serif !important;
    letter-spacing: 0.02em !important;
    word-spacing: 0.06em !important;
    line-height: 1.7 !important;
}

/* ── Highlight links (yellow bg on every link) ── */
body.aviv-a11y--highlight-links a:not(#aviv-a11y-root a),
body.aviv-a11y--highlight-links a:visited:not(#aviv-a11y-root a) {
    background-color: #fff59d !important;
    color: #000 !important;
    box-shadow: 0 0 0 2px #fff59d !important;
    text-decoration: underline !important;
}

/* ── Underline links ── */
body.aviv-a11y--underline-links a:not(#aviv-a11y-root a) {
    text-decoration: underline !important;
    text-underline-offset: 3px !important;
}

/* ── Highlight headings ── */
body.aviv-a11y--highlight-headings h1:not(#aviv-a11y-root h1),
body.aviv-a11y--highlight-headings h2:not(#aviv-a11y-root h2),
body.aviv-a11y--highlight-headings h3:not(#aviv-a11y-root h3),
body.aviv-a11y--highlight-headings h4:not(#aviv-a11y-root h4),
body.aviv-a11y--highlight-headings h5:not(#aviv-a11y-root h5),
body.aviv-a11y--highlight-headings h6:not(#aviv-a11y-root h6) {
    outline: 2px dashed #1e88e5 !important;
    outline-offset: 4px !important;
    background: rgba(30,136,229,0.06) !important;
    padding: 4px !important;
}

/* ── Big cursor ── */
body.aviv-a11y--big-cursor,
body.aviv-a11y--big-cursor *:not(#aviv-a11y-root):not(#aviv-a11y-root *) {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'><path fill='%23000' stroke='%23fff' stroke-width='1.5' d='M4 2 L4 22 L10 16 L14 22 L17 20 L13 14 L20 14 Z'/></svg>") 4 4, auto !important;
}
body.aviv-a11y--big-cursor a:not(#aviv-a11y-root a),
body.aviv-a11y--big-cursor button:not(#aviv-a11y-root button),
body.aviv-a11y--big-cursor input:not(#aviv-a11y-root input),
body.aviv-a11y--big-cursor select:not(#aviv-a11y-root select),
body.aviv-a11y--big-cursor textarea:not(#aviv-a11y-root textarea) {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'><path fill='%23e53935' stroke='%23fff' stroke-width='1.5' d='M4 2 L4 22 L10 16 L14 22 L17 20 L13 14 L20 14 Z'/></svg>") 4 4, pointer !important;
}

/* ── Stop animations ── */
body.aviv-a11y--stop-animations,
body.aviv-a11y--stop-animations *:not(#aviv-a11y-root):not(#aviv-a11y-root *) {
    animation-play-state: paused !important;
    animation-duration: 0s !important;
    animation-delay: 0s !important;
    transition: none !important;
}
body.aviv-a11y--stop-animations video:not(#aviv-a11y-root video),
body.aviv-a11y--stop-animations audio:not(#aviv-a11y-root audio) {
    /* Pause is best-effort; browser blocks JS pause without user gesture */
}

/* ── Reading guide (thin horizontal line follows mouse Y) ── */
body.aviv-a11y--reading-guide::after {
    content: "";
    position: fixed;
    left: 0;
    right: 0;
    top: var(--aviv-a11y-mouse-y, 50vh);
    height: 3px;
    background: #ff3366;
    pointer-events: none;
    z-index: 2147482990;
    box-shadow: 0 0 8px rgba(255,51,102,0.6);
}

/* ── Reading mask (dims everything except a horizontal strip at cursor) ── */
body.aviv-a11y--reading-mask::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2147482980;
    background: linear-gradient(
        to bottom,
        rgba(0,0,0,0.55) 0,
        rgba(0,0,0,0.55) calc(var(--aviv-a11y-mouse-y, 50vh) - 60px),
        transparent      calc(var(--aviv-a11y-mouse-y, 50vh) - 60px),
        transparent      calc(var(--aviv-a11y-mouse-y, 50vh) + 60px),
        rgba(0,0,0,0.55) calc(var(--aviv-a11y-mouse-y, 50vh) + 60px),
        rgba(0,0,0,0.55) 100%
    );
}

/* ── Keyboard nav (visible focus everywhere) ── */
body.aviv-a11y--keyboard-nav *:focus {
    outline: 3px solid #ff9800 !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 5px rgba(255,152,0,0.3) !important;
}

/* Skip-to-content link (always exists for keyboard users) */
body.aviv-a11y--keyboard-nav .aviv-a11y-skip-link,
.aviv-a11y-skip-link {
    position: absolute;
    top: -100px;
    right: 20px;
    background: #000;
    color: #fff;
    padding: 12px 20px;
    z-index: 2147482970;
    text-decoration: none;
    border-radius: 0 0 6px 6px;
}
.aviv-a11y-skip-link:focus {
    top: 0;
}

/* Respect reduced-motion preference — always */
@media (prefers-reduced-motion: reduce) {
    #aviv-a11y-panel {
        animation: none !important;
    }
}
