// Product data - in a real scenario, this would come from an API
const products = [
{
id: 1,
name: "Classic Hot Chocolate",
price: "£12.99",
image: "http://static.photos/food/400x400/1",
hoverImage: "http://static.photos/food/400x400/2",
rating: 5,
flavor: "classic"
},
{
id: 2,
name: "Zesty Orange Delight",
price: "£14.99",
image: "http://static.photos/food/400x400/3",
hoverImage: "http://static.photos/food/400x400/4",
rating: 5,
flavor: "orange"
},
{
id: 3,
name: "Mint Chocolate Dream",
price: "£14.99",
image: "http://static.photos/food/400x400/5",
hoverImage: "http://static.photos/food/400x400/6",
rating: 5,
flavor: "mint"
},
{
id: 4,
name: "Premium Cocoa Collection",
price: "£24.99",
image: "http://static.photos/food/400x400/7",
hoverImage: "http://static.photos/food/400x400/8",
rating: 5,
flavor: "premium"
}
];
// Load products into the grid
document.addEventListener('DOMContentLoaded', function() {
const productsGrid = document.getElementById('products-grid');
products.forEach(product => {
const productCard = document.createElement('div');
productCard.className = 'product-card bg-white rounded-lg overflow-hidden shadow-md';
let flavorBadge = '';
if (product.flavor === 'orange') {
flavorBadge = 'Orange';
} else if (product.flavor === 'mint') {
flavorBadge = 'Mint';
} else if (product.flavor === 'premium') {
flavorBadge = 'Premium';
}
productCard.innerHTML = `

${flavorBadge}
${product.name}
${product.price}
${''.repeat(product.rating)}
`;
productsGrid.appendChild(productCard);
});
// Re-initialize feather icons after adding new content
feather.replace();
});
// Newsletter subscription
document.addEventListener('DOMContentLoaded', function() {
const newsletterForm = document.getElementById('newsletter-form');
if (newsletterForm) {
newsletterForm.addEventListener('submit', function(e) {
e.preventDefault();
const email = this.querySelector('input[type="email"]').value;
alert(`Thank you for subscribing with ${email}! You'll receive our exclusive offers soon.`);
this.reset();
});
}
// Luxurious Drip Animation on Hero Button
const heroBtn = document.querySelector('a[href="#products"]');
if (heroBtn) {
heroBtn.classList.add('btn-melt');
}
});
// Animate product cards on scroll
const observerOptions = { threshold: 0.2 };
const productObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = 1;
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
document.addEventListener('DOMContentLoaded', () => {
const cards = document.querySelectorAll('.product-card');
cards.forEach(card => {
card.style.opacity = 0;
card.style.transform = 'translateY(30px)';
card.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
productObserver.observe(card);
});
});