/* ============================================================
   HARVEST · ACCESSIBILITY
   WCAG 2.2 AA enhancements, screen reader, focus, mode toggles
   ============================================================ */

/* Screen-reader only text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.sr-only-focusable:focus,
.sr-only-focusable:focus-visible {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* Live region for announcements */
.live-region {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Focus visible enhancement */
.a11y-focus-bold *:focus-visible {
  outline: 4px solid var(--gold) !important;
  outline-offset: 4px !important;
  box-shadow: 0 0 0 8px rgba(229, 187, 114, 0.4) !important;
}

/* Dyslexia-friendly font option */
.a11y-dyslexic-font {
  --font-body: 'Lexend', 'Inter', sans-serif;
  --font-heading: 'Lexend', sans-serif;
  --font-child: 'Lexend', 'AbcPrint', sans-serif;
}
.a11y-dyslexic-font p, .a11y-dyslexic-font li {
  letter-spacing: 0.05em;
  line-height: 1.8;
  word-spacing: 0.1em;
}

/* Increased spacing mode (WCAG 1.4.12) */
.a11y-spacious {
  --sp-3: 1rem;
  --sp-4: 1.5rem;
  --sp-5: 2rem;
}
.a11y-spacious p,
.a11y-spacious li {
  line-height: 2;
  margin-bottom: 1.5em;
}
.a11y-spacious h1,
.a11y-spacious h2,
.a11y-spacious h3 { line-height: 1.4; margin-bottom: 1em; }

/* Reduced motion already in theme.css */

/* High contrast addon — bigger borders */
.a11y-high-contrast .btn,
.a11y-high-contrast .form-input,
.a11y-high-contrast .form-select,
.a11y-high-contrast .form-textarea,
.a11y-high-contrast .choice,
.a11y-high-contrast .choice-btn,
.a11y-high-contrast .card {
  border-width: 2px;
  border-color: var(--ink);
}

/* Larger target sizes (WCAG 2.5.8) - already 48px min, but add a class for 56px+ */
.a11y-large-targets .btn { min-height: 56px; padding: 16px 32px; }
.a11y-large-targets .choice { min-height: 56px; padding: var(--sp-4); }
.a11y-large-targets .choice-btn { min-height: 88px; }
.a11y-large-targets .btn-icon { width: 48px; height: 48px; }

/* Color-independent indicators - icons paired with color */
.has-icon-marker::before {
  content: attr(data-marker);
  display: inline-block;
  margin-right: 6px;
  font-weight: 700;
}
.mastery-secure::before { content: '✓ '; }
.mastery-watch::before { content: '◐ '; }
.mastery-needs::before { content: '⚠ '; }
.mastery-blocked::before { content: '✗ '; }

/* Reading-distance-friendly captions */
.audio-caption {
  font-size: var(--fs-base);
  color: var(--ink-soft);
  font-style: italic;
  background: var(--paper-warm);
  padding: var(--sp-3);
  border-radius: var(--r-sm);
  border-left: 3px solid var(--info);
  margin: var(--sp-3) 0;
}

/* Accessibility panel */
.a11y-panel {
  background: var(--paper);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  max-width: 480px;
  width: 100%;
}
.a11y-panel h2 {
  margin-bottom: var(--sp-4);
  font-family: var(--font-display);
  color: var(--green);
}
.a11y-toggle-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.a11y-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-3);
  background: var(--paper-warm);
  border-radius: var(--r-md);
  border: 1px solid var(--paper-deep);
  cursor: pointer;
}
.a11y-toggle-label {
  font-weight: 600;
  color: var(--ink);
  font-size: var(--fs-sm);
}
.a11y-toggle-desc {
  font-size: var(--fs-xs);
  color: var(--ink-mute);
  margin-top: 2px;
}
.a11y-switch {
  position: relative;
  width: 48px;
  height: 28px;
  background: var(--paper-deep);
  border-radius: var(--r-pill);
  transition: background var(--t-fast) var(--ease);
  flex-shrink: 0;
}
.a11y-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: var(--paper);
  border-radius: 50%;
  transition: transform var(--t-fast) var(--ease);
  box-shadow: var(--shadow-sm);
}
.a11y-toggle.on .a11y-switch { background: var(--green-rich); }
.a11y-toggle.on .a11y-switch::after { transform: translateX(20px); }

.a11y-scale-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.a11y-scale-row label { font-weight: 600; min-width: 100px; font-size: var(--fs-sm); }
.a11y-scale-row input[type="range"] { flex: 1; accent-color: var(--green-rich); }

/* Quiet (low-stim) mode */
.a11y-quiet {
  --shadow-md: var(--shadow-sm);
  --shadow-lg: var(--shadow-sm);
}
.a11y-quiet .atmosphere { display: none; }
.a11y-quiet body { background: var(--paper-warm); }

/* Print accessibility -- always include semantic content */
@media print {
  .sr-only { position: static; width: auto; height: auto; clip: auto; }
}
