| 58 | |
| 59 | // Enhanced foldout behavior |
| 60 | function initializeFoldouts() { |
| 61 | // Add smooth animations to details elements |
| 62 | const detailsElements = document.querySelectorAll("details"); |
| 63 | |
| 64 | detailsElements.forEach((details) => { |
| 65 | const summary = details.querySelector("summary"); |
| 66 | |
| 67 | // Add click analytics/feedback |
| 68 | summary.addEventListener("click", function (e) { |
| 69 | // Small delay to allow default behavior |
| 70 | setTimeout(() => { |
| 71 | // Scroll into view if needed |
| 72 | if (details.open) { |
| 73 | const rect = details.getBoundingClientRect(); |
| 74 | const isInViewport = |
| 75 | rect.top >= 0 && rect.bottom <= window.innerHeight; |
| 76 | |
| 77 | if (!isInViewport) { |
| 78 | details.scrollIntoView({ |
| 79 | behavior: "smooth", |
| 80 | block: "nearest", |
| 81 | }); |
| 82 | } |
| 83 | } |
| 84 | }, 100); |
| 85 | }); |
| 86 | }); |
| 87 | } |
| 88 | |
| 89 | // Keyboard shortcuts |
| 90 | function initializeKeyboardShortcuts() { |