document.addEventListener("DOMContentLoaded", function() {var scrollLinks = document.querySelectorAll('a[href^="#"]');for (var i = 0; i < scrollLinks.length; i++) {scrollLinks[i].addEventListener("click", smoothScroll);}function smoothScroll(event) {event.preventDefault();var targetId = this.getAttribute("href");var targetElement = document.querySelector(targetId);var startPosition = window.pageYOffset;var targetPosition = targetElement.offsetTop;var distance = targetPosition - startPosition;var duration = 1000;var startTime = null;function scrollAnimation(currentTime) {if (startTime === null) startTime = currentTime;var timeElapsed = currentTime - startTime;var scrollProgress = Math.min(timeElapsed / duration, 1);var easing = function(t) {return t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;};var scrollStep = distance * easing(scrollProgress);window.scrollTo(0, startPosition + scrollStep);if (timeElapsed < duration) {requestAnimationFrame(scrollAnimation);}}requestAnimationFrame(scrollAnimation);}});
