/* Smooth motion between screens (motion.js): a tapped card grows into its page or popup and shrinks back. */

/* The card's box moves and resizes; inside it the old and new screens keep their real size and are cut to the
   box from the top left, so nothing is ever stretched. The box is filled with the larger screen's own colour
   (motion.js sets it), so the page behind never shows through while the old screen hands over to the new. */
::view-transition-group(tap-card) {
  animation-duration: 300ms;
  animation-timing-function: cubic-bezier(.3, 0, 0, 1);
  overflow: hidden;
  border-radius: 18px;
  background: var(--motion-surface, transparent);
  box-shadow: 0 24px 48px -28px rgba(29, 26, 22, .45);
}
::view-transition-old(tap-card),
::view-transition-new(tap-card) {
  inset: 0 auto auto 0;
  width: auto;
  height: auto;
  object-fit: none;
  object-position: left top;
}
::view-transition-new(tap-card) { animation: motion-in 150ms 50ms cubic-bezier(.2, 0, 0, 1) both; }
::view-transition-old(tap-card) { animation: motion-out 110ms 40ms linear both; }

/* A picture keeps its shape and scales from the small one into the large one. */
::view-transition-group(tap-picture) {
  animation-duration: 300ms;
  animation-timing-function: cubic-bezier(.3, 0, 0, 1);
}
::view-transition-new(tap-picture) { animation: motion-in 140ms cubic-bezier(.2, 0, 0, 1) both; }
::view-transition-old(tap-picture) { animation: motion-out 100ms 140ms linear both; }
/* Shrinking back, the small picture blown up would look blurred, so the large one stays until the end. */
.motion-back::view-transition-new(tap-picture) { animation: motion-in 90ms 180ms cubic-bezier(.2, 0, 0, 1) both; }
.motion-back::view-transition-old(tap-picture) { animation: motion-out 90ms 200ms linear both; }

::view-transition-old(root),
::view-transition-new(root) { animation-duration: 220ms; }

@keyframes motion-in { from { opacity: 0; } }
@keyframes motion-out { to { opacity: 0; } }

/* While a card grows, panels and sheets skip their own slide in, which would otherwise play inside the card. */
.motion-busy .canvas { transition: none !important; }
.sheet.motion-grown[open] .sheet-panel,
.viewer.motion-grown[open] { animation: none; }
