/* ===========================================================================
   Accessibility widget: launcher, panel, and the effect classes it toggles
   on <html>. Self-contained, no dependencies.
   =========================================================================== */

@font-face {
  font-family: "OpenDyslexic";
  src: url("/assets/fonts/opendyslexic-regular.woff2") format("woff2");
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "OpenDyslexic";
  src: url("/assets/fonts/opendyslexic-bold.woff2") format("woff2");
  font-weight: 700; font-display: swap;
}

/* ---------------------------------------------------------------- Launcher */
.a11y-fab {
  position: fixed; left: 20px; bottom: 20px; z-index: 9600;
  width: 52px; height: 52px; border-radius: 50%; border: none; cursor: pointer;
  background: #0B5D34; color: #fff; display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 28px -8px rgba(11,93,52,.6); transition: transform .2s ease, box-shadow .2s;
}
.a11y-fab:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 16px 34px -10px rgba(11,93,52,.7); }
.a11y-fab:focus-visible { outline: 3px solid #F0A818; outline-offset: 3px; }
.a11y-fab svg { width: 28px; height: 28px; }
@media (max-width: 520px){ .a11y-fab { left: 12px; bottom: 12px; width: 46px; height: 46px; } .a11y-fab svg { width: 24px; height: 24px; } }

/* ---------------------------------------------------------------- Panel */
.a11y-panel {
  position: fixed; left: 20px; bottom: 84px; z-index: 9601;
  width: min(360px, calc(100vw - 32px)); max-height: min(78vh, 640px);
  background: #fff; color: #1A1410; border: 1px solid #E6DBC4; border-radius: 18px;
  box-shadow: 0 24px 60px -16px rgba(11,93,52,.4), 0 8px 24px rgba(26,20,16,.18);
  display: flex; flex-direction: column; overflow: hidden;
  font-family: "Plus Jakarta Sans","Segoe UI",system-ui,sans-serif;
}
.a11y-panel[hidden] { display: none; }
.a11y-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px; background: #0B5D34; color: #fff; }
.a11y-head strong { font-family: "Fraunces",Georgia,serif; font-size: 1.1rem; }
.a11y-head-actions { display: flex; gap: 6px; }
.a11y-head button { background: rgba(255,255,255,.15); border: none; color: #fff; cursor: pointer; font-size: .76rem; font-weight: 700; padding: 6px 10px; border-radius: 100px; }
.a11y-head button:hover { background: rgba(255,255,255,.28); }
.a11y-body { padding: 14px; overflow-y: auto; }
.a11y-group-title { font-size: .68rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: #4A4038; margin: 12px 4px 8px; }
.a11y-group-title:first-child { margin-top: 0; }
.a11y-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.a11y-opt {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 12px 8px; border: 1.5px solid #E6DBC4; border-radius: 12px; background: #FBF6EC;
  cursor: pointer; font-family: inherit; font-size: .8rem; font-weight: 700; color: #1A1410;
  transition: border-color .15s, background .15s, transform .12s;
}
.a11y-opt:hover { transform: translateY(-1px); border-color: #0B5D34; }
.a11y-opt:focus-visible { outline: 3px solid #F0A818; outline-offset: 2px; }
.a11y-opt svg { width: 22px; height: 22px; color: #0B5D34; }
.a11y-opt[aria-pressed="true"] { background: #0B5D34; color: #fff; border-color: #0B5D34; }
.a11y-opt[aria-pressed="true"] svg { color: #fff; }
.a11y-opt .a11y-level { font-size: .68rem; opacity: .8; font-weight: 800; }
.a11y-foot { padding: 10px 14px; border-top: 1px solid #E6DBC4; font-size: .68rem; color: #4A4038; text-align: center; }
@media (prefers-reduced-motion: reduce) { .a11y-fab, .a11y-opt { transition: none; } }

/* ---------------------------------------------------------------- Reading guide */
.a11y-guide-bar { position: fixed; left: 0; right: 0; height: 44px; background: rgba(11,93,52,.18); border-top: 2px solid #0B5D34; border-bottom: 2px solid #0B5D34; pointer-events: none; z-index: 9590; display: none; }
html.a11y-guide .a11y-guide-bar { display: block; }

/* ===========================================================================
   EFFECT CLASSES (toggled on <html>)
   =========================================================================== */

/* Bigger text: zoom the page content so EVERY text element scales (headings,
   leads, numbers, cards, etc.), regardless of px/rem/clamp. The header chrome
   and the fixed widgets are left at their normal size so controls stay usable. */
html.a11y-font-1 #app-main, html.a11y-font-1 .site-footer { zoom: 1.12; }
html.a11y-font-2 #app-main, html.a11y-font-2 .site-footer { zoom: 1.25; }
html.a11y-font-3 #app-main, html.a11y-font-3 .site-footer { zoom: 1.4; }
/* Firefox fallback (older versions): scale text-heavy elements */
@supports not (zoom: 1) {
  html.a11y-font-1 #app-main { font-size: 112%; }
  html.a11y-font-2 #app-main { font-size: 125%; }
  html.a11y-font-3 #app-main { font-size: 140%; }
}

/* Spacing */
html.a11y-linespacing body { line-height: 2 !important; }
html.a11y-linespacing p, html.a11y-linespacing li { margin-bottom: 1em !important; }
html.a11y-letterspacing body { letter-spacing: .12em !important; word-spacing: .16em !important; }

/* Fonts */
html.a11y-dyslexic body, html.a11y-dyslexic body :not(.icon):not(svg):not(.a11y-panel):not(.a11y-panel *) { font-family: "OpenDyslexic", "Comic Sans MS", sans-serif !important; }
html.a11y-readable body, html.a11y-readable body :not(.a11y-panel):not(.a11y-panel *) { font-family: "Plus Jakarta Sans", Arial, "Helvetica Neue", sans-serif !important; }

/* Text alignment */
html.a11y-alignleft p, html.a11y-alignleft li, html.a11y-alignleft h1, html.a11y-alignleft h2,
html.a11y-alignleft h3, html.a11y-alignleft h4, html.a11y-alignleft .lead, html.a11y-alignleft .section-head { text-align: left !important; }

/* Colour: high contrast */
html.a11y-color-contrast body { background: #fff !important; }
html.a11y-color-contrast body, html.a11y-color-contrast p, html.a11y-color-contrast li,
html.a11y-color-contrast h1, html.a11y-color-contrast h2, html.a11y-color-contrast h3, html.a11y-color-contrast h4,
html.a11y-color-contrast .muted, html.a11y-color-contrast span { color: #000 !important; }
html.a11y-color-contrast .card, html.a11y-color-contrast section, html.a11y-color-contrast .site-header,
html.a11y-color-contrast .site-footer, html.a11y-color-contrast main { background: #fff !important; }
html.a11y-color-contrast a:not(.btn):not(.a11y-opt) { color: #0000d1 !important; text-decoration: underline !important; }
html.a11y-color-contrast .btn-primary, html.a11y-color-contrast .btn-gold { background: #000 !important; color: #fff !important; }

/* Colour: dark mode. Override the design tokens so the whole UI flips, then fix
   the cases where a colour is hardcoded or used as both text and background. */
html.a11y-color-dark {
  --paper: #0c2117; --paper-2: #0a1b12; --card: #12321f; --white: #12321f;
  --ink: #f4eee0; --ink-soft: #c2d6c9; --line: rgba(255,255,255,.16);
  --green: #80e3a7; --green-700: #6ad494; --green-900: #081710;
  --gold: #f3b53f; --gold-soft: #ffd277;
}
html.a11y-color-dark body { background: #0c2117 !important; background-image: none !important; }
html.a11y-color-dark p, html.a11y-color-dark .muted, html.a11y-color-dark .lead { color: var(--ink-soft) !important; }
/* Header stays cream by default (hardcoded), force it dark */
html.a11y-color-dark .site-header { background: rgba(10,27,18,.94) !important; border-bottom-color: rgba(255,255,255,.12) !important; }
/* Buttons keep readable contrast (don't let the lightened --green become a bg) */
html.a11y-color-dark .btn-primary { background: #0e7a44 !important; color: #fff !important; box-shadow: none !important; }
html.a11y-color-dark .btn-primary:hover { background: #0c6b3b !important; }
html.a11y-color-dark .btn-gold { color: #10231a !important; }
html.a11y-color-dark .btn-ghost { color: var(--ink) !important; border-color: rgba(255,255,255,.28) !important; }
html.a11y-color-dark .nav-links a:not(.btn) { color: var(--ink-soft) !important; }
/* Chips, HUD, badges */
html.a11y-color-dark .chip { background: rgba(128,227,167,.16) !important; color: #a9efc6 !important; }
html.a11y-color-dark .hud-chip { background: #0a1b12 !important; }
/* "Dark" sections invert their meaning, keep their text light */
html.a11y-color-dark .section-dark { background: #081710 !important; color: #f4eee0 !important; }
html.a11y-color-dark .section-dark p, html.a11y-color-dark .section-dark .muted { color: #c2d6c9 !important; }
/* Form controls */
html.a11y-color-dark input, html.a11y-color-dark select, html.a11y-color-dark textarea { background: #0a1b12 !important; color: var(--ink) !important; border-color: rgba(255,255,255,.18) !important; }
/* Drop heavy light shadows that look like halos on dark */
html.a11y-color-dark .card, html.a11y-color-dark .kpi, html.a11y-color-dark .stat-band, html.a11y-color-dark .dash-toolbar, html.a11y-color-dark .cmp-row { box-shadow: none !important; }
/* Dark-surface components use var(--ink) as background with light text; since
   --ink is now light, give them an explicit dark surface so text stays visible. */
html.a11y-color-dark .cookie-banner,
html.a11y-color-dark .maisha-bubble,
html.a11y-color-dark .toast,
html.a11y-color-dark .map-tooltip,
html.a11y-color-dark .hud-chip { background: #061009 !important; color: #f4eee0 !important; }
html.a11y-color-dark .maisha-bubble::after { border-top-color: #061009 !important; }
html.a11y-color-dark .cookie-banner-text { color: #d8e4dc !important; }

/* Colour: low saturation */
html.a11y-color-lowsat { filter: saturate(.4); }

/* Colour: invert + monochrome (filter based). Re-invert media + the widget. */
html.a11y-color-invert { filter: invert(1) hue-rotate(180deg); background: #fff; }
html.a11y-color-invert img, html.a11y-color-invert video, html.a11y-color-invert iframe,
html.a11y-color-invert .a11y-fab, html.a11y-color-invert .a11y-panel { filter: invert(1) hue-rotate(180deg); }
html.a11y-color-mono { filter: grayscale(1); }

/* Highlight links / headings */
html.a11y-links a:not(.a11y-opt):not(.a11y-fab) { outline: 2px solid #F0A818 !important; outline-offset: 2px; background: rgba(240,168,24,.16) !important; text-decoration: underline !important; }
html.a11y-headings h1, html.a11y-headings h2, html.a11y-headings h3, html.a11y-headings h4 { outline: 2px dashed #0B5D34 !important; outline-offset: 3px; }

/* Big cursor */
html.a11y-cursor, html.a11y-cursor * { 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 d="M4 2l7 18 2.5-7L20 10z" fill="black" stroke="white" stroke-width="1.5"/></svg>') 4 2, auto !important; }

/* Pause animations */
html.a11y-noanim *, html.a11y-noanim *::before, html.a11y-noanim *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }

/* Hide images (keep layout, hide content) */
html.a11y-hideimg img { visibility: hidden !important; }

/* Text-to-speech: indicate clickable text */
html.a11y-tts main :hover { outline: 2px dotted #0B5D34; outline-offset: 2px; cursor: help; }

/* Reading mask: dim everything except a band around the cursor */
.a11y-mask-shade { position: fixed; left: 0; right: 0; background: rgba(0,0,0,.62); pointer-events: none; z-index: 9589; display: none; }
html.a11y-mask .a11y-mask-shade { display: block; }

/* Keyboard focus highlight */
html.a11y-focus a:focus, html.a11y-focus button:focus, html.a11y-focus input:focus,
html.a11y-focus select:focus, html.a11y-focus textarea:focus, html.a11y-focus [tabindex]:focus {
  outline: 3px solid #F0A818 !important; outline-offset: 2px !important; border-radius: 2px;
}

/* Read-aloud voice picker */
.a11y-voice { display: flex; gap: 6px; margin: 4px 4px 0; }
.a11y-voice button { flex: 1; padding: 8px; border: 1.5px solid #E6DBC4; border-radius: 10px; background: #FBF6EC; cursor: pointer; font-family: inherit; font-size: .78rem; font-weight: 700; color: #1A1410; }
.a11y-voice button[aria-pressed="true"] { background: #0B5D34; color: #fff; border-color: #0B5D34; }
