Martin Winkler published a package that polyfills Element.matchContainer to get notified in script when a Container Query matches/unmatches. Under the hood, it uses a StyleObserver.
A rather geeky/technical weblog, est. 2001, by Bramus
StyleObserver: Element.matchContainer()@function + CSS if() = 🤯::view-transition-group(*) animationsattr() gets an upgrademoveBefore