/* Opening and closing motion for every popup: modals, the service menus, Filter by Address, the account
   dropdown and the calendar day popup. Each fades in while moving a few pixels into place, and fades out
   while moving back. Opening is plain CSS, since Blazor adds the element and the animation runs once on
   insertion. Blazor also removes the element at once on close, so interop.js ("Popup closing motion") puts
   an inert copy with .popup-leaving back in its place and removes it when that animation ends.
   The selectors here and in interop.js must list the same popups. */

/* :where() keeps these at zero specificity, so .popup-leaving below always wins. */
:where(.service-row__menu, .address-filter__menu, .account-dropdown-menu, .upcoming-calendar__tooltip) {
  /* These open downward from their trigger, so they start slightly above where they end up. */
  --popup-shift: calc(-1 * var(--motion-distance-sm));
  animation: popup-in var(--motion-duration-enter) var(--motion-ease-enter);
}

:where(.service-row__menu--flip-up) {
  --popup-shift: var(--motion-distance-sm);
}

/* The overlay only fades; the panel rises into place inside it. */
:where(.modal-backdrop) {
  --popup-shift: 0px;
  animation: popup-in var(--motion-duration-enter) var(--motion-ease-enter);
}

:where(.modal-panel) {
  --popup-shift: var(--motion-distance-sm);
  animation: popup-slide-in var(--motion-duration-enter) var(--motion-ease-enter);
}

.popup-leaving {
  animation: popup-out var(--motion-duration-exit) var(--motion-ease-exit) forwards;
  pointer-events: none;
}

/* A copy of the calendar popup also copies any menu open inside it; don't let that replay its opening. */
.popup-leaving * {
  animation: none;
}

.popup-leaving .modal-panel {
  animation: popup-slide-out var(--motion-duration-exit) var(--motion-ease-exit) forwards;
}

@keyframes popup-in {
  from {
    opacity: 0;
    translate: 0 var(--popup-shift);
  }
}

@keyframes popup-out {
  to {
    opacity: 0;
    translate: 0 var(--popup-shift);
  }
}

@keyframes popup-slide-in {
  from {
    translate: 0 var(--popup-shift);
  }
}

@keyframes popup-slide-out {
  to {
    translate: 0 var(--popup-shift);
  }
}
