.deck-badge {
  position: relative;
  display: inline-block;
  inline-size: 1.4em;
  aspect-ratio: 1;
  flex: none;
  overflow: clip;
  vertical-align: middle;
  border-radius: 17%;
  background-image: var(--deck-sheet);
  background-repeat: no-repeat;
  background-size: var(--deck-size, 300%) var(--deck-size, 300%);
  background-position: var(--deck-x, 0%) var(--deck-y, 0%);
  transform-origin: center 78%;
}

.deck-sections { --deck-sheet: url('/art/deck-sections.webp'); }
.deck-cooking { --deck-sheet: url('/art/deck-cooking.webp'); }
.deck-status { --deck-sheet: url('/art/deck-status.webp'); }
.deck-flavors { --deck-sheet: url('/art/deck-flavors.webp'); --deck-size: 400%; }
.deck-finishes { --deck-sheet: url('/art/deck-finishes.webp'); }
.deck-extras { --deck-sheet: url('/art/deck-extras.webp'); }
.deck-strength.deck-badge { --deck-sheet: url('/art/deck-strength.webp'); --deck-size: 200%; }
.deck-x1 { --deck-x: 50%; }
.deck-x2 { --deck-x: 100%; }
.deck-y1 { --deck-y: 50%; }
.deck-y2 { --deck-y: 100%; }
.deck-flavors.deck-x1 { --deck-x: 33.3333%; }
.deck-flavors.deck-x2 { --deck-x: 66.6667%; }
.deck-flavors.deck-y1 { --deck-y: 33.3333%; }
.deck-flavors.deck-y2 { --deck-y: 66.6667%; }
.deck-x3 { --deck-x: 100%; }
.deck-y3 { --deck-y: 100%; }
.deck-badge.deck-strength.deck-x1 { --deck-x: 100%; }
.deck-badge.deck-strength.deck-y1 { --deck-y: 100%; }

.toon-emblem:has(> .deck-badge) {
  border-radius: 23%;
  box-shadow: .1rem .13rem var(--toon-ink);
  background: #29143e;
}

.toon-emblem > .deck-badge { inline-size: 100%; block-size: 100%; }
.masthead nav .nav-glyph > .deck-badge { inline-size: 1.35rem; }
.wordmark:hover .deck-badge, .masthead nav a:is(:hover, :focus-visible) .deck-badge {
  animation: deck-nod .36s ease-out;
}

.flavor-portrait { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .45rem; }
.flavor-tile { display: grid; min-inline-size: 0; aspect-ratio: 1; }
.flavor-tile .deck-badge { display: block; inline-size: 100%; }
.flavor-tile .deck-cold-tag { font-size: .75rem; padding: .18em .35em; }
.deck-deep-cold, .deck-strength-level { position: relative; display: inline-grid; inline-size: 100%; }
.deck-deep-cold > .deck-badge, .deck-strength-level > .deck-badge { inline-size: 100%; }
.deck-strength-level.is-unknown > .deck-badge { filter: saturate(.25); }
.deck-cold-tag, .deck-strength-tag {
  position: absolute;
  inset-inline-end: 0;
  inset-block-end: 0;
  min-inline-size: 1em;
  padding-inline: .12em;
  border-radius: .24em;
  background: #170925;
  color: #b6fcff;
  font-size: .56rem;
  font-weight: 850;
  line-height: 1;
  text-align: center;
}
.deck-strength-tag { background: #250c18; color: #ffebac; }
.flavor-tile .deck-strength-tag { font-size: .76rem; padding: .2em .38em; }

.flavor-slot {
  position: relative;
  display: block;
  min-inline-size: 0;
  aspect-ratio: 1;
  overflow: clip;
  border-radius: 17%;
  background: #1b1022;
}
.flavor-slot::after {
  position: absolute;
  inset: 0;
  content: '';
  box-shadow: inset 0 5px 7px #10091491, inset 0 -5px 7px #10091491;
  pointer-events: none;
}
.flavor-slot-strip {
  position: absolute;
  inset: 0 0 auto;
  display: grid;
  animation: flavor-roll 1.5s linear infinite;
}
.flavor-slot-strip > .deck-badge { display: block; inline-size: 100%; border-radius: 0; }
.flavor-slot:nth-child(2) .flavor-slot-strip { animation-duration: 1.7s; animation-delay: -.3s; }
.flavor-slot:nth-child(3) .flavor-slot-strip { animation-duration: 1.85s; animation-delay: -.65s; }
.flavor-slot:nth-child(4) .flavor-slot-strip { animation-duration: 2s; animation-delay: -.95s; }
/* Four frames and a repeated first frame let the rolling strip loop seamlessly. */
@keyframes flavor-roll { to { transform: translateY(-80%); } }
@media (prefers-reduced-motion: reduce) { .flavor-slot .flavor-slot-strip { animation: none; } }

.deck-animated {
  animation: deck-nod .34s cubic-bezier(.15, .55, .28, 1) both;
}
.deck-animated:is([data-deck-id="loading"], [data-deck-id="sync"]) { animation: deck-turn .72s ease-in-out 2; }
.deck-animated[data-deck-id="generation"] { animation: deck-stir .48s ease-in-out 3; }
.deck-animated:is([data-deck-id="complete"], [data-deck-id="near"], [data-deck-id="tare"]) { animation: deck-hop .48s cubic-bezier(.2,.8,.25,1.15); }
.deck-animated:is([data-deck-id="surprise"], [data-deck-id="failure"], [data-deck-id^="cold"]):not([data-deck-id="cold0"], [data-deck-id="coldauto"]) { animation: deck-rattle .48s ease-out 2; }
.deck-animated:is([data-deck-id="over"], [data-deck-id="offline"]) { animation: none; }

/* The selected areas use the same sprite as the still pose, then move independently. */
.deck-cut, .deck-blink {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.deck-cut { background: inherit; border-radius: inherit; }
.deck-brows {
  clip-path: polygon(20% 27%, 26% 23%, 43% 38%, 47% 38%, 62% 24%, 67% 26%, 67% 32%, 53% 45%, 46% 46%, 39% 42%, 20% 32%);
  animation: deck-scowl .42s ease-in-out 3;
}
.deck-jaw {
  clip-path: polygon(20% 53%, 25% 48%, 34% 46%, 54% 46%, 65% 49%, 68% 54%, 66% 60%, 58% 60%, 48% 58%, 36% 58%, 26% 61%, 21% 60%);
  animation: deck-grit .14s steps(2, end) 8;
}
.deck-fist-left {
  clip-path: polygon(2% 60%, 11% 57%, 18% 60%, 21% 68%, 16% 76%, 8% 77%, 1% 70%);
  animation: deck-fist-left .29s ease-in-out 4;
}
.deck-fist-right {
  clip-path: polygon(74% 60%, 83% 55%, 95% 55%, 99% 64%, 95% 73%, 87% 77%, 79% 74%);
  animation: deck-fist-right .29s ease-in-out 4;
}
.deck-glance {
  clip-path: polygon(22% 43%, 30% 39%, 39% 42%, 44% 42%, 49% 39%, 56% 40%, 59% 46%, 58% 55%, 53% 61%, 45% 59%, 40% 56%, 34% 62%, 27% 62%, 23% 58%);
  animation: deck-glance 1.7s ease-in-out 2;
}
.deck-blink { opacity: 0; animation: deck-blink 1.7s linear 2; }
.deck-blink::before, .deck-blink::after {
  position: absolute;
  content: '';
  inset-block-start: 40%;
  inset-inline-start: 22.5%;
  inline-size: 20%;
  block-size: 22%;
  border: .07em solid #11252c;
  border-radius: 50% 50% 49% 47%;
  background: #0dd9dd;
  box-shadow: inset 0 -.16em #11252c;
}
.deck-blink::after { inset-inline-start: 41%; inset-block-start: 38%; inline-size: 16%; }
.deck-plug {
  clip-path: polygon(69% 29%, 77% 19%, 78% 16%, 91% 16%, 98% 20%, 97% 37%, 92% 49%, 88% 55%, 87% 67%, 79% 70%, 72% 66%, 69% 58%, 74% 52%, 70% 48%);
  animation: deck-plug 1.7s ease-in-out 2;
  transform-origin: 79% 68%;
}

@keyframes deck-nod { from { transform: translateY(3%) scale(.91) rotate(-5deg); } 62% { transform: translateY(-2%) scale(1.025); } to { transform: none; } }
@keyframes deck-turn { 0%, 100% { transform: none; } 40% { transform: rotate(12deg) scale(.93); } 70% { transform: rotate(-8deg) scale(.98); } }
@keyframes deck-stir { 0%, 100% { transform: none; } 45% { transform: rotate(6deg) translateX(2%); } 75% { transform: rotate(-5deg) translateX(-1%); } }
@keyframes deck-hop { from { transform: translateY(5%) scale(1.05,.86); } 45% { transform: translateY(-7%) scale(.98,1.06); } 78% { transform: scale(1.04,.94); } to { transform: none; } }
@keyframes deck-rattle { 0%, 100% { transform: none; } 25% { transform: rotate(5deg); } 65% { transform: rotate(-5deg); } }
@keyframes deck-scowl { 50% { transform: translateY(2.5%) scaleX(.95); } }
@keyframes deck-grit { 50% { transform: translate(.5%, 2.6%) scaleY(.95); } }
@keyframes deck-fist-left { 50% { transform: translate(-1.6%, -2.6%); } }
@keyframes deck-fist-right { 50% { transform: translate(1.6%, -2.6%); } }
@keyframes deck-glance { 0%, 70%, 100% { transform: none; } 35%, 61% { transform: translateX(2%); } }
@keyframes deck-blink { 0%, 37%, 49%, 100% { opacity: 0; } 41%, 44% { opacity: 1; } }
@keyframes deck-plug { 0%, 63%, 100% { transform: none; } 33%, 48% { transform: rotate(5deg); } }

@media (prefers-reduced-motion: reduce) {
  .deck-badge, .deck-badge *, .wordmark:hover .deck-badge, .masthead nav a:is(:hover, :focus-visible) .deck-badge {
    animation: none !important;
  }
}
