document.addEventListener("DOMContentLoaded", async function () { document.documentElement.classList.add("fc-reveal-ready"); if (window.matchMedia("(max-width: 991px)").matches) return; gsap.registerPlugin(ScrollTrigger); if (document.fonts && document.fonts.ready) { try { await document.fonts.ready; } catch (e) {} } function splitToSpans(element) { const text = element.textContent; element.textContent = ""; const frag = document.createDocumentFragment(); text.split("").forEach((char) => { const span = document.createElement("span"); span.classList.add("char"); span.style.opacity = "0"; span.style.filter = "blur(8px)"; span.style.transform = "translateY(20px)"; span.style.color = "inherit"; span.textContent = char; frag.appendChild(span); }); element.appendChild(frag); } const heading1 = document.querySelector(".heading .h1"); const heading2 = document.querySelector(".second_heading .h1.second"); if (heading1) splitToSpans(heading1); if (heading2) splitToSpans(heading2); if (heading1) { const chars1 = heading1.querySelectorAll(".char"); gsap.set(chars1, { opacity: 0, filter: "blur(8px)", y: 20 }); gsap.to(chars1, { opacity: 1, filter: "blur(0px)", y: 0, duration: 0.6, ease: "power2.out", stagger: 0.05, delay: 0.35, scrollTrigger: { trigger: heading1, start: "top 80%", once: true } }); } if (heading2) { const wrapper2 = document.querySelector(".second_heading") || heading2; const chars2 = heading2.querySelectorAll(".char"); gsap.set(chars2, { opacity: 0, filter: "blur(8px)", y: 20 }); gsap.to(chars2, { opacity: 1, filter: "blur(0px)", y: 0, duration: 0.6, ease: "power2.out", stagger: 0.05, delay: 0.35, scrollTrigger: { trigger: wrapper2, start: "top 80%", once: true } }); } requestAnimationFrame(() => ScrollTrigger.refresh()); });