Improves navigation on narrow viewports by moving the TOC into the article and collapsing long lists with a show more/less toggle.
Prevents duplicate TOCs and reduces scroll “fighting” by disposing/reinitializing scrollspy on resize and keeping auto-scrolling behavior limited to the right-side desktop panel.
Prevents mobile scroll “fighting” by limiting scrollspy and the page TOC to desktop-sized viewports.
Removes any existing TOC markup and related layout class when below the desktop breakpoint to avoid interfering with touch scrolling.