/* Accessibility panel and the display options it switches on. Shared by the sales site and the course app.
   Options are attributes on <html> set by a11y-boot.js: data-theme, data-font, data-spacing, data-lines, data-links,
   data-focus, data-width (and data-motion, handled in brand.css). */

@font-face { font-family: 'OpenDyslexic'; font-style: normal; font-weight: 400; font-display: swap; src: url('/assets/fonts/opendyslexic-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'OpenDyslexic'; font-style: normal; font-weight: 700; font-display: swap; src: url('/assets/fonts/opendyslexic-latin-700-normal.woff2') format('woff2'); }

/* ---------- high contrast themes (aim: 7:1 or better for text) ---------- */
:root[data-theme='contrast-dark'] {
  color-scheme: dark;
  --bg: #000; --bg-2: #000; --card: #000; --text: #fff; --muted: #ececec;
  --border: #fff; --shadow: transparent; --focus: #ffe600;
  --good: #8dff9d; --good-bg: #002b0a; --bad: #ff9aa0; --bad-bg: #3a0004; --warn-bg: #332b00;
  --accent: #ffe600; --accent-ink: #000; --link: #ffe600; --purple: #4a22b8; --purple-fill: #4a22b8; --purple-deep: #fff;
  --sh: none; --sh-sm: none; --bw: 3px;
}
:root[data-theme='contrast-light'] {
  color-scheme: light;
  --bg: #fff; --bg-2: #fff; --card: #fff; --text: #000; --muted: #1a1a1a;
  --border: #000; --shadow: transparent; --focus: #0000cc;
  --good: #005a12; --good-bg: #e6ffe9; --bad: #9c0006; --bad-bg: #ffe6e8; --warn-bg: #fff4cc;
  --accent: #0000cc; --accent-ink: #fff; --link: #0000cc; --purple: #4a22b8; --purple-fill: #4a22b8; --purple-deep: #000;
  --sh: none; --sh-sm: none; --bw: 3px;
}
:root[data-theme='contrast-dark'] .btn-primary, :root[data-theme='contrast-light'] .btn-primary { --b: #ffe600; color: #000; }
:root[data-theme='contrast-dark'] .btn-purple, :root[data-theme='contrast-light'] .btn-purple { --b: #4a22b8; color: #fff; }

/* ---------- fonts ---------- */
html[data-font='clear'] { --display: var(--font); }
html[data-font='system'] { --font: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif; --display: var(--font); }
html[data-font='serif'] { --font: Georgia, 'Times New Roman', Times, serif; --display: var(--font); }
html[data-font='dyslexia'] { --font: 'OpenDyslexic', 'Atkinson Hyperlegible', system-ui, sans-serif; --display: var(--font); }
html[data-font]:not([data-font='default']) :is(h1, h2, h3, h4) { font-weight: 700; letter-spacing: 0; }

/* ---------- spacing (WCAG 1.4.12: nothing may break at these settings) ---------- */
html[data-spacing='roomy'] body { letter-spacing: .05em; word-spacing: .1em; }
html[data-spacing='extra'] body { letter-spacing: .12em; word-spacing: .16em; }
html[data-spacing] :is(button, input, select, textarea, h1, h2, h3, h4) { letter-spacing: inherit; word-spacing: inherit; }
html[data-spacing='extra'] p { margin-bottom: 2em; }
html[data-lines='relaxed'] body :is(p, li, dd, dt, blockquote, label, summary, td, th, figcaption, small, .lede, .muted) { line-height: 1.85; }
html[data-lines='loose'] body :is(p, li, dd, dt, blockquote, label, summary, td, th, figcaption, small, .lede, .muted) { line-height: 2.15; }

/* ---------- links, focus, reading width ---------- */
html[data-links='underline'] a:not(.btn) { text-decoration: underline !important; text-underline-offset: 3px; text-decoration-thickness: 2px; }
html[data-focus='strong'] :focus-visible { outline: 4px solid var(--focus) !important; outline-offset: 3px !important; box-shadow: 0 0 0 8px var(--bg) !important; }
html[data-width='narrow'] :is(main, #main) { max-width: 68ch; margin-inline: auto; }
html[data-width='narrow'] :is(main, #main) .wrap { max-width: 68ch; }

/* ---------- the panel ---------- */
.a11y-btn { font-size: calc(1rem / var(--scale, 1)); }                                  /* the button keeps one comfortable size so it never covers content at large text */
.a11y-panel { font-size: calc(1rem * min(1, 1.3 / var(--scale, 1))); }                 /* the panel's own text grows, up to 130% */
.a11y-btn {
  position: fixed; z-index: 60; left: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
  display: inline-flex; align-items: center; gap: .5em; min-height: 48px; padding: .5em 1em .5em .8em;
  font: inherit; font-weight: 700; line-height: 1.1; color: var(--text); background: var(--card); cursor: pointer;
  border: var(--bw, 2.5px) solid var(--border); border-radius: 999px; box-shadow: var(--sh, 4px 4px 0 #16121f);
}
.a11y-btn:hover { background: color-mix(in srgb, var(--lime, #b8f557) 45%, var(--card)); }
.a11y-btn svg { width: 1.6em; height: 1.6em; flex: none; }
@media (max-width: 899px) { .a11y-btn { bottom: calc(78px + env(safe-area-inset-bottom)); } } /* clear of the app's bottom navigation */
@media print { .a11y-btn, .a11y-panel, .a11y-backdrop { display: none !important; } }

.a11y-backdrop { position: fixed; inset: 0; z-index: 65; background: rgba(0, 0, 0, .5); }
.a11y-panel {
  position: fixed; z-index: 70; top: 0; bottom: 0; left: 0; width: min(420px, 100vw); overflow-y: auto; overscroll-behavior: contain;
  padding: 1rem 1.1rem 2.5rem; color: var(--text); background: var(--card);
  border-right: var(--bw, 2.5px) solid var(--border); box-shadow: 8px 0 30px rgba(0, 0, 0, .3);
  transform: translateX(-104%); visibility: hidden; transition: transform .22s ease, visibility 0s .22s;
}
.a11y-panel.open { transform: none; visibility: visible; transition: transform .22s ease; }
.a11y-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; margin-bottom: .6rem; }
.a11y-head h2 { font-size: 1.5em; margin: 0; }
.a11y-panel p { margin: 0 0 .8em; }
.a11y-panel fieldset { border: 0; margin: 0 0 1.2rem; padding: 0; min-width: 0; }
.a11y-panel legend { font-weight: 700; padding: 0; margin-bottom: .45rem; }
.a11y-opts { display: flex; flex-wrap: wrap; gap: .45rem; }
.a11y-opt { position: relative; }
.a11y-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.a11y-opt span {
  display: inline-block; min-height: 44px; padding: .55em .95em; line-height: 1.25; cursor: pointer;
  color: var(--text); background: var(--card); border: var(--bw, 2.5px) solid var(--border); border-radius: 999px;
}
.a11y-opt input:checked + span { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.a11y-opt input:checked + span::before { content: '✓ '; }
.a11y-opt input:focus-visible + span { outline: 4px solid var(--focus); outline-offset: 3px; }
.a11y-opt:hover span { filter: brightness(.96); }
.a11y-size { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.a11y-size output { min-width: 4.2ch; text-align: center; font-weight: 700; }
.a11y-step {
  min-height: 48px; min-width: 48px; padding: .3em .8em; font: inherit; font-weight: 700; cursor: pointer; color: var(--text);
  background: var(--card); border: var(--bw, 2.5px) solid var(--border); border-radius: 12px;
}
.a11y-step:disabled { opacity: .45; cursor: not-allowed; }
.a11y-check { display: flex; align-items: flex-start; gap: .7rem; margin-bottom: .7rem; cursor: pointer; }
.a11y-check input { width: 1.5rem; height: 1.5rem; margin: .1rem 0 0; flex: none; accent-color: var(--accent); }
.a11y-foot { border-top: var(--bw, 2.5px) solid var(--border); padding-top: 1rem; }
.a11y-foot .a11y-step { padding-inline: 1em; }
.a11y-panel a { color: var(--link); }

/* ---------- keeping the app's header and navigation usable at large text, wide fonts and roomy spacing ---------- */
.topbar { flex-wrap: wrap; }
.topbar .btn, .a11y-btn { white-space: nowrap; overflow-wrap: normal; }
.a11y-btn { letter-spacing: normal; word-spacing: normal; }
@media (max-width: 520px) {
  html[data-large] .bottomnav a span:last-child { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  html[data-large] .bottomnav a { min-width: 48px; padding: .3rem .5rem; }
}

/* Buttons wrap between words, never mid-word; the lesson footer wraps rather than squeezing its buttons. */
.btn, .bottomnav a, .topbar .btn, .xp-pill { overflow-wrap: break-word; }
.lp-foot { flex-wrap: wrap; }
@media (max-width: 520px) {
  html[data-large] .a11y-btn span:last-child, html[data-font='dyslexia'] .a11y-btn span:last-child { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  html[data-large] .a11y-btn, html[data-font='dyslexia'] .a11y-btn { padding: .5em; }
}
.a11y-btn { max-width: calc(100vw - 24px); }

/* On phones the button is icon-only (its name is still read by screen readers), and lesson footers leave room for it. */
@media (max-width: 520px) {
  .a11y-btn span:last-child { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .a11y-btn { padding: .5em; }
  .lp-foot { padding-left: 72px; }
}
