/*
  Topic badges (decision 056): scenes (badges/scene.html, 56 px and up, inline) and stickers
  (badges/sticker.html, below 56 px, from the partials/topic_stickers.html sprite).

  Frames: the topic color comes from [data-topic] (base.css sets --t-bg). The rim, ink and tint
  use palette colors on purpose: a badge is a printed sticker and looks the same in both color
  schemes, like the postmarks (decision 056).

  Motion: only scenes move. Each moving part carries .tb-m and one .tb-m--<move>, which names
  its keyframes in --tb-move. Nothing plays until a host switches it on:
  - .tb-hover on an interactive element holding a scene: hover or keyboard focus plays the move
    (pointer devices only, so a tap leaves no sticky hover);
  - .tb-play on the scene or an ancestor, for a moment with no pointer (a spin landing, a dealt
    card, a page load). static/js/badges.js adds it and takes it off when the move ends, so it
    can play again.
  Every move starts and ends on the drawn pose, lasts 450–900 ms, plays twice and never loops,
  so nothing moves for more than 5 s (WCAG 2.2.2). With reduced motion nothing plays.
*/

/* ---------- Frames ---------- */
.tbadge, .tsticker {
  display: block;
  flex: none;
  overflow: visible;
  --tb-tint: color-mix(in srgb, var(--t-bg, var(--wc-white)) 25%, var(--wc-white)); /* decorative */
}
.tbadge__rim, .tsticker__rim { fill: var(--wc-graph-paper); } /* decorative */
.tbadge__disc { fill: var(--tb-tint); stroke: var(--wc-spy-pond); stroke-width: 4; } /* decorative */
.tbadge__ring { fill: none; stroke: var(--t-bg); stroke-width: 4; stroke-dasharray: 6 6; }
.tsticker__ring { fill: var(--t-bg); stroke: var(--wc-spy-pond); stroke-width: 2.5; } /* decorative */
.tsticker__centre { fill: var(--tb-tint); stroke: var(--wc-spy-pond); stroke-width: 1.5; } /* decorative */

/* ---------- Moving parts ---------- */
.tb-m {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation-duration: 900ms;
  animation-timing-function: ease-in-out;
  animation-iteration-count: 2;
}
.tb-d1 { animation-delay: 150ms; }
.tb-d2 { animation-delay: 300ms; }

.tb-m--rise   { --tb-move: tb-rise; animation-timing-function: ease-in; }
.tb-m--drip   { --tb-move: tb-drip; transform-origin: 50% 0; }
.tb-m--blink  { --tb-move: tb-blink; animation-timing-function: steps(1, end); animation-duration: 450ms; animation-iteration-count: 4; }
.tb-m--wobble { --tb-move: tb-wobble; }
.tb-m--flick  { --tb-move: tb-flick; transform-origin: 100% 0; animation-duration: 600ms; }
.tb-m--fly    { --tb-move: tb-fly; animation-timing-function: ease-out; animation-duration: 600ms; }
.tb-m--pop    { --tb-move: tb-pop; transform-origin: 50% 50%; animation-timing-function: cubic-bezier(.3, 1.6, .5, 1); }
.tb-m--hop    { --tb-move: tb-hop; animation-duration: 700ms; }
.tb-m--swing  { --tb-move: tb-swing; transform-origin: 50% 0; }
.tb-m--flip   { --tb-move: tb-flip; transform-origin: 0 50%; }
.tb-m--wave   { --tb-move: tb-wave; transform-origin: 0 100%; animation-duration: 600ms; }
.tb-m--tumble { --tb-move: tb-tumble; transform-origin: 50% 50%; }
.tb-m--bounce { --tb-move: tb-bounce; animation-duration: 700ms; }

/* ---------- Switching motion on ---------- */
@media (prefers-reduced-motion: no-preference) {
  .tb-play .tb-m { animation-name: var(--tb-move); }
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .tb-hover:is(:hover, :focus-visible) .tb-m { animation-name: var(--tb-move); }
}

/* ---------- Keyframes ---------- */
@keyframes tb-rise   { 0% { transform: none; opacity: 1; } 70% { transform: translateY(-10px); opacity: 0; } 71% { transform: translateY(6px); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes tb-drip   { 0%, 100% { transform: none; } 50% { transform: scaleY(1.45); } }
@keyframes tb-blink  { 0% { opacity: 1; } 50% { opacity: .15; } }
@keyframes tb-wobble { 0%, 100% { transform: none; } 20% { transform: rotate(-7deg); } 45% { transform: rotate(6deg); } 70% { transform: rotate(-3deg); } 85% { transform: rotate(1deg); } }
@keyframes tb-flick  { 0%, 100% { transform: none; } 40% { transform: rotate(-22deg); } 70% { transform: rotate(8deg); } }
@keyframes tb-fly    { 0% { transform: none; opacity: 1; } 60% { transform: translate(8px, 10px); opacity: 0; } 61% { transform: none; opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes tb-pop    { 0%, 100% { transform: none; } 40% { transform: scale(1.18) rotate(-6deg); } 70% { transform: scale(.96); } }
@keyframes tb-hop    { 0%, 100% { transform: none; } 15% { transform: scale(1.06, .9); } 45% { transform: translateY(-12px) scale(.96, 1.06); } 75% { transform: scale(1.05, .93); } }
@keyframes tb-swing  { 0%, 100% { transform: none; } 25% { transform: rotate(9deg); } 75% { transform: rotate(-9deg); } }
@keyframes tb-flip   { 0%, 100% { transform: none; } 50% { transform: scaleX(-1); } }
@keyframes tb-wave   { 0%, 100% { transform: none; } 25% { transform: rotate(-14deg); } 75% { transform: rotate(10deg); } }
@keyframes tb-tumble { 0%, 100% { transform: none; } 50% { transform: translate(-4px, -8px) rotate(-90deg); } }
@keyframes tb-bounce { 0%, 100% { transform: none; } 50% { transform: translateY(-10px); } }
