/* Mishap — motion: cards that spring in, tabs that hop, and the "+XP" pop-up
   (fx.js). It loads after the other styles so it can take over the screen's
   own fade (app.css); everything on a card is :where(), which has no weight,
   so a card that already animates itself keeps its own animation.
   Only opacity, translate and scale move (never transform), so nothing
   that sets its own transform is disturbed. */

@keyframes screenFade{from{opacity:0}}
@keyframes cardIn{from{opacity:0;translate:0 16px;scale:.94}}
@keyframes slideNext{from{opacity:0;translate:28px 0}}
@keyframes slidePrev{from{opacity:0;translate:-28px 0}}
@keyframes tabHop{0%{scale:.7;translate:0 5px}55%{scale:1.28;translate:0 -5px}80%{scale:.94;translate:0 1px}100%{scale:1;translate:0 0}}

.screen{animation-name:screenFade}
[data-slide="next"] .screen{animation-name:slideNext;animation-duration:.22s;animation-timing-function:cubic-bezier(.22,1.2,.36,1)}
[data-slide="prev"] .screen{animation-name:slidePrev;animation-duration:.22s;animation-timing-function:cubic-bezier(.22,1.2,.36,1)}

/* the screen's children, one after another; cards inside a list too */
:where(.screen>*, .screen :is([class*="card"],[class*="tile"],.setting-row,.result-row,.vote-card)){
  animation:var(--fx-in,cardIn) .38s cubic-bezier(.34,1.56,.64,1) backwards;
  animation-delay:calc(var(--i,0) * 35ms)}
.screen>:nth-child(2){--i:1}.screen>:nth-child(3){--i:2}.screen>:nth-child(4){--i:3}
.screen>:nth-child(5){--i:4}.screen>:nth-child(6){--i:5}.screen>:nth-child(7){--i:6}
.screen>:nth-child(n+8){--i:7}
.screen :is([class*="card"],[class*="tile"],.setting-row,.result-row,.vote-card):nth-child(2){--i:2}
.screen :is([class*="card"],[class*="tile"],.setting-row,.result-row,.vote-card):nth-child(3){--i:3}
.screen :is([class*="card"],[class*="tile"],.setting-row,.result-row,.vote-card):nth-child(4){--i:4}
.screen :is([class*="card"],[class*="tile"],.setting-row,.result-row,.vote-card):nth-child(n+5){--i:5}

/* the same screen repainting itself (new data) stays put */
.quiet{--fx-in:none}
.quiet .screen{animation:none}

/* a press that gives */
:where(.btn,.tab,[class*="card"],[class*="tile"],.setting-row):active{scale:.97}

.tab.pop svg{animation:tabHop .4s cubic-bezier(.3,1.4,.5,1)}

/* ---------- +XP ---------- */
@keyframes fxCard{0%{opacity:0;scale:.4;translate:0 30px}16%{opacity:1;scale:1.12;translate:0 0}26%{scale:1}82%{opacity:1;translate:0 0}100%{opacity:0;translate:0 -36px}}
@keyframes fxBit{0%{opacity:1;translate:0 0;rotate:0deg;scale:.3}70%{opacity:1}100%{opacity:0;translate:var(--x) var(--y);rotate:var(--r);scale:1}}
@keyframes fxShine{0%,100%{rotate:-8deg}50%{rotate:8deg;scale:1.15}}
.fx-pop{position:fixed;inset:0;z-index:70;display:grid;place-items:center;pointer-events:none}
.fx-card{position:relative;display:flex;flex-direction:column;align-items:center;gap:6px;padding:22px 34px 24px;
  border:1px solid var(--line);border-radius:26px;background:var(--surface);color:var(--ink);box-shadow:0 18px 50px #0003;
  animation:fxCard 2.5s cubic-bezier(.34,1.56,.64,1) both}
.fx-badge{display:grid;place-items:center;width:44px;height:44px;border-radius:50%;background:var(--orange);color:#fff;
  animation:fxShine 1s ease-in-out 2}
.fx-badge svg{width:24px;height:24px}
.fx-title{font:700 13px "IBM Plex Mono",monospace;letter-spacing:.18em;text-transform:uppercase;color:var(--orange)}
.fx-xp{font:800 clamp(44px,15vw,64px)/1 "Sora",sans-serif;letter-spacing:-.02em}
.fx-pop.win .fx-badge{width:54px;height:54px;background:#FFC83D;color:#1c1c1f}
.fx-pop.win .fx-badge svg{width:30px;height:30px}
.fx-burst{position:absolute;left:50%;top:38%;width:0;height:0}
.fx-burst i{position:absolute;left:0;top:0;width:var(--w);height:calc(var(--w) * 1.6);border-radius:2px;background:var(--c);
  animation:fxBit 1.15s cubic-bezier(.15,.8,.3,1) forwards}

@media (prefers-reduced-motion:reduce){
  :where(.screen>*, .screen :is([class*="card"],[class*="tile"],.setting-row,.result-row,.vote-card)),
  [data-slide] .screen, .tab.pop svg, .fx-badge{animation:none}
  :where(.btn,.tab,[class*="card"],[class*="tile"],.setting-row):active{scale:1}
  .fx-card{animation:fxFade 2.5s both}
  .fx-burst{display:none}
  @keyframes fxFade{0%{opacity:0}12%,85%{opacity:1}100%{opacity:0}}
}
