// ========== Language Toggle ========== let currentLang = 'fi'; const langToggle = document.getElementById('langToggle'); langToggle.addEventListener('click', () => { currentLang = currentLang === 'fi' ? 'en' : 'fi'; langToggle.textContent = currentLang.toUpperCase(); document.documentElement.lang = currentLang; document.querySelectorAll('[data-fi]').forEach(el => { const text = el.getAttribute(`data-${currentLang}`); if (text) { if (el.tagName === 'A' || el.tagName === 'BUTTON' || el.tagName === 'P' || el.tagName === 'SPAN' || el.tagName === 'H1' || el.tagName === 'H2' || el.tagName === 'H3' || el.tagName === 'LI') { el.innerHTML = text; } } }); }); // ========== Mobile Navigation ========== const hamburger = document.getElementById('hamburger'); const navLinks = document.getElementById('navLinks'); hamburger.addEventListener('click', () => { hamburger.classList.toggle('active'); navLinks.classList.toggle('active'); }); // Close mobile nav on link click navLinks.querySelectorAll('a').forEach(link => { link.addEventListener('click', () => { hamburger.classList.remove('active'); navLinks.classList.remove('active'); }); }); // ========== Navbar Scroll Effect ========== const navbar = document.getElementById('navbar'); window.addEventListener('scroll', () => { if (window.scrollY > 50) { navbar.classList.add('scrolled'); } else { navbar.classList.remove('scrolled'); } }); // ========== Scroll Animations ========== const observerOptions = { threshold: 0.1, rootMargin: '0px 0px -50px 0px' }; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('visible'); } }); }, observerOptions); // Add fade-in class to animatable elements document.querySelectorAll('.theme-card, .region-card, .about-facts li, .section-title, .section-intro').forEach(el => { el.classList.add('fade-in'); observer.observe(el); }); // Stagger theme cards document.querySelectorAll('.theme-card').forEach((card, i) => { card.style.transitionDelay = `${i * 0.1}s`; }); document.querySelectorAll('.about-facts li').forEach((li, i) => { li.style.transitionDelay = `${i * 0.08}s`; });