document.addEventListener('DOMContentLoaded', function() { // Add to cart functionality const addToCartButtons = document.querySelectorAll('button:contains("Add to Cart")'); addToCartButtons.forEach(button => { button.addEventListener('click', function() { const productName = this.closest('.bg-white').querySelector('h3').textContent; const productPrice = this.closest('.bg-white').querySelector('span').textContent; // Create cookie animation const cookie = document.createElement('div'); cookie.innerHTML = ''; cookie.className = 'fixed bottom-4 right-4 text-4xl cookie-spin'; document.body.appendChild(cookie); feather.replace(); // Show notification const notification = document.createElement('div'); notification.className = 'fixed bottom-4 left-4 bg-white text-cookie-800 px-4 py-2 rounded-lg shadow-lg flex items-center'; notification.innerHTML = ` Added ${productName} (${productPrice}) to cart! `; document.body.appendChild(notification); feather.replace(); // Remove notification after 3 seconds setTimeout(() => { notification.remove(); cookie.remove(); }, 3000); }); }); // 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' }); }); }); });