/* ============================================================================
   SittingInventory.com: Accessibility preferences layer
   ----------------------------------------------------------------------------
   Same layer as ITMonitoring.com (ai-advisor-platform-docs ADR-0007). Tokenized CSS
   applied via classes on <html> by a11y.js. Preferences are persisted client-side
   under the single key a11y_prefs_v1 and hold ONLY non-personal display settings
   (text size, spacing, contrast theme, motion, etc.), never any personal data.

   Contrast themes re-map the same CSS variables the page already uses (--bg,
   --surface, --ink, --muted, --line, --accent, ...), so every element recolours
   automatically. With no saved choice the site follows the visitor's system theme.
   ============================================================================ */

/* ---- Contrast themes ------------------------------------------------------ */
html.light {
  color-scheme: light;
  --bg: #EDEFEF; --surface: #F8F9F9; --ink: #14262E; --muted: #53656C; --line: #C6CED1;
  --accent: #C73F08; --accent-ink: #FFFFFF; --good: #1D6F46; --wash: #E2E6E7;
}
html.dark {
  color-scheme: dark;
  --bg: #0E191E; --surface: #152329; --ink: #E4EBED; --muted: #9AABB1; --line: #2A3B42;
  --accent: #FF7A3D; --accent-ink: #1A0D05; --good: #5FD29B; --wash: #1B2D34;
}
/* Third, maximal-contrast option: black canvas, white text, yellow interactive. */
html.a11y-contrast-high {
  color-scheme: dark;
  --bg: #000000; --surface: #000000; --ink: #ffffff; --muted: #ffffff; --line: #ffffff;
  --accent: #ffe000; --accent-ink: #000000; --good: #6bff9e; --wash: #0a0a0a;
}
html.a11y-contrast-high body { background: #000; color: #fff; }
html.a11y-contrast-high a { color: #ffe000; text-decoration: underline; }
html.a11y-contrast-high a.cta { color: #000; }
html.a11y-contrast-high button,
html.a11y-contrast-high input,
html.a11y-contrast-high select,
html.a11y-contrast-high textarea,
html.a11y-contrast-high [role="button"] {
  border: 1px solid #fff !important;
}

/* ---- Text size (WCAG 1.4.4 resize text) ----------------------------------- */
html.a11y-text-110 { font-size: 110%; }
html.a11y-text-125 { font-size: 125%; }
html.a11y-text-150 { font-size: 150%; }
html.a11y-text-175 { font-size: 175%; }
html.a11y-text-200 { font-size: 200%; }
html[class*="a11y-text-"] body { font-size: 1rem; }

/* ---- Line spacing (WCAG 1.4.12 text spacing) ------------------------------ */
html.a11y-line-120 body { line-height: 1.86; } /* +20% over the 1.55 base */
html.a11y-line-140 body { line-height: 2.17; } /* +40% over the 1.55 base */
html.a11y-line-120 p, html.a11y-line-120 li, html.a11y-line-120 span, html.a11y-line-120 a,
html.a11y-line-120 label, html.a11y-line-120 summary,
html.a11y-line-140 p, html.a11y-line-140 li, html.a11y-line-140 span, html.a11y-line-140 a,
html.a11y-line-140 label, html.a11y-line-140 summary {
  line-height: inherit;
}

/* ---- Colour-independence aids (WCAG 1.4.1 use of colour) ------------------ */
html.a11y-underline-links a { text-decoration: underline !important; }
html.a11y-highlight-links a {
  background: #ffe000 !important;
  color: #111 !important;
  text-decoration: underline !important;
  box-shadow: 0 0 0 2px #ffe000;
  border-radius: 2px;
}

/* ---- Dyslexia-friendly font ----------------------------------------------- */
/* The @font-face (Atkinson Hyperlegible, same woff2 as ITMonitoring.com, embedded
   in /a11y-font.css) is loaded at runtime only when this toggle is enabled. Until it
   loads, text falls back to the normal body font, so nothing breaks. */
html.a11y-dyslexia body,
html.a11y-dyslexia :where(h1, h2, h3, h4, h5, h6, p, a, li, span, em, strong, b, button, input, select, textarea, label, legend, summary) {
  font-family: "Atkinson Hyperlegible", var(--font-body) !important;
  letter-spacing: 0.01em;
}

/* ---- Reading guide (horizontal ruler overlay, moved with arrow keys) ------ */
.a11y-reading-guide {
  position: fixed;
  left: 0;
  right: 0;
  top: 45vh;
  height: 40px;
  background: rgba(255, 224, 0, 0.16);
  border-top: 2px solid rgba(17, 17, 17, 0.65);
  border-bottom: 2px solid rgba(17, 17, 17, 0.65);
  pointer-events: none;
  z-index: 2147483646;
}
html.dark .a11y-reading-guide,
html.a11y-contrast-high .a11y-reading-guide {
  background: rgba(255, 224, 0, 0.14);
  border-color: rgba(255, 255, 255, 0.75);
}
/* ---- Big cursor ------------------------------------------------------------ */
html.a11y-big-cursor,
html.a11y-big-cursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'%3E%3Cpath d='M4 2 L4 22 L9 17 L12.5 23 L15 21.5 L11.5 16 L18 16 Z' fill='%23ffffff' stroke='%23000000' stroke-width='1.2' stroke-linejoin='round'/%3E%3C/svg%3E") 4 2, auto !important;
}

/* ---- Always-visible, high-contrast focus ring ----------------------------- */
html.a11y-focus-strong :where(a, button, input, textarea, select, summary, [tabindex]):focus {
  outline: 3px solid #ffbf00 !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 3px #000, 0 0 0 6px #ffbf00 !important;
  border-radius: 4px;
}

/* ---- Reduce motion (user override, on top of prefers-reduced-motion) ------ */
html.a11y-reduce-motion *,
html.a11y-reduce-motion *::before,
html.a11y-reduce-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

/* ---- Pause auto-playing media / animations -------------------------------- */
html.a11y-pause-media *,
html.a11y-pause-media *::before,
html.a11y-pause-media *::after {
  animation-play-state: paused !important;
}

/* ---- Skip links (visible on focus, first in tab order) -------------------- */
.a11y-skip-links { position: absolute; top: 0; left: 0; z-index: 2147483647; }
.a11y-skip-link {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
}
.a11y-skip-link:focus {
  left: 8px;
  top: 8px;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  clip-path: none;
  padding: 10px 16px;
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Footer link to the accessibility statement --------------------------- */
footer nav a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* ---- Launcher + dialog ------------------------------------------------------ */
.a11y-launcher { position: fixed; z-index: 2147483645; bottom: 20px; right: 20px; }
@media (max-width: 640px) {
  .a11y-launcher { right: 50%; transform: translateX(50%); bottom: 16px; }
}
.a11y-launcher-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; padding: 0; border-radius: 999px;
  border: 1px solid var(--line); background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35); cursor: pointer;
}
.a11y-launcher-btn:hover { filter: brightness(1.08); }

.a11y-backdrop {
  position: fixed; inset: 0; z-index: 2147483645;
  display: flex; align-items: flex-end; justify-content: flex-end;
  background: rgba(0, 0, 0, 0.4); padding: 16px;
}
.a11y-panel {
  width: 100%; max-width: 384px; max-height: 85vh; overflow-y: auto;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}
.a11y-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.a11y-panel h2 {
  font-family: var(--font-display); font-size: 1.625rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.02em; line-height: 1.1; margin: 0;
}
.a11y-panel h2:focus { outline: none; }
.a11y-panel fieldset { display: block; border: 0; margin: 0 0 16px; padding: 0; min-width: 0; }
.a11y-panel legend {
  padding: 0; margin: 0 0 8px; font-family: var(--font-mono); font-size: 0.75rem;
  font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.a11y-stack { display: flex; flex-direction: column; gap: 8px; }
.a11y-row { display: flex; align-items: center; gap: 8px; }
.a11y-seg { display: flex; flex-wrap: wrap; gap: 8px; }
.a11y-scale { min-width: 3.5rem; text-align: center; font-size: 0.875rem; font-weight: 500; }
.a11y-btn {
  font: inherit; font-size: 0.875rem; min-height: 36px; min-width: 36px;
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 2px;
  background: transparent; color: var(--ink); cursor: pointer;
}
.a11y-btn:hover { border-color: var(--accent); }
.a11y-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--wash); font-weight: 600; }
.a11y-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.a11y-btn.a11y-push { margin-left: auto; }
.a11y-close { width: 36px; height: 36px; padding: 0; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.a11y-close:hover { color: var(--ink); }
.a11y-switch {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left; font: inherit; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 2px; background: transparent; color: var(--ink); cursor: pointer;
}
.a11y-switch:hover { border-color: var(--accent); }
.a11y-switch-text { display: flex; flex-direction: column; }
.a11y-switch-label { font-size: 0.875rem; }
.a11y-switch-desc { font-size: 0.75rem; color: var(--muted); }
.a11y-track { position: relative; flex: none; width: 36px; height: 20px; border-radius: 999px; background: var(--line); transition: background 0.15s; }
.a11y-thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 999px; background: var(--surface); transition: transform 0.15s; }
.a11y-switch[aria-checked="true"] .a11y-track { background: var(--accent); }
.a11y-switch[aria-checked="true"] .a11y-thumb { transform: translateX(16px); }
.a11y-foot { margin-top: 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding-top: 16px; }
.a11y-foot a { font-size: 0.875rem; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.a11y-note { margin: 12px 0 0; font-size: 0.75rem; line-height: 1.5; color: var(--muted); }

/* ---- Header theme toggle ---------------------------------------------------- */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; padding: 0;
  border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); }
.theme-toggle:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
