// Schalter für Hintergrund-Animationen (Matrix-Regen, blinkender Cursor), pro Browser gemerkt. // Bei "Bewegung reduzieren" im System ist die Animation ohnehin aus. const KEY = 'p42.calm'; const EVENT = 'p42:motion'; const systemReduced = () => window.matchMedia('(prefers-reduced-motion: reduce)').matches; export function isCalm() { if (systemReduced()) return true; try { return localStorage.getItem(KEY) === '1'; } catch { return false; } } export function setCalm(calm) { try { localStorage.setItem(KEY, calm ? '1' : '0'); } catch { /* ignorieren */ } apply(); } export function onMotionChange(fn) { window.addEventListener(EVENT, fn); return () => window.removeEventListener(EVENT, fn); } export const motionLocked = systemReduced; function apply() { document.documentElement.classList.toggle('calm', isCalm()); window.dispatchEvent(new Event(EVENT)); } apply();