Just in case you wouldn’t be aware of it, the CSS :has selector isn’t widely supported, notably Firefox:
:has