Something appears out of display:none and goes back again, both ends
animated, with no library and no timer. Two CSS features do it:
@starting-style supplies the state a new element never had, and
transition-behavior: allow-discrete keeps the node painted until the exit has
finished.
@starting-style gave it one. On the way out it is still here while it leaves,
because display is in the transition list with allow-discrete.
overlay is in the listA popover lives in the browser’s top layer. Close it and it is removed from that layer
immediately, so its exit would play behind the rest of the page. Transitioning
overlay with allow-discrete keeps it up there until the end. The
backdrop needs its own @starting-style block, because the nested form does not
work on a pseudo-element.
It rose on the emphasised decelerate curve over 350ms and will leave on the accelerate curve over 200ms. Escape closes it, focus is trapped in it, and the backdrop fades with it. All of that is the platform; none of it is code here.
.pop{
display:none; opacity:0; translate:0 -10px;
transition: opacity .2s, translate .2s, display .2s allow-discrete;
}
.pop.open{
display:block; opacity:1; translate:0 0;
transition-duration:.35s; /* in is slower than out */
}
@starting-style{ /* AFTER .pop.open */
.pop.open{ opacity:0; translate:0 -10px }
}
/* in the top layer, add: overlay .2s allow-discrete */
@media (prefers-reduced-motion:reduce){
.pop, .pop.open{ translate:none !important } /* keep the fade */
}