/* ==========================================================================
   Spotless Mind, Preferences
   In-site accessibility choices, applied as data attributes on <html> before
   first paint (see the inline script in index.html). Each block mirrors the
   OS-level media query the site already honours, so choosing "motion off"
   here does exactly what the OS setting does, and low-stimulation goes one
   step further.

     data-motion="reduce"   every prefers-reduced-motion rule, forced
     data-stim="low"        no ambient field, no swirl, no grain, no marquee,
                            no tilt, no sheen, no gradient type, solid colour
     data-font="dyslexia"   Lexend, wider spacing, longer leading
     data-text="large"      root font-size up 18%
   ========================================================================== */

/* --------------------------------------------------------------------------
   Motion off, mirrors every @media (prefers-reduced-motion: reduce) rule
   -------------------------------------------------------------------------- */
:root[data-motion="reduce"] {
  --dur-instant: 1ms;
  --dur-fast:    1ms;
  --dur-base:    1ms;
  --dur-slow:    1ms;
  --dur-slower:  1ms;
  --reveal-shift: 0px;
  scroll-behavior: auto;
}
:root[data-motion="reduce"] .shimmer { animation: none; }
:root[data-motion="reduce"] .page.active { animation: none; }
:root[data-motion="reduce"] .field::before,
:root[data-motion="reduce"] .field::after { animation: none; }
:root[data-motion="reduce"] #swirl { display: none; }
:root[data-motion="reduce"] .reveal { opacity: 1; transform: none; transition: none; }
:root[data-motion="reduce"] .pulse { animation: none; }
:root[data-motion="reduce"] .sj-orb { animation: none; transform: scale(.9); }
:root[data-motion="reduce"] .bloom-rings { animation: none; }
:root[data-motion="reduce"] .lobe-edge { animation: none; stroke-dashoffset: 0; }
:root[data-motion="reduce"] .marquee-track { animation: none; }
:root[data-motion="reduce"] .marquee { -webkit-mask-image: none; mask-image: none; }
:root[data-motion="reduce"] .scene .sun,
:root[data-motion="reduce"] .scene .wave { animation: none; }
:root[data-motion="reduce"] .bx-node .ring { animation: none; opacity: .3; }
:root[data-motion="reduce"] #loader .ldraw { animation: none; stroke-dashoffset: 0; }
:root[data-motion="reduce"] .confetti { display: none; }
:root[data-motion="reduce"] #net .signal { display: none; }
:root[data-motion="reduce"] .card.tilt { transform: none !important; }

/* --------------------------------------------------------------------------
   Low stimulation. Everything decorative goes; everything functional stays.
   -------------------------------------------------------------------------- */
:root[data-stim="low"] {
  --field-opacity: 0;
  --grain-opacity: 0;
  --swirl-opacity: 0;
}
:root[data-stim="low"] .field,
:root[data-stim="low"] #swirl,
:root[data-stim="low"] .grain,
:root[data-stim="low"] .marquee,
:root[data-stim="low"] .sheen,
:root[data-stim="low"] #net,
:root[data-stim="low"] .bloom-rings,
:root[data-stim="low"] .scene .sun,
:root[data-stim="low"] .badge .pulse { display: none !important; }

:root[data-stim="low"] .grad,
:root[data-stim="low"] .shimmer {
  background-image: none;
  color: var(--brand);
  -webkit-text-fill-color: currentColor;
  animation: none;
}
:root[data-stim="low"] .card:hover { transform: none; }
:root[data-stim="low"] .card:hover .icon { transform: none; }
:root[data-stim="low"] .card:hover .card-go svg { transform: none; }
:root[data-stim="low"] .btn::after { display: none; }
:root[data-stim="low"] .btn:hover { transform: none; }
:root[data-stim="low"] .lobe { fill: var(--brand-tint-2); }
:root[data-stim="low"] .scene { background: var(--surface-inverse); }
:root[data-stim="low"] .scene .wave { display: none; }
:root[data-stim="low"] .glass,
:root[data-stim="low"] .game-shell,
:root[data-stim="low"] .pr-card,
:root[data-stim="low"] .kyb { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--surface); }

/* --------------------------------------------------------------------------
   Dyslexia-friendly reading. Lexend is loaded on demand by prefs.js.
   -------------------------------------------------------------------------- */
:root[data-font="dyslexia"] {
  --font-display: 'Lexend', 'Public Sans', 'Public Sans Fallback', system-ui, sans-serif;
  --font-body:    'Lexend', 'Public Sans', 'Public Sans Fallback', system-ui, sans-serif;
  --leading-prose: 1.85;
  --leading-normal: 1.6;
  --leading-snug: 1.35;
  --tracking-tighter: 0;
  --tracking-tight: 0;
}
:root[data-font="dyslexia"] body {
  letter-spacing: .012em;
  word-spacing: .06em;
}
:root[data-font="dyslexia"] h1,
:root[data-font="dyslexia"] h2,
:root[data-font="dyslexia"] h3 { font-weight: var(--weight-semi); letter-spacing: 0; }
:root[data-font="dyslexia"] p,
:root[data-font="dyslexia"] li { text-align: left; }
:root[data-font="dyslexia"] em { font-style: normal; font-weight: var(--weight-semi); }

/* --------------------------------------------------------------------------
   Larger text. Every size on the site is rem-based, so this scales it all.
   -------------------------------------------------------------------------- */
:root[data-text="large"] { font-size: 118%; }
:root[data-text="large"] .page { padding-inline: clamp(1rem, 0.7rem + 1.4vw, 2rem); }

/* --------------------------------------------------------------------------
   The Settings button and panel
   -------------------------------------------------------------------------- */
#prefsBtn {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  flex-shrink: 0;
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
#prefsBtn:hover { border-color: var(--brand); background: var(--brand-tint); }
#prefsBtn svg { width: 1.125rem; height: 1.125rem; }
#prefsBtn.on { border-color: var(--brand); background: var(--brand-tint-2); }

.st-list { display: flex; flex-direction: column; gap: var(--space-2); margin: var(--space-4) 0; }
.st-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  text-align: left;
  color: var(--text);
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.st-row:hover { border-color: var(--border-brand); }
.st-row[aria-checked="true"] { border-color: var(--brand); background: var(--brand-tint); }
.st-row b { display: block; font-size: var(--text-base); font-weight: var(--weight-semi); }
.st-row span { display: block; font-size: var(--text-sm); color: var(--text-muted); margin-top: 2px; }
.st-row .st-icon {
  display: grid; place-items: center;
  width: 2.25rem; height: 2.25rem;
  border-radius: var(--radius-sm);
  background: var(--brand-tint);
  color: var(--brand);
  flex: none;
}
.st-row .st-icon svg { width: 1.125rem; height: 1.125rem; }
.st-row .st-txt { flex: 1; min-width: 0; }

/* The switch, drawn so its state reads without colour */
.st-sw {
  position: relative;
  flex: none;
  width: 3rem; height: 1.75rem;
  border-radius: var(--radius-full);
  background: var(--border-strong);
  transition: background var(--dur-base) var(--ease-out);
}
.st-sw::after {
  content: "";
  position: absolute;
  top: .1875rem; left: .1875rem;
  width: 1.375rem; height: 1.375rem;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-2);
  transition: transform var(--dur-base) var(--ease-spring);
}
.st-row[aria-checked="true"] .st-sw { background: var(--brand); }
.st-row[aria-checked="true"] .st-sw::after { transform: translateX(1.25rem); background-image: var(--icon-check); background-size: 60%; background-position: center; background-repeat: no-repeat; }

.st-note { font-size: var(--text-sm); color: var(--text-muted); margin-top: var(--space-3); }
.st-reset { margin-top: var(--space-3); }
