/* local_accesibilidad - widget.css
 * Prefix: a11y-  |  Scope of reading modes: #page (Boost/Essential) or .a11y-scope (fallback set by JS)
 * No CDN: fonts served from ../fonts/ (unmodified originals, SIL OFL 1.1, licences alongside).
 */

/* ---------- Fonts (loaded lazily: only referenced when a rule using them applies) ---------- */
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-hyperlegible/AtkinsonHyperlegible-Regular.ttf") format("truetype");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-hyperlegible/AtkinsonHyperlegible-Bold.ttf") format("truetype");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-hyperlegible/AtkinsonHyperlegible-Italic.ttf") format("truetype");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-hyperlegible/AtkinsonHyperlegible-BoldItalic.ttf") format("truetype");
  font-weight: 700; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Lexend";
  src: url("../fonts/lexend/Lexend-VariableFont_wght.ttf") format("truetype-variations"),
       url("../fonts/lexend/Lexend-VariableFont_wght.ttf") format("truetype");
  font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "OpenDyslexic";
  src: url("../fonts/opendyslexic/OpenDyslexic-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "OpenDyslexic";
  src: url("../fonts/opendyslexic/OpenDyslexic-Bold.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "OpenDyslexic";
  src: url("../fonts/opendyslexic/OpenDyslexic-Italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "OpenDyslexic";
  src: url("../fonts/opendyslexic/OpenDyslexic-Bold-Italic.woff2") format("woff2");
  font-weight: 700; font-style: italic; font-display: swap;
}

/* ---------- Variables ---------- */
:root {
  --a11y-fab-color: #086A3F;
  --a11y-scale: 1;
  --a11y-font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --a11y-ink: #14202E;
  --a11y-muted: #5B6B7A;
  --a11y-line: #DCE3E8;
  --a11y-soft: #F6F9FB;
  --a11y-focus: #B45309; /* 5.0:1 sobre blanco, 4.8:1 sobre soft, 4.4:1 sobre tile ON (medido) */
}

/* ---------- Widget root: isolate from theme ---------- */
#a11yWidgetRoot { font-family: var(--a11y-font); line-height: 1.5; color: var(--a11y-ink); text-align: left; }
#a11yWidgetRoot *, #a11yWidgetRoot *::before, #a11yWidgetRoot *::after { box-sizing: border-box; }
#a11yWidgetRoot button { text-transform: none; letter-spacing: normal; min-width: 0; box-shadow: none; }

/* ---------- Floating button ---------- */
.a11y-fab {
  position: fixed !important; right: 22px; bottom: 22px; z-index: 99998;
  width: 62px !important; height: 62px !important; padding: 0 !important; margin: 0 !important;
  border-radius: 50% !important; border: 0 !important; cursor: grab;
  background: #086A3F; background: var(--a11y-fab-color);
  color: #fff; display: grid; place-items: center;
  box-shadow: 0 12px 28px -6px rgba(10,33,46,.5);
  transition: box-shadow .2s ease;
  font-family: var(--a11y-font);
  touch-action: none; -webkit-user-select: none; user-select: none;
}
.a11y-fab.a11y-dragging { cursor: grabbing; transition: none; box-shadow: 0 20px 40px -8px rgba(10,33,46,.65); transform: scale(1.08); }
.a11y-fab.a11y-snapping { transition: left .25s cubic-bezier(.22,.61,.36,1), right .25s cubic-bezier(.22,.61,.36,1), top .25s cubic-bezier(.22,.61,.36,1); }
.a11y-fab:focus { outline: none; }
.a11y-fab:focus-visible { outline: 3px solid #14202E; outline-offset: 3px; }
.a11y-fab svg { width: 32px; height: 32px; pointer-events: none; }
.a11y-pulse {
  position: absolute; left: 0; top: 0; right: 0; bottom: 0; border-radius: 50%;
  background: #086A3F; background: var(--a11y-fab-color);
  opacity: 0; animation: a11yPulse 2.6s infinite; pointer-events: none; z-index: -1;
}
@keyframes a11yPulse {
  0%   { transform: scale(1);    opacity: .45; }
  70%  { transform: scale(1.55); opacity: 0; }
  100% { transform: scale(1.55); opacity: 0; }
}

/* ---------- Overlay + panel ---------- */
.a11y-overlay { position: fixed; left: 0; top: 0; right: 0; bottom: 0; z-index: 99997; background: rgba(10,33,46,.35); opacity: 0; visibility: hidden; transition: opacity .3s; }
.a11y-overlay.open { opacity: 1; visibility: visible; }

.a11y-panel {
  position: fixed; right: 0; top: 0; bottom: 0; z-index: 99999;
  width: 380px; max-width: 92vw; margin: 0; padding: 0;
  background: #fff; box-shadow: 0 18px 50px -12px rgba(10,33,46,.45);
  transform: translateX(105%); transition: transform .35s cubic-bezier(.22,.61,.36,1);
  display: flex; flex-direction: column;
  font-family: var(--a11y-font); color: var(--a11y-ink); line-height: 1.6; font-size: 16px;
}
.a11y-panel[hidden] { display: none !important; }
.a11y-panel.a11y-left { right: auto; left: 0; transform: translateX(-105%); }
.a11y-panel.open { transform: translateX(0); }

.a11y-panel .a11y-head {
  background: linear-gradient(135deg, #0A4F57, #0F6E78); color: #fff;
  padding: 20px; margin: 0; border: 0; display: flex; align-items: center; gap: 12px; flex: none;
}
.a11y-panel .a11y-ic { width: 40px; height: 40px; border-radius: 11px; background: rgba(255,255,255,.18); display: grid; place-items: center; flex: none; }
.a11y-panel .a11y-ic svg { width: 24px; height: 24px; }
.a11y-panel .a11y-head h2 { margin: 0; padding: 0; font-size: 1.15rem; font-weight: 700; color: #fff; font-family: var(--a11y-font); line-height: 1.3; }
.a11y-panel .a11y-head p { margin: 2px 0 0; padding: 0; font-size: .82rem; opacity: .85; color: #fff; }
.a11y-close {
  margin-left: auto; background: rgba(255,255,255,.15); border: 0; color: #fff;
  width: 36px; height: 36px; border-radius: 10px; font-size: 1.3rem; cursor: pointer; line-height: 1; padding: 0; flex: none;
}
.a11y-close:hover { background: rgba(255,255,255,.28); }
.a11y-close:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

.a11y-bodyc { padding: 16px 18px 26px; overflow-y: auto; flex: 1; }
.a11y-gt { font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--a11y-muted); font-weight: 700; margin: 18px 4px 8px; }
.a11y-gt:first-child { margin-top: 4px; }

/* Tiles */
.a11y-tile {
  width: 100%; text-align: left; cursor: pointer; display: flex; align-items: center; gap: 13px;
  background: var(--a11y-soft); border: 2px solid transparent; border-radius: 13px;
  padding: 13px 14px; margin: 0 0 9px; color: var(--a11y-ink);
  font-family: var(--a11y-font); font-size: 1rem; line-height: 1.4;
  transition: border-color .18s, background .18s;
}
.a11y-tile:hover { border-color: #BFD2D6; }
.a11y-glyph { width: 40px; height: 40px; border-radius: 10px; background: #fff; border: 1px solid var(--a11y-line); display: grid; place-items: center; color: #0F6E78; flex: none; }
.a11y-glyph svg { width: 22px; height: 22px; }
.a11y-txt { flex: 1; min-width: 0; }
.a11y-txt b { display: block; font-size: .97rem; font-weight: 700; }
.a11y-txt span { font-size: .8rem; color: var(--a11y-muted); display: block; }
.a11y-state { font-size: .72rem; font-weight: 700; color: var(--a11y-muted); background: #fff; border: 1px solid var(--a11y-line); border-radius: 999px; padding: 3px 9px; flex: none; }
.a11y-tile[aria-pressed="true"] { border-color: #0F6E78; background: #E7F2F3; }
.a11y-tile[aria-pressed="true"] .a11y-state { color: #fff; background: #0F6E78; border-color: #0F6E78; }
.a11y-tile[aria-pressed="true"] .a11y-glyph { background: #0F6E78; color: #fff; border-color: #0F6E78; }
.a11y-tile:focus-visible { outline: 3px solid var(--a11y-focus); outline-offset: 2px; }

/* Text-size stepper */
.a11y-stepper { display: flex; gap: 8px; background: var(--a11y-soft); border-radius: 13px; padding: 8px; }
.a11y-stepper button {
  flex: 1; border: 1px solid var(--a11y-line); background: #fff; border-radius: 9px; cursor: pointer;
  font-family: var(--a11y-font); font-weight: 700; color: #0F6E78; padding: 10px; font-size: 1rem; line-height: 1.2;
}
.a11y-stepper button:hover { background: #E7F2F3; }
.a11y-stepper button:focus-visible { outline: 3px solid var(--a11y-focus); outline-offset: 2px; }
.a11y-val { flex: 1.3; display: grid; place-items: center; font-weight: 700; font-size: .95rem; }

/* Segmented radio group (typeface) */
.a11y-seg { display: flex; gap: 6px; background: var(--a11y-soft); border-radius: 13px; padding: 8px; flex-wrap: wrap; }
.a11y-segbtn {
  flex: 1 1 auto; min-width: 72px; border: 1px solid var(--a11y-line); background: #fff; border-radius: 9px; cursor: pointer;
  font-family: var(--a11y-font); font-weight: 700; color: var(--a11y-ink); padding: 9px 6px; font-size: .85rem; line-height: 1.2;
}
.a11y-segbtn:hover { background: #E7F2F3; }
.a11y-segbtn[aria-checked="true"] { background: #0F6E78; border-color: #0F6E78; color: #fff; }
.a11y-segbtn:focus-visible { outline: 3px solid var(--a11y-focus); outline-offset: 2px; }
/* Font samples load only while the panel is open, so no page-load cost. */
.a11y-panel.open .a11y-f-atkinson { font-family: "Atkinson Hyperlegible", sans-serif; }
.a11y-panel.open .a11y-f-lexend { font-family: "Lexend", sans-serif; }
.a11y-panel.open .a11y-f-opendyslexic { font-family: "OpenDyslexic", sans-serif; font-size: .74rem; }

/* Speech playback controls */
.a11y-subrow { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; background: var(--a11y-soft); border-radius: 13px; padding: 8px; margin: -3px 0 9px; }
.a11y-subrow[hidden] { display: none !important; }
.a11y-subrow button {
  display: flex; align-items: center; gap: 6px; border: 1px solid var(--a11y-line); background: #fff; border-radius: 9px; cursor: pointer;
  font-family: var(--a11y-font); font-weight: 700; color: var(--a11y-ink); padding: 8px 10px; font-size: .8rem; line-height: 1.2;
}
.a11y-subrow button:hover { background: #E7F2F3; }
.a11y-subrow button:focus-visible { outline: 3px solid var(--a11y-focus); outline-offset: 2px; }
.a11y-subrow button svg { width: 14px; height: 14px; flex: none; }
.a11y-voicebox { flex: 1 1 100%; display: flex; align-items: center; gap: 8px; font-size: .78rem; font-weight: 700; color: var(--a11y-muted); }
.a11y-voicebox select {
  flex: 1; min-width: 0; border: 1px solid var(--a11y-line); background: #fff; border-radius: 9px;
  font-family: var(--a11y-font); color: var(--a11y-ink); padding: 7px 8px; font-size: .8rem; max-width: 100%;
}
.a11y-voicebox select:focus-visible { outline: 3px solid var(--a11y-focus); outline-offset: 2px; }
.a11y-ratebox { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.a11y-ratebox span { min-width: 46px; text-align: center; font-weight: 700; font-size: .85rem; }

/* Colour swatches */
.a11y-colors { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; padding: 4px; }
.a11y-swatch { width: 34px; height: 34px; padding: 0; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--a11y-line); cursor: pointer; }
.a11y-swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--a11y-ink); }
.a11y-swatch:focus-visible { outline: 3px solid var(--a11y-focus); outline-offset: 2px; }
.a11y-color-custom { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--a11y-muted); font-weight: 400; }
.a11y-color-custom input { width: 38px; height: 34px; border: 1px solid var(--a11y-line); border-radius: 8px; background: #fff; cursor: pointer; padding: 2px; margin: 0; }

.a11y-hint { font-size: .78rem; color: var(--a11y-muted); background: var(--a11y-soft); border-radius: 10px; padding: 10px 12px; margin-top: 6px; }

.a11y-reset {
  width: 100%; margin-top: 18px; background: #fff; border: 2px solid var(--a11y-line); color: var(--a11y-ink);
  border-radius: 13px; padding: 13px; font-family: var(--a11y-font); font-weight: 700; font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.a11y-reset:hover { border-color: var(--a11y-ink); }
.a11y-reset:focus-visible { outline: 3px solid var(--a11y-focus); outline-offset: 2px; }

.a11y-foot { padding: 12px 18px; border-top: 1px solid var(--a11y-line); font-size: .76rem; color: var(--a11y-muted); text-align: center; font-family: var(--a11y-font); flex: none; }
.a11y-badge { display: inline-block; margin-top: 4px; font-size: .7rem; font-weight: 700; letter-spacing: .04em; color: #0F6E78; background: #E7F2F3; border-radius: 999px; padding: 2px 9px; }

/* Reading guide + SR live region */
.a11y-guide { position: fixed; left: 0; right: 0; height: 42px; background: rgba(15,110,120,.12); border-top: 2px solid #0F6E78; border-bottom: 2px solid #0F6E78; pointer-events: none; z-index: 99996; display: none; }
.a11y-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

/* ---------- Reading modes (page scope) ---------- */
html.a11y-uppercase #page *, html.a11y-uppercase .a11y-scope * { text-transform: uppercase !important; }

html.a11y-dyslexia #page, html.a11y-dyslexia .a11y-scope { font-family: "Lexend", var(--a11y-font) !important; letter-spacing: .02em; }
/* Icon fonts keep their own family; only elements that inherit the body font change. */

html.a11y-spacing #page, html.a11y-spacing .a11y-scope { letter-spacing: .06em !important; word-spacing: .14em !important; }
html.a11y-spacing #page p, html.a11y-spacing #page li, html.a11y-spacing #page td, html.a11y-spacing #page label,
html.a11y-spacing .a11y-scope p, html.a11y-spacing .a11y-scope li, html.a11y-spacing .a11y-scope td, html.a11y-spacing .a11y-scope label { line-height: 2 !important; }

html.a11y-links #page a, html.a11y-links .a11y-scope a {
  background: #FFF4D6 !important; color: #14202E !important; text-decoration: underline !important; text-underline-offset: 3px;
  box-shadow: 0 0 0 2px #FFD166; border-radius: 3px; padding: 0 2px;
}

html.a11y-grayscale #page, html.a11y-grayscale .a11y-scope { -webkit-filter: grayscale(1); filter: grayscale(1); }

html.a11y-bigtext #page, html.a11y-bigtext .a11y-scope { font-size: calc(1rem * var(--a11y-scale)) !important; }

/* Reading typefaces */
html.a11y-font-atkinson #page, html.a11y-font-atkinson .a11y-scope { font-family: "Atkinson Hyperlegible", system-ui, sans-serif !important; }
html.a11y-font-lexend #page, html.a11y-font-lexend .a11y-scope { font-family: "Lexend", system-ui, sans-serif !important; letter-spacing: .02em; }
html.a11y-font-opendyslexic #page, html.a11y-font-opendyslexic .a11y-scope { font-family: "OpenDyslexic", system-ui, sans-serif !important; line-height: 1.75; }

/* Inverted contrast: page filtered, media re-inverted to keep natural colours */
html.a11y-invert body { background: #111 !important; }
html.a11y-invert #page, html.a11y-invert .a11y-scope { filter: invert(1) hue-rotate(180deg); background: #fff !important; }
html.a11y-invert #page img, html.a11y-invert #page video, html.a11y-invert #page iframe,
html.a11y-invert #page canvas, html.a11y-invert #page embed, html.a11y-invert #page object, html.a11y-invert #page picture,
html.a11y-invert .a11y-scope img, html.a11y-invert .a11y-scope video, html.a11y-invert .a11y-scope iframe,
html.a11y-invert .a11y-scope canvas, html.a11y-invert .a11y-scope embed, html.a11y-invert .a11y-scope object,
html.a11y-invert .a11y-scope picture { filter: invert(1) hue-rotate(180deg); }

/* Pause CSS animations and transitions */
html.a11y-noanim #page *, html.a11y-noanim .a11y-scope * { animation-play-state: paused !important; transition: none !important; }
html.a11y-noanim { scroll-behavior: auto !important; }

/* Large cursor (inline SVG, no external asset) */
html.a11y-bigcursor body, html.a11y-bigcursor #page, html.a11y-bigcursor #page *,
html.a11y-bigcursor .a11y-scope, html.a11y-bigcursor .a11y-scope *, html.a11y-bigcursor #a11yWidgetRoot * {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 24 24"><path d="M5 2l14 11.5-5.8.9 3.3 6.6-2.9 1.4-3.2-6.6L5 20.5z" fill="%23111" stroke="%23fff" stroke-width="1.4"/></svg>') 4 2, auto !important;
}

/* Hide images (also background images) */
html.a11y-noimg #page img, html.a11y-noimg .a11y-scope img { visibility: hidden !important; }
html.a11y-noimg #page *, html.a11y-noimg .a11y-scope * { background-image: none !important; }

html.a11y-contrast, html.a11y-contrast body { background: #000 !important; }
html.a11y-contrast #page, html.a11y-contrast .a11y-scope { background: #000 !important; color: #FFE600 !important; }
html.a11y-contrast #page *, html.a11y-contrast .a11y-scope * { color: #FFE600 !important; border-color: #FFE600 !important; background-color: transparent !important; }
html.a11y-contrast #page a, html.a11y-contrast .a11y-scope a { color: #7CFCFF !important; }

/* Text being narrated */
.a11y-speaking { background: #FFF4D6 !important; box-shadow: 0 0 0 3px #FFD166; border-radius: 4px; }
html.a11y-contrast .a11y-speaking { background: #FFE600 !important; color: #000 !important; }
html.a11y-contrast .a11y-speaking * { color: #000 !important; }

/* ---------- Motion preference ---------- */
@media (prefers-reduced-motion: reduce) {
  .a11y-fab, .a11y-panel, .a11y-overlay, .a11y-tile { transition: none !important; }
  .a11y-pulse { animation: none !important; }
}
