/* document.addEventListener("DOMContentLoaded", function () {
    const wrap = document.querySelector(".funfacts-wrap");
    const cards = document.querySelectorAll(".funfacts-wrap .funfact-box");

    if (!wrap || !cards.length) return;

    function animateCards() {
        const rect = wrap.getBoundingClientRect();
        const windowH = window.innerHeight;

        let progress = 1 - rect.top / (windowH * 0.9);
        progress = Math.max(0, Math.min(progress, 1));

        cards.forEach((card, index) => {
            const delay = index * 0.15;
            const localProgress = Math.max(0, Math.min((progress - delay) / 0.45, 1));

            const startX = 900 + index * 160;
            const rotate = index % 2 === 0 ? -10 : 10;

            const x = startX * (1 - localProgress);
            const r = rotate * (1 - localProgress);

            card.style.transform = `translateX(${x}px) rotate(${r}deg)`;
        });
    }

    animateCards();
    window.addEventListener("scroll", animateCards);
}); */