// Initialize cart functionality let cart = []; document.addEventListener('DOMContentLoaded', () => { // Cart count update updateCartCount(); // Smooth scrolling for anchor links document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); document.querySelector(this.getAttribute('href')).scrollIntoView({ behavior: 'smooth' }); }); }); }); function addToCart(product) { cart.push(product); updateCartCount(); // In a real app, you'd probably show a notification here } function updateCartCount() { const cartCountElements = document.querySelectorAll('.cart-count'); cartCountElements.forEach(el => { el.textContent = cart.length > 0 ? cart.length : ''; }); } // Simple cart toggle (would be expanded in a real app) function toggleCart() { console.log("Cart would open now with", cart.length, "items"); // In reality, you'd show a modal or sidebar with cart items }