// MgCardView - Scroll handling window.MgCardView = { scrollToElement: function (elementId) { const element = document.getElementById(elementId); if (!element) return; // Find the closest scroll container const scrollArea = element.closest('.mg-card-scroll-area'); if (scrollArea) { const containerRect = scrollArea.getBoundingClientRect(); const elementRect = element.getBoundingClientRect(); const offset = elementRect.top - containerRect.top - (containerRect.height - elementRect.height) / 2; scrollArea.scrollBy({ top: offset, behavior: 'smooth' }); } else { element.scrollIntoView({ behavior: 'smooth', block: 'center' }); } } };