// DOM Content Loaded event document.addEventListener('DOMContentLoaded', function() { // 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' }); }); }); // Tooltip initialization const tooltipTriggers = document.querySelectorAll('[data-tooltip]'); tooltipTriggers.forEach(trigger => { trigger.addEventListener('mouseenter', function() { const tooltip = document.createElement('div'); tooltip.classList.add('bg-gray-800', 'text-white', 'px-2', 'py-1', 'rounded', 'text-xs', 'absolute', 'z-50', 'whitespace-nowrap'); tooltip.textContent = this.getAttribute('data-tooltip'); document.body.appendChild(tooltip); const rect = this.getBoundingClientRect(); tooltip.style.top = `${rect.top - 30}px`; tooltip.style.left = `${rect.left + rect.width/2 - tooltip.offsetWidth/2}px`; this.addEventListener('mouseleave', function() { tooltip.remove(); }); }); }); }); // Theme toggle functionality function toggleTheme() { const html = document.documentElement; if (html.classList.contains('dark')) { html.classList.remove('dark'); localStorage.setItem('theme', 'light'); } else { html.classList.add('dark'); localStorage.setItem('theme', 'dark'); } } // Check for saved theme preference if (localStorage.getItem('theme') === 'dark') { document.documentElement.classList.add('dark'); }