(function() { 'use strict'; const isMobile = window.innerWidth <= 767; const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches; if (prefersReducedMotion) return; document.addEventListener('DOMContentLoaded', () => { const targets = gsap.utils.toArray('[data-manifesto-paragraph]'); if (!targets.length) return; const splits = []; const triggers = []; const destroy = () => { while (triggers.length) triggers.pop().kill(); while (splits.length) splits.pop().revert(); }; const build = () => { destroy(); targets.forEach(target => { const split = new SplitText(target, { type: 'lines', linesClass: 'manifesto-line' }); splits.push(split); const blurAmount = isMobile ? 8 : 16; const yOffset = isMobile ? 11 : 22; const duration = isMobile ? 0.4 : 0.6; split.lines.forEach((line, idx) => { line.dataset.manifestoLine = idx + 1; gsap.set(line, { filter: `blur(${blurAmount}px)`, opacity: 0.15, y: yOffset }); const trigger = ScrollTrigger.create({ trigger: line, start: 'top 80%', end: 'bottom 60%', ...(isMobile && { markers: false, fastScrollEnd: true }), onEnter: () => gsap.to(line, { filter: 'blur(0px)', opacity: 1, y: 0, duration: duration, ease: 'power2.out' }), onLeaveBack: () => gsap.to(line, { filter: `blur(${blurAmount}px)`, opacity: 0.15, y: yOffset, duration: 0.4, ease: 'power2.in' }) }); triggers.push(trigger); }); }); if ('requestIdleCallback' in window) { requestIdleCallback(() => ScrollTrigger.refresh(), { timeout: 100 }); } else { setTimeout(() => ScrollTrigger.refresh(), 0); } }; build(); if (document.fonts?.ready) { document.fonts.ready.then(() => { if (splits.length === 0) build(); else ScrollTrigger.refresh(); }).catch(() => {}); } const debounced = gsap.utils.debounce(build, 150); window.addEventListener('resize', debounced); if (window.lenis) { window.lenis.on('scroll', ScrollTrigger.update); ScrollTrigger.addEventListener('refresh', () => { if (window.lenis?.update) { requestAnimationFrame(() => window.lenis.update()); } }); } }); })();