// Full-viewport overlay with a 48px transparent slit that follows the cursor. const SLIT = 48; const STYLE_BASE = 'position:fixed;left:0;right:0;background:rgba(0,0,0,.82);pointer-events:none;z-index:2147483645;'; let top: HTMLElement | null = null; let bot: HTMLElement | null = null; let handler: ((e: MouseEvent) => void) | null = null; export function toggle(on: boolean): void { if (on) { top = document.createElement('div'); top.id = 'accessmate-mask-top'; top.style.cssText = STYLE_BASE + 'top:0;height:0'; bot = document.createElement('div'); bot.id = 'accessmate-mask-bot'; bot.style.cssText = STYLE_BASE + 'bottom:0;height:' + window.innerHeight + 'px'; document.body.appendChild(top); document.body.appendChild(bot); handler = (e: MouseEvent) => { const y = e.clientY; if (top) top.style.height = `${Math.max(0, y - SLIT / 2)}px`; if (bot) bot.style.height = `${Math.max(0, window.innerHeight - y - SLIT / 2)}px`; }; document.addEventListener('mousemove', handler, { passive: true }); } else { top?.remove(); bot?.remove(); top = null; bot = null; if (handler) { document.removeEventListener('mousemove', handler); handler = null; } } }