document.addEventListener('DOMContentLoaded', () => { const carrousel = document.getElementById('carrousel'); if (carrousel) { new Flickity(carrousel, { autoPlay: true, groupCells: '75%', }); } const punch = document.getElementById('punch'); const navbar = document.getElementById('navbar'); const homeTitle = document.getElementById('home-title'); if (navbar || punch || homeTitle) { let lastScrollY = window.scrollY; window.addEventListener('scroll', () => { let currentScrollY = window.scrollY; if (navbar) { if (lastScrollY > currentScrollY) { navbar.style.top = '0'; } else { navbar.style.top = '-140px'; } lastScrollY = currentScrollY; } if (punch) { const punchPosition = punch.getBoundingClientRect(); if (currentScrollY > punchPosition.bottom + (window.innerHeight / 2)) { punch.style.color = '#F8FAFC'; punch.style.backgroundColor = '#222'; } else { punch.style.color = '#222'; punch.style.backgroundColor = '#F8FAFC'; } } if (homeTitle) { if (currentScrollY > 1000) { homeTitle.style.display = 'none'; } else { homeTitle.style.display = 'flex'; } } }); } });