// Back to top functionality document.addEventListener('DOMContentLoaded', function() { const backToTopButton = document.getElementById('backToTop'); if (backToTopButton) { // Show/hide back to top button based on scroll position window.addEventListener('scroll', () => { if (window.pageYOffset > 300) { backToTopButton.classList.add('show'); } else { backToTopButton.classList.remove('show'); } }); // Smooth scroll to top when clicked backToTopButton.addEventListener('click', (e) => { e.preventDefault(); window.scrollTo({ top: 0, behavior: 'smooth' }); }); } // Fade-in animation for elements const fadeElements = document.querySelectorAll('.fade-in'); const fadeInObserver = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('show'); } }); }, { threshold: 0.1, rootMargin: '0px 0px -50px 0px' }); fadeElements.forEach(element => { fadeInObserver.observe(element); }); // Smooth scrolling for anchor links document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); const targetId = this.getAttribute('href'); if (targetId === '#') return; const targetElement = document.querySelector(targetId); if (targetElement) { targetElement.scrollIntoView({ behavior: 'smooth', block: 'start' }); } }); }); }); const readMoreBtns = document.querySelectorAll('.read-more'); const modals = document.querySelectorAll('.modal'); const closeButtons = document.querySelectorAll('.close-modal'); readMoreBtns.forEach(btn => { btn.addEventListener('click', () => { document.getElementById(btn.dataset.service).classList.add('active'); }); }); closeButtons.forEach(btn => { btn.addEventListener('click', () => { btn.closest('.modal').classList.remove('active'); }); }); modals.forEach(modal => { modal.addEventListener('click', e => { if (e.target === modal) modal.classList.remove('active'); }); });