// Injects a style that disables all CSS animations and transitions.
let el: HTMLStyleElement | null = null;

export function toggle(on: boolean): void {
  if (on) {
    if (document.getElementById('accessmate-animations')) return;
    el = document.createElement('style');
    el.id = 'accessmate-animations';
    el.textContent =
      '*,*::before,*::after{' +
      'animation-duration:0.01ms!important;' +
      'animation-iteration-count:1!important;' +
      'transition-duration:0.01ms!important;' +
      'scroll-behavior:auto!important}';
    document.head.appendChild(el);
  } else {
    el?.remove();
    el = null;
  }
}
