You can now detect when sticky is actually stuck. In CSS.

Use CSS scroll-state queries to style a sticky element only when it is actually stuck to the top. No scroll listener, no class toggle, no JavaScript.