.ui-anim {
    animation-fill-mode: both;
    animation-timing-function: ease-out;
}

.ui-anim--push-up,
.ui-anim--push-down,
.ui-anim--push-left,
.ui-anim--push-right {
    overflow: hidden;
}

.ui-anim--fade-in { animation-name: mebUiAnimFadeIn; }
.ui-anim--fade-out { animation-name: mebUiAnimFadeOut; }

@keyframes mebUiAnimFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes mebUiAnimFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.ui-anim--slide-up { animation-name: mebUiAnimSlideUp; }
.ui-anim--slide-down { animation-name: mebUiAnimSlideDown; }
.ui-anim--slide-left { animation-name: mebUiAnimSlideLeft; }
.ui-anim--slide-right { animation-name: mebUiAnimSlideRight; }

@keyframes mebUiAnimSlideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes mebUiAnimSlideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes mebUiAnimSlideLeft {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes mebUiAnimSlideRight {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.ui-anim--push-up { animation-name: mebUiAnimSlideUp; }
.ui-anim--push-down { animation-name: mebUiAnimSlideDown; }
.ui-anim--push-left { animation-name: mebUiAnimSlideLeft; }
.ui-anim--push-right { animation-name: mebUiAnimSlideRight; }

.ui-anim--zoom-in { animation-name: mebUiAnimZoomIn; }
.ui-anim--zoom-out { animation-name: mebUiAnimZoomOut; }

@keyframes mebUiAnimZoomIn {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes mebUiAnimZoomOut {
    from { transform: scale(1); opacity: 1; }
    to { transform: scale(1.15); opacity: 0; }
}

/* PR2 (Inc2d) -- "step into the room" JOIN reveal keyframes. The stage panel does a
   SUBTLE zoom+fade (scale .98, not --zoom-in's .85, which is too strong for a full
   panel; and NOT --reveal's max-height, which reflows -> CLS). Chrome elements reuse a
   from-above rise. These are global @keyframes so the gameplay hosts' scoped CSS can
   reference them by name (keyed on [data-meb-reveal="entering"]) inside a
   prefers-reduced-motion: no-preference guard. */
@keyframes mebUiAnimRoomEnter {
    from { transform: scale(0.98); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes mebUiAnimRoomChromeRise {
    from { transform: translateY(-12px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.ui-anim--reveal {
    animation-name: mebUiAnimReveal;
    overflow: hidden;
}

@keyframes mebUiAnimReveal {
    from { max-height: 0; opacity: 0; }
    to { max-height: 9999px; opacity: 1; }
}

.ui-anim--bounce-in {
    animation-name: mebUiAnimBounceIn;
    animation-timing-function: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ui-anim--bounce-out {
    animation-name: mebUiAnimBounceOut;
    animation-timing-function: cubic-bezier(0.6, -0.28, 0.735, 0.045);
}

@keyframes mebUiAnimBounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1); }
}

@keyframes mebUiAnimBounceOut {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.3); opacity: 0; }
}

.ui-anim--flip-x {
    animation-name: mebUiAnimFlipX;
    backface-visibility: hidden;
}

.ui-anim--flip-y {
    animation-name: mebUiAnimFlipY;
    backface-visibility: hidden;
}

@keyframes mebUiAnimFlipX {
    from { transform: perspective(800px) rotateX(90deg); opacity: 0; }
    to { transform: perspective(800px) rotateX(0); opacity: 1; }
}

@keyframes mebUiAnimFlipY {
    from { transform: perspective(800px) rotateY(90deg); opacity: 0; }
    to { transform: perspective(800px) rotateY(0); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .ui-anim {
        animation-duration: 0.01ms !important;
        animation-delay: 0ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* SWAP A softening (ADO #8927) -- the /playgame welcome-card hydration "screen refresh".
   When the Blazor InteractiveAuto circuit activates it TEARS DOWN the prerendered welcome-card
   DOM node and repaints a fresh, pixel-identical interactive node -- node identity cannot be
   preserved across the prerender->interactive boundary (verified empirically: Blazor rebuilds the
   subtree even when the markup is byte-identical, so distinctIds==1 is unreachable). That repaint,
   plus the small (~8px desktop) layout shift that lands with it, reads as a flash/refresh.

   We can't remove the rebuild, so we SOFTEN it: give the INTERACTIVE card a brief settle so the
   repaint reads as a gentle rise+fade. translateY(8px)->0 makes the interactive node start at the
   SAME on-screen position the prerendered card occupied, then settle up into its post-shift spot --
   turning the 8px jump into smooth motion instead of a step. Keyed on the interactive render-mode
   marker (data-meb-render-mode = server|wasm) so the STATIC SSR/FCP card is NEVER animated (first
   paint stays instant). Runs once -- the interactive node is built once at hydration. The
   .layout-*-prestart class names are the global playbook-contract classes (not scoped), so this
   global rule matches the WelcomeShell card directly. Reduced-motion users get the instant swap. */
@media (prefers-reduced-motion: no-preference) {
    .layout-game-prestart[data-meb-render-mode="server"],
    .layout-game-prestart[data-meb-render-mode="wasm"],
    .layout-mobile-prestart[data-meb-render-mode="server"],
    .layout-mobile-prestart[data-meb-render-mode="wasm"] {
        animation: mebUiAnimWelcomeHydrate 220ms ease-out;
    }
}

@keyframes mebUiAnimWelcomeHydrate {
    from { opacity: 0.6; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
