/* Squishy Town motion system: one set of speeds, curves and presses for the whole game.
   Loaded last so it settles conflicts between older layers. Movement uses transform/opacity only. */
:root{
 --m-tap:90ms;--m-fast:160ms;--m-med:260ms;--m-slow:420ms;
 --m-spring:cubic-bezier(.3,1.6,.5,1);   /* bouncy settle: presses, pops */
 --m-soft:cubic-bezier(.3,1.25,.5,1);    /* gentle overshoot: highlights, cards */
 --m-out:cubic-bezier(.2,.8,.2,1);       /* things arriving */
 --m-in:cubic-bezier(.4,0,.8,.4);        /* things leaving */
 --m-press-scale:.95;--m-press-y:2px;
}

/* ---------- 1. One press for every button ---------- */
html body :is(.btn,.icon-button,.mat-symbol,.bottom-nav button,.gm-tile):not(:disabled){
 transition:scale var(--m-med) var(--m-spring),translate var(--m-med) var(--m-spring),background-color .2s,box-shadow .2s,color .2s,opacity .2s;
}
html body :is(.btn,.icon-button,.mat-symbol,.bottom-nav button,.gm-tile):active:not(:disabled){
 transform:none;translate:0 var(--m-press-y)!important;scale:var(--m-press-scale)!important;
 transition-duration:var(--m-tap);transition-timing-function:ease-out;
}
html body button.mat-symbol:not(:disabled):active svg{transform:none}

/* ---------- 2. Toys: the squish always wins over idle motion ---------- */
html body .toy.v2x-press{animation:none!important}
html body .toy.v2x-jelly{animation:v2x-jelly .55s var(--m-spring)!important}

/* Living shelves: every squishy breathes on its own beat. */
@media(prefers-reduced-motion:no-preference){
 html body[data-place=shop] .toy-card:not(.sold) .toy:not(.v2x-press):not(.v2x-jelly),
 html body[data-place=home] .room-display .toy:not(.v2x-press):not(.v2x-jelly){animation:sq-breathe 3.6s ease-in-out infinite}
 html body[data-place=shop] .toy-card:nth-child(5n+2) .toy:not(.v2x-press):not(.v2x-jelly){animation-delay:-.7s;animation-duration:3.9s}
 html body[data-place=shop] .toy-card:nth-child(5n+3) .toy:not(.v2x-press):not(.v2x-jelly){animation-delay:-1.5s;animation-duration:3.4s}
 html body[data-place=shop] .toy-card:nth-child(5n+4) .toy:not(.v2x-press):not(.v2x-jelly){animation-delay:-2.3s;animation-duration:4.1s}
 html body[data-place=shop] .toy-card:nth-child(5n) .toy:not(.v2x-press):not(.v2x-jelly){animation-delay:-3s;animation-duration:3.7s}
 html body[data-place=home] .room-display .toy:nth-child(2n):not(.v2x-press):not(.v2x-jelly){animation-delay:-1.2s}
 html body[data-place=home] .room-display .toy:nth-child(3n):not(.v2x-press):not(.v2x-jelly){animation-delay:-2.4s}
 @keyframes sq-breathe{0%,100%{translate:0 0;scale:1 1}45%{translate:0 -4px;scale:1.025 .975}70%{translate:0 -1px;scale:.99 1.01}}
}

/* Ultra toys keep their steady golden glow; the old looping filter repainted every frame on every ultra toy. */
html body .material-ultra:not(#squish .toy){animation:none!important}

/* ---------- 3. Popups: soft pop in, quick shrink out ---------- */
@media(prefers-reduced-motion:no-preference){
 @keyframes sq-pop-in{from{opacity:0;scale:.9;translate:0 10px}}
}

/* ---------- 4. Mystery find: poof + sparkles ---------- */
.sq-poof{position:fixed;z-index:2147483000;width:90px;height:90px;border-radius:50%;pointer-events:none;background:radial-gradient(circle,#fff 0 30%,#fff7e8cc 45%,#ffe9f400 70%)}
.sq-poof.gold{background:radial-gradient(circle,#fffbe0 0 26%,#ffe08acc 46%,#ffd15600 72%)}
.sq-spark{position:fixed;z-index:2147483001;width:11px;height:11px;border-radius:50%;pointer-events:none;box-shadow:0 0 6px #fff8}

/* ---------- 5. One message at a time ---------- */
html body:has(.v2l-hand) .shop-try-sign{opacity:0;transition:opacity var(--m-fast)}
html body .shop-try-sign{transition:opacity var(--m-med)}
html.sq-celebrating .v2l-hand,html.sq-celebrating .v2l-tip{opacity:0!important;transition:opacity var(--m-fast)}
.v2q-celebrate.sq-leaving{animation:sq-fade-out .22s var(--m-in) forwards!important;pointer-events:none}
@keyframes sq-fade-out{to{opacity:0;scale:.96}}

/* ---------- 6. Play: all game cards are ready together when the tab appears ---------- */
html body.gm-open .gm-screen .gm-tile{animation:none!important}

/* ---------- 7. Messages slide away instead of blinking out ---------- */
#toast.sq-out{animation:sq-toast-out .2s var(--m-in) forwards!important}
@keyframes sq-toast-out{to{opacity:0;translate:0 -10px}}

/* ---------- 8. Nothing loops while the app is in the background ---------- */
html.sq-paused *,html.sq-paused *::before,html.sq-paused *::after{animation-play-state:paused!important}

/* ---------- 9. Reduce Motion: a safety net under every layer ---------- */
@media(prefers-reduced-motion:reduce){
 *,*::before,*::after{animation-iteration-count:1!important;scroll-behavior:auto!important}
 html body .toy,html body .hunter-shop,html body .town-player{animation:none!important}
 .sq-poof,.sq-spark{display:none!important}
}

/* ---------- 10. Movement on the compositor (no layout work per frame) ---------- */
@media(prefers-reduced-motion:no-preference){
 html body .v2q-pet{left:0;animation-name:sq-pet-walk!important}
 @keyframes sq-pet-walk{0%{translate:-120px 0}45%,55%{translate:calc(50vw - 48px) 0}100%{translate:calc(100vw + 20px) 0}}
 
}
html body .town-player{transition:translate .5s var(--m-out)!important}

/* ---------- 11. A message on screen stays put while tabs change underneath it ---------- */
#toast:not([hidden]){view-transition-name:sq-toast}
::view-transition-group(sq-toast){animation:none}
::view-transition-old(sq-toast){animation:none;opacity:0}
::view-transition-new(sq-toast){animation:none}
html body dialog#modal.sq-ghost{animation:none!important;transition:none!important}
