export function smoothScrollToElement(id: string, duration = 800) { const element = document.getElementById(id) if (!element) return const startY = window.scrollY || window.pageYOffset const targetRect = element.getBoundingClientRect() const targetY = startY + targetRect.top const startTime = performance.now() function easeInOutQuad(t: number) { return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t } function step(currentTime: number) { const elapsed = currentTime - startTime const progress = Math.min(elapsed / duration, 1) const eased = easeInOutQuad(progress) const nextY = startY + (targetY - startY) * eased window.scrollTo(0, nextY) if (progress < 1) { requestAnimationFrame(step) } } requestAnimationFrame(step) }