Enter and exit

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.

The pattern, and the same thing without it

This faded and rose on the way in. It had no previous state, so @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.
This one popped in and cut out. Same markup, same opacity transition, neither of the two features. This is the behaviour people install a library to escape.

In the top layer, where a third property is needed

Why overlay is in the list

A 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.

A sheet from the bottom

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.

What you paste

.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 */
}