/* Site-wide accessibility controls. Kept separate from the page router. */
.a11y-widget,
.a11y-panel,
.a11y-ruler { font-family: Arial, Helvetica, sans-serif; }
.a11y-skip-link { position: fixed; z-index: 1600; top: 10px; left: 10px; padding: 12px 16px; transform: translateY(-160%); border: 2px solid #111; border-radius: 10px; background: #fff; color: #111; font-weight: 800; }
.a11y-skip-link:focus { transform: translateY(0); outline: 3px solid #155eef; outline-offset: 3px; }

.a11y-widget { position: fixed; z-index: 1400; right: max(48px, calc(env(safe-area-inset-right) + 32px)); bottom: max(20px, env(safe-area-inset-bottom)); }
.a11y-toggle {
    width: 52px; min-width: 52px; min-height: 52px; display: inline-flex; align-items: center; justify-content: center;
    padding: 0; border: 2px solid #9b3514; border-radius: 50%; background: #fff;
    color: #7c2d12; box-shadow: 0 5px 20px rgba(31, 24, 20, .2); font-size: 14px; font-weight: 800; cursor: pointer;
}
.a11y-toggle span { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.a11y-toggle:hover { background: #fff4ec; }
.a11y-toggle:focus-visible, .a11y-panel :focus-visible { outline: 3px solid #155eef; outline-offset: 3px; }
.a11y-toggle svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.a11y-panel {
    position: absolute; right: 0; bottom: calc(100% + 12px); width: min(390px, calc(100vw - 28px));
    max-height: min(74vh, 720px); overflow: auto; overscroll-behavior: contain;
    padding: 20px; border: 1px solid #c9b9ad; border-radius: 20px; background: #fffdfa; color: #211a16;
    box-shadow: 0 18px 60px rgba(22, 18, 15, .28); scrollbar-width: thin;
}
.a11y-panel[hidden] { display: none; }
.a11y-panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding-bottom: 14px; border-bottom: 1px solid #e9ded5; }
.a11y-panel h2 { margin: 0; font-size: 20px; line-height: 1.25; color: #211a16; }
.a11y-panel-intro { margin: 6px 0 0; color: #51443d; font-size: 13px; line-height: 1.5; }
.a11y-close { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid #d8c9bf; border-radius: 12px; background: #fff; color: #211a16; font-size: 23px; cursor: pointer; }
.a11y-panel fieldset { min-width: 0; margin: 15px 0 0; padding: 13px; border: 1px solid #e3d7ce; border-radius: 14px; }
.a11y-panel legend { padding: 0 6px; color: #713717; font-size: 13px; font-weight: 800; }
.a11y-control-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 9px 0; }
.a11y-control-row > label, .a11y-control-row > span { color: #302721; font-size: 13px; line-height: 1.4; }
.a11y-button-row { display: flex; flex-wrap: wrap; gap: 7px; }
.a11y-panel button:not(.a11y-close), .a11y-panel select {
    min-height: 40px; border: 1px solid #9a8374; border-radius: 10px; background: #fff; color: #211a16;
    padding: 7px 11px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.a11y-panel button:hover, .a11y-panel select:hover { background: #fff1e8; border-color: #9b3514; }
.a11y-panel button[aria-pressed="true"] { border-color: #7c2d12; background: #7c2d12; color: #fff; }
.a11y-panel input[type="range"] { width: min(175px, 48%); min-height: 32px; accent-color: #9b3514; }
.a11y-panel output { min-width: 38px; color: #302721; font-size: 12px; font-weight: 800; text-align: right; }
.a11y-panel select { width: 100%; }
.a11y-panel .a11y-note { margin: 8px 0 0; color: #51443d; font-size: 12px; line-height: 1.5; }
.a11y-panel .a11y-status { min-height: 1.5em; margin: 10px 0 0; color: #164b2e; font-size: 12px; line-height: 1.5; }
.a11y-speech-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.a11y-speech-actions button:first-child { grid-column: 1 / -1; background: #a53b17; color: #fff; border-color: #7c2d12; }
.a11y-reset { width: 100%; margin-top: 14px; }
.a11y-ruler { position: fixed; z-index: 1300; left: 0; right: 0; height: 48px; display: none; pointer-events: none; border-block: 3px solid #111; background: rgba(255, 236, 77, .22); box-shadow: 0 0 0 9999px rgba(13, 17, 23, .22); }
.a11y-ruler.is-active { display: block; }
.a11y-ruler.is-speaking { height: 52px; border-color: #9b3514; background: rgba(255, 225, 85, .32); box-shadow: 0 0 0 9999px rgba(13, 17, 23, .26); }
.a11y-word-marker { position: fixed; z-index: 1350; display: none; pointer-events: none; border-radius: 3px; background: rgba(255, 229, 107, .28); outline: 2px solid #a33411; box-shadow: 0 0 0 3px rgba(255, 229, 107, .8); }
.a11y-word-marker.is-active { display: block; }
::highlight(a11y-speaking-word) { color: #17120f; background: #ffe56b; text-decoration: underline 3px #b43c14; text-decoration-skip-ink: none; }

/* User-controlled reading preferences. Every mode can be switched off independently. */
html.a11y-invert { filter: invert(1) hue-rotate(180deg); }
html.a11y-invert img, html.a11y-invert video, html.a11y-invert picture, html.a11y-invert canvas,
html.a11y-invert .a11y-widget, html.a11y-invert .back-to-top { filter: invert(1) hue-rotate(180deg); }
html.a11y-grayscale { filter: grayscale(1); }
html.a11y-grayscale.a11y-invert { filter: grayscale(1) invert(1) hue-rotate(180deg); }
body.a11y-high-contrast, body.a11y-high-contrast * { color: #fff !important; border-color: #fff !important; box-shadow: none !important; }
body.a11y-high-contrast, body.a11y-high-contrast *:not(svg):not(path) { background-color: #000 !important; }
body.a11y-high-contrast a, body.a11y-high-contrast a *, body.a11y-high-contrast button[aria-pressed="true"] { color: #ffeb3b !important; }
/* The ruler is an overlay: invert the page underneath it so white-on-black
   high-contrast text becomes black-on-white while the reader scans that line. */
body.a11y-high-contrast .a11y-ruler {
    background: rgba(255, 255, 255, .02) !important;
    border-block: 3px solid #ffeb3b !important;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, .62) !important;
}
@supports ((backdrop-filter: invert(1)) or (-webkit-backdrop-filter: invert(1))) {
    body.a11y-high-contrast .a11y-ruler {
        -webkit-backdrop-filter: invert(1) contrast(1.15);
        backdrop-filter: invert(1) contrast(1.15);
    }
}
body.a11y-high-contrast .a11y-word-marker { background: rgba(255, 229, 107, .35) !important; outline-color: #ffeb3b !important; box-shadow: 0 0 0 3px #ffeb3b !important; }
body.a11y-high-contrast :focus-visible { outline: 3px solid #ffeb3b !important; outline-offset: 3px; }
body.a11y-underlined-links a { text-decoration: underline !important; text-decoration-thickness: .12em !important; text-underline-offset: .16em !important; }
body.a11y-readable-font, body.a11y-readable-font *:not(svg):not(path) { font-family: Arial, Verdana, sans-serif !important; }
body.a11y-loose-spacing p, body.a11y-loose-spacing li, body.a11y-loose-spacing label,
body.a11y-loose-spacing blockquote, body.a11y-loose-spacing dd { line-height: 1.9 !important; letter-spacing: .035em !important; word-spacing: .12em !important; }
body.a11y-stop-motion *, body.a11y-stop-motion *::before, body.a11y-stop-motion *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .001ms !important;
}
body.a11y-scaled *:not(.a11y-panel):not(.a11y-panel *) { font-size: calc(var(--a11y-base-font, 1rem) * var(--a11y-font-scale, 1)) !important; }

@media (max-width: 600px) {
    .a11y-widget { right: max(40px, calc(env(safe-area-inset-right) + 24px)); bottom: max(16px, env(safe-area-inset-bottom)); }
    .a11y-toggle { width: 48px; min-width: 48px; height: 48px; min-height: 48px; padding: 0; font-size: 0; }
    .a11y-toggle svg { width: 25px; height: 25px; }
    .a11y-panel { right: 0; bottom: calc(100% + 10px); width: min(360px, calc(100vw - 24px)); max-height: min(72dvh, 680px); padding: 15px; }
    .a11y-ruler { height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
    .a11y-toggle, .a11y-panel *, .a11y-ruler { scroll-behavior: auto !important; transition-duration: .001ms !important; }
}
