Finds the nearest scrollable parent element of a given element.
Traverses up the DOM tree to find an ancestor with scrollable overflow.
Falls back to document.documentElement if the viewport itself is scrollable.
Parameters
element: HTMLElement|null
The starting element to search from
Returns HTMLElement|null
The nearest scrollable parent element, or null if none found
Finds the nearest scrollable parent element of a given element. Traverses up the DOM tree to find an ancestor with scrollable overflow. Falls back to document.documentElement if the viewport itself is scrollable.