/** * Casera Landing Page JavaScript */ document.addEventListener('DOMContentLoaded', function() { // Mobile Navigation Toggle const navToggle = document.getElementById('nav-toggle'); const navLinks = document.getElementById('nav-links'); if (navToggle && navLinks) { navToggle.addEventListener('click', function() { navLinks.classList.toggle('active'); navToggle.classList.toggle('active'); }); // Close menu when clicking a link navLinks.querySelectorAll('.nav-link').forEach(link => { link.addEventListener('click', () => { navLinks.classList.remove('active'); navToggle.classList.remove('active'); }); }); } // Smooth Scroll for Anchor Links document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function(e) { const href = this.getAttribute('href'); if (href === '#') return; e.preventDefault(); const target = document.querySelector(href); if (target) { const navHeight = document.querySelector('.nav').offsetHeight; const targetPosition = target.getBoundingClientRect().top + window.pageYOffset - navHeight; window.scrollTo({ top: targetPosition, behavior: 'smooth' }); } }); }); // Scroll Animation Observer const observerOptions = { threshold: 0.1, rootMargin: '0px 0px -50px 0px' }; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('animate-in'); observer.unobserve(entry.target); } }); }, observerOptions); // Observe elements for animation document.querySelectorAll('.feature, .highlight-card, .testimonial-card, .platforms-content').forEach(el => { el.style.opacity = '0'; observer.observe(el); }); // Nav Background on Scroll const nav = document.querySelector('.nav'); let lastScroll = 0; window.addEventListener('scroll', () => { const currentScroll = window.pageYOffset; if (currentScroll > 50) { nav.style.boxShadow = 'var(--shadow-md)'; } else { nav.style.boxShadow = 'none'; } lastScroll = currentScroll; }); });