/* ICoBC Academy: accessibility tools and reading settings.
   Everything is opt-in, stored on the learner's own device and reversible.
   The page works fully without this file and without JavaScript. */

/* ---------- reading settings, applied to <html> ---------- */
html.a11y {
  --a11y-scale: 1;
  --a11y-leading: 1.65;
  --a11y-tracking: 0em;
  --a11y-word: normal;
}
html.a11y-text body { font-size: calc(1rem * var(--a11y-scale)); }
html.a11y-text .player-toc,
html.a11y-text .lesson,
html.a11y-text .prose { line-height: var(--a11y-leading); letter-spacing: var(--a11y-tracking); word-spacing: var(--a11y-word); }
html.a11y-text p,
html.a11y-text li,
html.a11y-text dd,
html.a11y-text td,
html.a11y-text .opt span { line-height: var(--a11y-leading); letter-spacing: var(--a11y-tracking); word-spacing: var(--a11y-word); }

/* Reading font: wide, open letterforms that are present on nearly every device. */
html.a11y-font-read body,
html.a11y-font-read .btn,
html.a11y-font-read input,
html.a11y-font-read select,
html.a11y-font-read textarea { font-family: Verdana, Tahoma, "DejaVu Sans", Geneva, sans-serif; }
html.a11y-font-read body { font-stretch: normal; }

/* Narrow measure: shorter lines are easier to track. */
html.a11y-measure .lesson > *,
html.a11y-measure .prose > * { max-width: 62ch; }
html.a11y-measure .lesson > .table-wrap,
html.a11y-measure .lesson > table,
html.a11y-measure .lesson > svg,
html.a11y-measure .lesson > .quiz,
html.a11y-measure .lesson > figure { max-width: none; }

/* Always underline links in running text. */
html.a11y-links main a:not(.btn):not(.brand-academy) { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 2px; }

/* Stronger contrast: darker text, heavier borders, no tinted backgrounds. */
html.a11y-contrast {
  --ink: #000000;
  --muted: #2B3C49;
  --line: #4A5C6A;
  --mist: #FFFFFF;
  --navy: #013151;
}
html.a11y-contrast .opt,
html.a11y-contrast .quiz,
html.a11y-contrast .card,
html.a11y-contrast .side-box { border-width: 2px; }
html.a11y-contrast .muted,
html.a11y-contrast .small { color: #2B3C49; }

/* Dark reading mode. Pictures keep their own colours. */
html.a11y-dark {
  --white: #11212D;
  --mist: #182C3A;
  --ink: #E9F1F6;
  --muted: #AFC3D0;
  --line: #335064;
  --navy: #CFE6F2;
  --navy-deep: #E9F1F6;
  color-scheme: dark;
}
html.a11y-dark body { background: #0C1821; color: var(--ink); }
html.a11y-dark .player-top,
html.a11y-dark .site-header { background: rgba(17,33,45,.96); }
html.a11y-dark .quiz,
html.a11y-dark .opt,
html.a11y-dark .card,
html.a11y-dark .side-box,
html.a11y-dark .final-box,
html.a11y-dark .cert-panel { background: var(--white); color: var(--ink); }
html.a11y-dark h1, html.a11y-dark h2, html.a11y-dark h3, html.a11y-dark h4,
html.a11y-dark .lesson-title, html.a11y-dark legend { color: var(--navy); }
html.a11y-dark a { color: #8FD3EC; }
html.a11y-dark img:not([src$=".svg"]) { filter: brightness(.92); }
html.a11y-dark .quiz-result, html.a11y-dark .final-score { color: #CFE6F2; }
html.a11y-dark .opt.opt-correct { background: #1E3A1C; border-color: #8DB024; }
html.a11y-dark .quiz.is-wrong .opt:has(input:checked):not(.opt-correct) { background: #3A2412; border-color: #D9822B; }
/* the panel's own controls need their own dark colours, because --navy is light here */
html.a11y-dark .a11y-fab,
html.a11y-dark .a11y-seg button[aria-pressed="true"],
html.a11y-dark .a11y-foot button.a11y-close { background: #1C4B6B; border-color: #1C4B6B; color: #FFFFFF; }
html.a11y-dark .a11y-seg button:hover { background: #22394A; border-color: #4A6D84; }

/* Reading ruler: a calm band that follows the pointer or the keyboard caret. */
.a11y-ruler {
  position: fixed; left: 0; right: 0; height: 2.6em; pointer-events: none; z-index: 70;
  border-top: 2px solid rgba(2,55,91,.55); border-bottom: 2px solid rgba(2,55,91,.55);
  background: rgba(93,202,231,.12); display: none;
}
html.a11y-ruler .a11y-ruler { display: block; }

/* ---------- the toolbar itself ---------- */
.a11y-fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 80;
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--navy, #02375B); color: #fff; border: 2px solid rgba(255,255,255,.75);
  box-shadow: 0 8px 22px rgba(2,39,64,.32);
}
.a11y-fab:hover { background: #013151; }
.a11y-fab svg { width: 26px; height: 26px; fill: currentColor; }
.a11y-panel {
  position: fixed; right: 18px; bottom: 82px; z-index: 81; width: min(340px, calc(100vw - 36px));
  max-height: min(76vh, 640px); overflow: auto;
  background: var(--white, #fff); color: var(--ink, #15293A);
  border: 1px solid var(--line, #D8E2E9); border-radius: 14px;
  box-shadow: 0 24px 60px rgba(2,39,64,.26); padding: 18px 18px 14px;
}
.a11y-panel[hidden] { display: none; }
.a11y-panel h2 { font-size: 1.05rem; margin: 0 0 2px; color: var(--navy, #02375B); }
.a11y-panel .a11y-sub { font-size: .82rem; color: var(--muted, #4F6576); margin: 0 0 14px; }
.a11y-group { margin-bottom: 14px; }
.a11y-group > span.a11y-label { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted, #4F6576); margin-bottom: 6px; }
.a11y-seg { display: flex; gap: 6px; flex-wrap: wrap; }
.a11y-seg button {
  flex: 1 1 auto; min-width: 56px; min-height: 40px; padding: 7px 10px; cursor: pointer;
  font: inherit; font-size: .88rem; border-radius: 9px;
  border: 1px solid var(--line, #D8E2E9); background: var(--white, #fff); color: var(--ink, #15293A);
}
.a11y-seg button:hover { border-color: #9DB0BE; background: #F7FAFC; }
.a11y-seg button[aria-pressed="true"] { background: var(--navy, #02375B); border-color: var(--navy, #02375B); color: #fff; font-weight: 600; }
.a11y-check { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; font-size: .92rem; cursor: pointer; }
.a11y-check input { width: 19px; height: 19px; margin: 2px 0 0; flex: none; accent-color: var(--navy, #02375B); }
.a11y-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-top: 1px solid var(--line, #D8E2E9); padding-top: 12px; margin-top: 4px; }
.a11y-foot button { font: inherit; font-size: .88rem; min-height: 40px; padding: 8px 14px; border-radius: 9px; cursor: pointer; border: 1px solid var(--line, #D8E2E9); background: var(--white, #fff); color: var(--ink, #15293A); }
.a11y-foot button.a11y-close { background: var(--navy, #02375B); border-color: var(--navy, #02375B); color: #fff; font-weight: 600; }
.a11y-fab:focus-visible, .a11y-panel :focus-visible { outline: 3px solid #5DCAE7; outline-offset: 2px; }

/* phones: a smaller button that steps aside while the learner reads (scrolls down) and returns on the way up */
@media (max-width: 760px) {
  .a11y-fab { width: 46px; height: 46px; right: 12px; bottom: 12px; }
  .a11y-fab svg { width: 23px; height: 23px; }
  .a11y-panel { right: 12px; left: 12px; width: auto; bottom: 68px; max-height: calc(100vh - 140px); }
  .a11y-fab.is-tucked { transform: translateX(34px); opacity: .55; }
  body { padding-bottom: 64px; }
}
@media (max-width: 760px) and (prefers-reduced-motion: no-preference) {
  html:not(.a11y-no-motion) .a11y-fab { transition: transform .25s ease, opacity .25s ease; }
}

@media print { .a11y-fab, .a11y-panel, .a11y-ruler { display: none !important; } }
