// WCAG 1.4.3 — High contrast via CSS invert + hue-rotate.
// Images and videos are double-inverted to restore natural colours.
let el: HTMLStyleElement | null = null;

export function toggle(on: boolean): void {
  if (on) {
    el = document.createElement('style');
    el.id = 'accessmate-contrast';
    el.textContent =
      'html{filter:invert(1) hue-rotate(180deg)!important}' +
      'img,video,canvas,svg{filter:invert(1) hue-rotate(180deg)!important}';
    document.head.appendChild(el);
  } else {
    el?.remove();
    el = null;
  }
}
