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'); const mobileMenuIcon = document.getElementById('mobile-menu-icon'); const mobileMenuItems = document.getElementById('mobile-menu-items'); if (navbar || punch || homeTitle) { let lastScrollY = window.scrollY; window.addEventListener('mousemove', (event) => { if (navbar && event.clientY < 100) { navbar.style.top = '0'; } }); window.addEventListener('scroll', () => { let currentScrollY = window.scrollY; if (navbar) { if (lastScrollY > currentScrollY && currentScrollY !== 0) { 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'; } } }); } if (mobileMenuIcon && mobileMenuItems) { mobileMenuIcon.addEventListener('click', () => { mobileMenuItems.style.display = mobileMenuItems.style.display === 'flex' ? 'none' : 'flex'; }); } });