CSS Motion Path.
Animate offset-distance to follow an authored curve without a JavaScript motion library.
View code
<svg class="route" viewBox="0 0 280 150" aria-label="Animated path" role="img"><path d="M20 102 C60 9 99 11 133 69 S215 140 260 50" fill="none" stroke="currentColor" stroke-width="2" stroke-dasharray="4 6" opacity=".48"/><circle class="traveler" cx="0" cy="0" r="8" fill="currentColor"/></svg>:root { color-scheme: dark; font: 15px system-ui, sans-serif; color: #dbff55; }
* { box-sizing: border-box; }
body { margin: 0; height: 100dvh; display: grid; place-items: center; overflow: hidden; background: transparent; }
.tile { display: grid; place-items: center; width: 68px; aspect-ratio: 1; border-radius: 18px; background: currentColor; }
.tile { background: #dbff55; color: #202415; font-size: 30px; }
canvas { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; }
button { font: inherit; color: #f3f1e9; background: #191919; border: 1px solid #ffffff66; padding: 8px 14px; border-radius: 24px; cursor: pointer; }
:focus-visible { outline: 2px solid #dbff55; outline-offset: -3px; }
.notice { max-width: 34ch; padding: 16px; color: #fff; }
@media (prefers-reduced-motion: reduce) { .sprite { animation-play-state: paused; } }
.route { width:min(86%,420px); height:80%; }
.traveler {
offset-path: path("M20 102 C60 9 99 11 133 69 S215 140 260 50");
offset-anchor: center;
animation: travel 3s ease-in-out infinite alternate;
}
@keyframes travel { from { offset-distance: 0%; } to { offset-distance: 100%; } }
@media (prefers-reduced-motion: reduce) { .traveler { animation-play-state: paused; } }// The offset-distance keyframes move the circle along the CSS motion path.