const GLOW_KEY = 'aetherforge-glow-particles';

export function loadGlowParticlesEnabled(): boolean {
  try {
    const v = localStorage.getItem(GLOW_KEY);
    if (v === '0') return false;
    if (v === '1') return true;
  } catch {
    /* ignore */
  }
  return true;
}

export function saveGlowParticlesEnabled(enabled: boolean): void {
  try {
    localStorage.setItem(GLOW_KEY, enabled ? '1' : '0');
  } catch {
    /* ignore */
  }
}

export const VISUAL_PREFS_EVENT = 'aetherforge-visual-prefs';

export function dispatchVisualPrefsChange(): void {
  window.dispatchEvent(new CustomEvent(VISUAL_PREFS_EVENT));
}
