export function setupScrollAnimations(): void {
    if (typeof window === 'undefined') return;

    const observerOptions = {
        root: null,
        rootMargin: '0px 0px -50px 0px',
        threshold: 0.1
    };

    const observer = new IntersectionObserver((entries) => {
        entries.forEach(entry => {
            if (entry.isIntersecting) {
                const el = entry.target as HTMLElement;
                const delay = parseInt(el.dataset.delay || '0');

                setTimeout(() => {
                    el.classList.add('is-visible');
                }, delay);

                observer.unobserve(el);
            }
        });
    }, observerOptions);

    document.querySelectorAll('.animate-on-scroll').forEach((el) => {
        observer.observe(el);
    });
}