document.addEventListener('DOMContentLoaded', function() { // Initialize chart initChart(); // Setup event listeners setupEventListeners(); // Add smooth scroll behavior 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' }); } }); }); // Mobile menu toggle document.addEventListener('click', function(e) { if (e.target.closest('.menu-button')) { const sidebar = document.querySelector('custom-sidebar'); if (sidebar) { const aside = sidebar.shadowRoot.querySelector('aside'); aside.classList.toggle('open'); // Add animation class aside.style.transform = aside.classList.contains('open') ? 'translateX(0)' : 'translateX(-100%)'; } } }); // Close sidebar when clicking outside on mobile document.addEventListener('click', function(e) { const sidebar = document.querySelector('custom-sidebar'); if (window.innerWidth < 1024 && sidebar && !e.target.closest('custom-sidebar') && !e.target.closest('.menu-button')) { const aside = sidebar.shadowRoot.querySelector('aside'); if (aside.classList.contains('open')) { aside.classList.remove('open'); aside.style.transform = 'translateX(-100%)'; } } }); // Add parallax effect to cards const observerOptions = { threshold: 0.1, rootMargin: '0px 0px -50px 0px' }; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.style.opacity = '1'; entry.target.style.transform = 'translateY(0)'; } }); }, observerOptions); // Observe all cards document.querySelectorAll('.group').forEach(card => { card.style.opacity = '0'; card.style.transform = 'translateY(20px)'; card.style.transition = 'all 0.6s cubic-bezier(0.4, 0, 0.2, 1)'; observer.observe(card); }); // Add interactive hover effects document.querySelectorAll('button, .activity-item').forEach(element => { element.addEventListener('mouseenter', function() { this.style.transform = 'scale(1.05)'; }); element.addEventListener('mouseleave', function() { this.style.transform = 'scale(1)'; }); }); // Initialize tooltips document.querySelectorAll('[data-tooltip]').forEach(element => { element.addEventListener('mouseenter', function(e) { const tooltip = document.createElement('div'); tooltip.className = 'absolute bg-gray-800 text-white text-xs rounded px-2 py-1 z-50'; tooltip.textContent = this.getAttribute('data-tooltip'); tooltip.style.top = e.pageY - 30 + 'px'; tooltip.style.left = e.pageX + 10 + 'px'; document.body.appendChild(tooltip); }); element.addEventListener('mouseleave', function() { const tooltip = document.querySelector('.absolute.bg-gray-800'); if (tooltip) tooltip.remove(); }); });