/* ── A11y Widget ────────────────────────────────────────── */

#a11y-toggle {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 99999;
    width: 46px;
    height: 56px;
    border-radius: 8px 0 0 8px;
    background: #a69082;
    color: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: -3px 0 12px rgba(0,0,0,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
    padding: 0;
}
#a11y-toggle:hover { background: #957060; }
#a11y-toggle[aria-expanded="true"] { background: #957060; }

/* ── Panel ── */
#a11y-panel {
    position: fixed;
    right: 46px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 99998;
    width: 285px;
    background: #faf7f5;
    border: 1px solid #d9cdc7;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(100,70,55,.15);
    display: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    color: #3d2e27;
    overflow: hidden;
}
#a11y-panel.a11y-open { display: block; }

#a11y-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1rem;
    border-bottom: 1px solid #d9cdc7;
    background: #f0e8e3;
    font-weight: 700;
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #7a5a4a;
}
#a11y-panel-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #b09080;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0;
    transition: color .15s;
}
#a11y-panel-close:hover { color: #7a5a4a; }

#a11y-panel-body {
    padding: .55rem .7rem;
    display: flex;
    flex-direction: column;
    gap: .3rem;
    max-height: 72vh;
    overflow-y: auto;
}

/* ── Section label ── */
.a11y-section-label {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #b09080;
    padding: .3rem .1rem .05rem;
}

/* ── Font size row ── */
.a11y-font-row {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .6rem;
    border: 1px solid #d9cdc7;
    border-radius: 8px;
    background: #f5eeea;
}
.a11y-font-row > span:first-child {
    font-size: .82rem;
    color: #7a5a4a;
    font-weight: 500;
    flex: 1;
}
.a11y-font-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid #d9cdc7;
    background: #fff;
    cursor: pointer;
    font-size: .78rem;
    font-weight: 700;
    color: #7a5a4a;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
    flex-shrink: 0;
}
.a11y-font-btn:hover { background: #ede5e1; }
#a11y-font-display {
    font-size: .75rem;
    color: #a69082;
    font-weight: 700;
    width: 34px;
    text-align: center;
    flex-shrink: 0;
}

/* ── Option Buttons ── */
.a11y-option {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .5rem .65rem;
    border-radius: 8px;
    border: 1px solid #d9cdc7;
    background: #f5eeea;
    cursor: pointer;
    text-align: left;
    color: #5a3e33;
    font-size: .82rem;
    font-weight: 500;
    width: 100%;
    transition: background .15s, border-color .15s;
}
.a11y-option:hover { background: #ede5e1; border-color: #c4b0a8; }
.a11y-option.a11y-active {
    background: #ede0d8;
    border-color: #a69082;
    color: #7a5a4a;
}
.a11y-opt-icon { font-size: .95rem; width: 20px; text-align: center; flex-shrink: 0; }
.a11y-opt-label { flex: 1; }
.a11y-opt-check { color: #a69082; font-size: .78rem; opacity: 0; transition: opacity .15s; }
.a11y-option.a11y-active .a11y-opt-check { opacity: 1; }

/* ── TTS controls ── */
#a11y-tts-controls {
    display: none;
    flex-direction: column;
    gap: .35rem;
    padding: .5rem .65rem;
    background: #ede0d8;
    border-radius: 8px;
    border: 1px solid #c4b0a8;
}
#a11y-tts-controls.a11y-visible { display: flex; }

/* ── Reading controls ── */
#a11y-reading-controls {
    display: none;
    flex-direction: column;
    gap: .35rem;
    padding: .5rem .65rem;
    background: #ede0d8;
    border-radius: 8px;
    border: 1px solid #c4b0a8;
}
#a11y-reading-controls.a11y-visible { display: flex; }
#a11y-reading-hint {
    font-size: .72rem;
    color: #957060;
    text-align: center;
}
#a11y-tts-hint {
    font-size: .72rem;
    color: #957060;
    text-align: center;
}
.a11y-tts-btns { display: flex; gap: .4rem; }
.a11y-tts-btn {
    flex: 1;
    padding: .35rem;
    border-radius: 6px;
    border: 1px solid #c4b0a8;
    background: #fff;
    color: #7a5a4a;
    cursor: pointer;
    font-size: .72rem;
    font-weight: 600;
    transition: background .15s;
}
.a11y-tts-btn:hover { background: #ede5e1; }

/* ── Reset ── */
#a11y-reset {
    margin: .25rem .7rem .4rem;
    padding: .45rem;
    border-radius: 8px;
    border: 1px solid #d9cdc7;
    background: #f5eeea;
    color: #957060;
    cursor: pointer;
    font-size: .78rem;
    font-weight: 600;
    width: calc(100% - 1.4rem);
    transition: background .15s;
}
#a11y-reset:hover { background: #ede5e1; }

/* ── Footer: statement + email ── */
#a11y-statement {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .35rem .7rem .6rem;
    border-top: 1px solid #d9cdc7;
    margin-top: .1rem;
    gap: .5rem;
}
#a11y-statement a {
    font-size: .7rem;
    color: #b09080;
    text-decoration: underline;
    text-underline-offset: 2px;
    white-space: nowrap;
    transition: color .15s;
}
#a11y-statement a:hover { color: #7a5a4a; }

/* ── Reading guide overlay ── */
#a11y-reading-guide {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    top: 40%;
    height: 120px;
    z-index: 99990;
    pointer-events: none;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
    border-top: 2px solid #a69082;
    border-bottom: 2px solid #a69082;
    border-radius: 2px;
}

/* ──────────────────────────────────────────────────────
   Accessibility overrides
   ────────────────────────────────────────────────────── */

html.a11y-font-1 body { font-size: 110% !important; }
html.a11y-font-2 body { font-size: 120% !important; }
html.a11y-font-3 body { font-size: 135% !important; }

html.a11y-contrast { filter: contrast(1.5) brightness(1.05); }
html.a11y-contrast.a11y-grayscale { filter: contrast(1.5) brightness(1.05) grayscale(1); }
html.a11y-grayscale:not(.a11y-contrast) { filter: grayscale(1); }

html.a11y-links a {
    outline: 3px solid #f5c400 !important;
    outline-offset: 3px !important;
    background: rgba(245,196,0,.18) !important;
    border-radius: 2px !important;
    text-decoration: underline !important;
}

html.a11y-no-anim *,
html.a11y-no-anim *::before,
html.a11y-no-anim *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

html.a11y-spacing-1 p, html.a11y-spacing-1 li, html.a11y-spacing-1 td,
html.a11y-spacing-1 th, html.a11y-spacing-1 span, html.a11y-spacing-1 div {
    line-height: 1.6 !important;
    letter-spacing: .02em !important;
    word-spacing: .08em !important;
}
html.a11y-spacing-2 p, html.a11y-spacing-2 li, html.a11y-spacing-2 td,
html.a11y-spacing-2 th, html.a11y-spacing-2 span, html.a11y-spacing-2 div {
    line-height: 1.85 !important;
    letter-spacing: .06em !important;
    word-spacing: .16em !important;
}
html.a11y-spacing-3 p, html.a11y-spacing-3 li, html.a11y-spacing-3 td,
html.a11y-spacing-3 th, html.a11y-spacing-3 span, html.a11y-spacing-3 div {
    line-height: 2.2 !important;
    letter-spacing: .1em !important;
    word-spacing: .28em !important;
}

@font-face {
    font-family: 'OpenDyslexic';
    src: url('https://cdn.jsdelivr.net/npm/open-dyslexic@1.0.3/open-dyslexic-regular.otf') format('opentype');
    font-display: swap;
}
html.a11y-dyslexia,
html.a11y-dyslexia * {
    font-family: 'OpenDyslexic', sans-serif !important;
}

/* TTS: readable elements get hover highlight when mode is active */
html.a11y-tts-on [data-a11y-r]:hover {
    outline: 2px dashed #a69082 !important;
    outline-offset: 3px !important;
    cursor: pointer !important;
    background: rgba(166,144,130,.08) !important;
    border-radius: 3px !important;
}
