.library-motion {
  display: grid;
  gap: 8px;
}

.library-motion-stage {
  position: relative;
  container-type: size;
  overflow: hidden;
  min-height: 256px;
  aspect-ratio: 6 / 5;
  background: radial-gradient(ellipse at 50% 78%, #17424d, #091b2a 72%);
  border: 1px solid #3b7388;
  box-shadow: inset 0 0 0 3px #0c2537;
}

.library-motion-figure {
  --platform-inset: 14px;
  --sprite-inset: 15px;
  --foot-inset: calc(var(--platform-inset) + var(--sprite-inset));
  --frame-margin: 8px;
  position: absolute;
  inset: 0 0 var(--platform-inset);
  width: min(
    68%, 228px,
    calc((100cqh - var(--foot-inset) - var(--frame-margin)) / var(--library-rise, 1.02)),
    calc((100cqw - 2 * var(--frame-margin)) / var(--library-span, 1.34)),
    calc((var(--foot-inset) - var(--frame-margin)) / var(--library-drop, .08))
  );
  margin-inline: auto;
}

.library-motion-platform {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.library-motion-sprite {
  position: absolute;
  bottom: var(--sprite-inset);
  left: var(--kernel-draw-left, var(--motion-left, var(--kernel-left, 0%)));
  width: var(--kernel-draw-width, var(--motion-width, var(--kernel-width, 100%)));
  aspect-ratio: 1;
  background-image: var(--motion-frame, var(--art-file));
  background-position: center bottom;
  background-size: contain;
  background-repeat: no-repeat;
  transform: translate(var(--kernel-draw-x, var(--motion-offset-x, var(--kernel-offset-x, 0%))), var(--kernel-draw-y, var(--motion-offset-y, var(--kernel-offset-y, 0%))));
  image-rendering: pixelated;
}

.library-motion-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.library-motion-actions button {
  flex: 1 0 auto;
  min-height: 42px;
  padding: 4px 3px;
  border: 1px solid #41778a;
  border-radius: 2px;
  color: #deeff5;
  background: #0c293c;
  font: inherit;
  font-size: 12px;
}

.library-motion-actions button:is(:hover, :focus-visible, [aria-pressed="true"], [aria-current="step"]) {
  color: #f4ffe7;
  border-color: #b9db8b;
  background: #244348;
}

.library-motion-actions button:focus-visible {
  outline: 2px solid #e1efa5;
  outline-offset: 1px;
}

.library-motion-actions .library-motion-sequence {
  flex: 0 0 36px;
  color: #b9db8b;
}

.library-motion-sequence[aria-pressed="false"] span:last-child,
.library-motion-sequence[aria-pressed="true"] span:first-child {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .library-motion-sequence { display: none; }
}

.drive-inspector .folder-motion-button {
  display: block;
  width: fit-content;
  margin-top: 8px;
}

.stock-controls .folder-motion-button {
  padding-inline: 10px;
  min-height: 40px;
}
