// Smooth scrolling for navigation links document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); const target = document.querySelector(this.getAttribute('href')); if (target) { target.scrollIntoView({ behavior: 'smooth', block: 'start' }); } }); }); // FAQ Accordion functionality document.querySelectorAll('.faq-question').forEach(question => { question.addEventListener('click', function() { const answer = this.nextElementSibling; const isActive = this.classList.contains('active'); // Close all other FAQ items document.querySelectorAll('.faq-question').forEach(q => { q.classList.remove('active'); q.nextElementSibling.classList.remove('active'); }); // Toggle current item if (!isActive) { this.classList.add('active'); answer.classList.add('active'); } }); }); // Header scroll effect window.addEventListener('scroll', function() { const header = document.querySelector('.header'); if (window.scrollY > 100) { header.style.background = 'rgba(139, 21, 56, 0.95)'; header.style.backdropFilter = 'blur(10px)'; } else { header.style.background = 'linear-gradient(135deg, #8B1538 0%, #A91D3A 100%)'; header.style.backdropFilter = 'none'; } }); // Intersection Observer for animations const observerOptions = { threshold: 0.1, rootMargin: '0px 0px -50px 0px' }; const observer = new IntersectionObserver(function(entries) { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.style.opacity = '1'; entry.target.style.transform = 'translateY(0)'; } }); }, observerOptions); // Observe elements for animation document.querySelectorAll('.benefit-card, .ingredient-card, .pricing-card').forEach(el => { el.style.opacity = '0'; el.style.transform = 'translateY(30px)'; el.style.transition = 'opacity 0.6s ease, transform 0.6s ease'; observer.observe(el); }); // Buy button click handlers document.querySelectorAll('.buy-button').forEach(button => { button.addEventListener('click', function() { // Add click animation this.style.transform = 'scale(0.95)'; setTimeout(() => { this.style.transform = 'scale(1)'; }, 150); // Here you would typically redirect to a payment processor // For demo purposes, we'll show an alert alert('Redirecionando para o checkout...'); }); }); // Mobile menu toggle (if needed) function toggleMobileMenu() { const nav = document.querySelector('.nav'); nav.classList.toggle('mobile-active'); } // Add mobile menu styles if needed const style = document.createElement('style'); style.textContent = ` @media (max-width: 768px) { .nav.mobile-active { display: flex; flex-direction: column; position: absolute; top: 100%; left: 0; right: 0; background: rgba(139, 21, 56, 0.95); padding: 20px; backdrop-filter: blur(10px); } .mobile-menu-toggle { display: block; background: none; border: none; color: white; font-size: 24px; cursor: pointer; } } .mobile-menu-toggle { display: none; } `; document.head.appendChild(style); // Parallax effect for hero section window.addEventListener('scroll', function() { const scrolled = window.pageYOffset; const hero = document.querySelector('.hero'); if (hero) { hero.style.transform = `translateY(${scrolled * 0.5}px)`; } }); // Product image hover effect document.querySelectorAll('.product-image').forEach(img => { img.addEventListener('mouseenter', function() { this.style.transform = 'scale(1.05) rotate(2deg)'; }); img.addEventListener('mouseleave', function() { this.style.transform = 'scale(1) rotate(0deg)'; }); }); // Countdown timer (optional feature) function startCountdown() { const countdownElement = document.getElementById('countdown'); if (!countdownElement) return; let timeLeft = 24 * 60 * 60; // 24 hours in seconds const timer = setInterval(function() { const hours = Math.floor(timeLeft / 3600); const minutes = Math.floor((timeLeft % 3600) / 60); const seconds = timeLeft % 60; countdownElement.innerHTML = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`; timeLeft--; if (timeLeft < 0) { clearInterval(timer); countdownElement.innerHTML = 'EXPIRED'; } }, 1000); } // Initialize countdown if element exists document.addEventListener('DOMContentLoaded', startCountdown); // Form validation (if contact forms are added) function validateEmail(email) { const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; return re.test(email); } // Loading screen (optional) window.addEventListener('load', function() { const loader = document.querySelector('.loader'); if (loader) { loader.style.opacity = '0'; setTimeout(() => { loader.style.display = 'none'; }, 500); } }); // Add to cart functionality with local storage function addToCart(productId, quantity = 1) { let cart = JSON.parse(localStorage.getItem('cart')) || []; const existingItem = cart.find(item => item.id === productId); if (existingItem) { existingItem.quantity += quantity; } else { cart.push({ id: productId, quantity: quantity }); } localStorage.setItem('cart', JSON.stringify(cart)); updateCartDisplay(); } function updateCartDisplay() { const cart = JSON.parse(localStorage.getItem('cart')) || []; const cartCount = cart.reduce((total, item) => total + item.quantity, 0); const cartElement = document.querySelector('.cart-count'); if (cartElement) { cartElement.textContent = cartCount; } } // Initialize cart display document.addEventListener('DOMContentLoaded', updateCartDisplay); // Testimonials slider (if testimonials section is added) function initTestimonialsSlider() { const slider = document.querySelector('.testimonials-slider'); if (!slider) return; let currentSlide = 0; const slides = slider.querySelectorAll('.testimonial'); const totalSlides = slides.length; function showSlide(index) { slides.forEach((slide, i) => { slide.style.display = i === index ? 'block' : 'none'; }); } function nextSlide() { currentSlide = (currentSlide + 1) % totalSlides; showSlide(currentSlide); } // Auto-advance slides setInterval(nextSlide, 5000); // Initialize showSlide(0); } // Initialize testimonials slider document.addEventListener('DOMContentLoaded', initTestimonialsSlider);