/* Animation of state changes in the puzzles and figures.
 *
 * The movement itself is driven from JavaScript (Automata.anim in js/automata.js), one transform per
 * token and frame. This file styles what goes with it: the arrow in use, the merge badge, the Sets view,
 * and the small switch "Animation: on / off". With prefers-reduced-motion nothing moves: a result
 * appears at once, and only a short fade remains. */

/* ---- the switch: animation on or off, normal or fast, skip to the end */
.an-row { gap: 0.4rem; }
.an-row .am-tool, .am-tool.an-skip { font-size: 0.78rem; padding: 0.15rem 0.6rem; }
.an-row .an-toggle, .an-row .an-speed { border-color: var(--rule); color: var(--muted); }
.an-row .an-toggle:hover, .an-row .an-speed:hover { color: var(--ink); }
.am-tool.an-skip { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.am-tool.an-skip[hidden], .an-row .am-tool[hidden] { display: none; }

/* ---- puzzles: tokens are placed frame by frame, so they have no transition of their own */
.pz-tok { transition: opacity 0.2s; will-change: transform; }
.pz-tok.fused .pz-tok-in { animation: an-fuse 0.36s ease-out; }
@keyframes an-fuse { from { transform: scale(1.5); } to { transform: scale(1); } }
.pz-tok.an-in { animation: an-fade 0.22s ease-out; }
@keyframes an-fade { from { opacity: 0; } }

/* how many possibilities became one */
.an-badge { pointer-events: none; }
.an-badge rect { fill: var(--payoff); }
.an-badge text { fill: var(--paper); font-family: var(--font-ui); font-size: 10.5px; font-weight: 700; text-anchor: middle; }
.an-badge-in { animation: an-badge 1.4s ease-out forwards; }
@keyframes an-badge {
  0% { opacity: 0; transform: translateY(5px) scale(0.5); }
  12% { opacity: 1; transform: translateY(0) scale(1.15); }
  22% { transform: translateY(0) scale(1); }
  75% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-7px) scale(1); }
}
@keyframes an-badge-fade { 0% { opacity: 0; } 12% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }

/* the arrows, tubes and wheels of the move that is being made */
.pz[data-go="0"] .pz-arrow:not(.k0), .pz[data-go="1"] .pz-arrow:not(.k1),
.pz[data-go="2"] .pz-arrow:not(.k2), .pz[data-go="3"] .pz-arrow:not(.k3) { opacity: 0.1; }
.pz-arrow.go { opacity: 1; stroke-width: 3; }
.pz-arrow.head.go { stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.pz[data-go] .pz-tube:not(.go), .pz[data-go] .pz-tube-head { opacity: 0.2; }
.pz-tube.go { opacity: 0.9; }
.pz-wheel.spoke.an-spin { transform-box: fill-box; transform-origin: center; animation: an-spin 0.42s linear; }
@keyframes an-spin { to { transform: rotate(360deg); } }

/* the move that has just been added to the list */
.pz-chip.an-new { animation: an-pop 0.24s ease-out; }
@keyframes an-pop { from { transform: scale(0.6); opacity: 0.3; } }

/* ---- puzzles, Sets view: chips in flight, the walk on the map of sets, pairs that close */
.pz-strip-dot { transition: background-color 0.18s, color 0.18s, border-color 0.18s; }
.pz-strip-ghost { z-index: 1; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.3); transition: none; }
.pz-land-node.here.an-wait { fill: var(--panel); stroke-dasharray: 3 2; }
.pz-land-walker { pointer-events: none; }
.pz-land-edge.go { stroke-width: 2.8; opacity: 1; }
.pz-pair-table td.an-left { animation: an-left 0.4s ease-out; }
@keyframes an-left { from { background: var(--token); color: var(--token-ink); } }

/* ---- figures: the landscape of sets (warmups.js) */
.wu-ls-node.cur.an-wait { fill: var(--accent-soft); }
.wu-ls-label.on.an-wait { fill: var(--ink); }
.an-walker { pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .pz-tok { will-change: auto; }
  .pz-tok.fused .pz-tok-in, .pz-wheel.spoke.an-spin, .pz-chip.an-new, .pz-pair-table td.an-left { animation: none; }
  .an-badge-in { animation-name: an-badge-fade; }
  .pz-strip-dot { transition: none; }
}
