/* assembly-motion player styles. Same choreography as the owner's System Atlas card:
   each layer falls (accelerating) to 1 px past its seat, springs back to -0.4 px, settles at 0: the latch.
   A ring flashes at the seat as it latches. Only transform and opacity animate, so the browser composites
   the layers and never repaints the drawing.
   Tokens a host page may set on .am-machine (or any ancestor): */
.am-machine {
  --am-ring: #1f4e9c; /* ring colour: use the drawing's ink */
  --am-ring-size: 9px;
  --am-ease: cubic-bezier(0.3, 0.7, 0.3, 1);
  --am-latch: 0.5s; /* one part's drop + latch */
  --am-ring-time: 0.42s;
  position: relative;
  display: block;
  flex: 0 0 auto;
}
.am-layer {
  /* left/top/width/height come from the layer's box (whole CSS px of the frame) */
  position: absolute;
  display: block;
  max-width: none; /* a host's img { max-width: 100% } would squeeze a layer off its box */
  pointer-events: none;
  user-select: none;
}
.am-seat {
  position: absolute;
  width: var(--am-ring-size);
  height: var(--am-ring-size);
  margin: calc(var(--am-ring-size) / -2) 0 0 calc(var(--am-ring-size) / -2);
  border: 1px solid var(--am-ring);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}
.am-machine[data-am-play='wait'] .am-layer {
  opacity: 0;
}
.am-machine[data-am-play='on'] .am-layer {
  animation: am-latch var(--am-latch) linear var(--at, 0s) both;
}
.am-machine[data-am-play='on'] .am-seat {
  animation: am-ring var(--am-ring-time) var(--am-ease) var(--at, 0s) both;
}
/* a lift (a lid): shown at its closed place from --at, rises to its seat from --open, with a 1 px settle */
.am-machine[data-am-play='on'] .am-layer.am-lift {
  animation: am-appear 0.2s linear var(--at, 0s) both, am-lift 0.6s linear var(--open, 0s) both;
}
@keyframes am-appear {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}
@keyframes am-lift {
  0% {
    transform: translate3d(0, var(--closed, 0px), 0);
    animation-timing-function: cubic-bezier(0.3, 0, 0.2, 1);
  }
  82% {
    transform: translate3d(0, -1px, 0);
    animation-timing-function: ease-in-out;
  }
  100% {
    transform: translate3d(0, 0, 0);
  }
}
/* fall (accelerating) to 1 px past the seat, spring back, settle: the latch.
   The per-keyframe timing functions make the fall speed up and the rebound slow down. */
@keyframes am-latch {
  0% {
    opacity: 0;
    transform: translate3d(0, var(--from, -6px), 0);
    animation-timing-function: cubic-bezier(0.45, 0, 0.9, 0.55);
  }
  40% {
    opacity: 1;
  }
  58% {
    transform: translate3d(0, 1px, 0);
    animation-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
  }
  78% {
    transform: translate3d(0, -0.4px, 0);
    animation-timing-function: ease-in-out;
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}
@keyframes am-ring {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  30% {
    opacity: 0.85;
  }
  100% {
    opacity: 0;
    transform: scale(1.6);
  }
}
/* reduced motion: the finished picture, no movement, no ring */
@media (prefers-reduced-motion: reduce) {
  .am-machine .am-layer,
  .am-machine .am-seat {
    animation: none !important;
  }
  .am-machine[data-am-play] .am-layer {
    opacity: 1 !important;
  }
}
