/* ── Screen transitions ───────────────────────────────────── */

.screen {
  display: none;
  min-height: 100vh;
  opacity: 0;
  transform: translateY(10px) scale(0.992);
}

.screen.active {
  display: block;
  opacity: 1;
  transform: none;
  animation: screenIn 0.48s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.screen.is-leaving {
  display: block !important;
  animation: screenOut 0.32s cubic-bezier(0.4, 0, 1, 1) both;
  pointer-events: none;
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
    filter: blur(2px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

@keyframes screenOut {
  from {
    opacity: 1;
    transform: none;
    filter: none;
  }
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.99);
    filter: blur(1.5px);
  }
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .screen.active,
  .screen.is-leaving {
    animation: none !important;
    opacity: 1;
    transform: none;
    filter: none;
  }
}

/* Content swap inside main (picker ↔ game) */
#tab-content.tc-fade-out {
  animation: contentOut 0.22s ease both;
  pointer-events: none;
}

#tab-content.tc-fade-in {
  animation: contentIn 0.38s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes contentOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(8px); }
}

@keyframes contentIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

/* Game chrome appears smoothly */
#game-chrome {
  animation: contentIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Unit cards stagger a bit more on home */
.unit-card {
  animation: cardSlideIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.unit-card:nth-child(1) { animation-delay: 0.06s; }
.unit-card:nth-child(2) { animation-delay: 0.12s; }
.unit-card:nth-child(3) { animation-delay: 0.18s; }
.unit-card:nth-child(4) { animation-delay: 0.24s; }
.unit-card:nth-child(5) { animation-delay: 0.30s; }

@keyframes cardSlideIn {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: none; }
}

.game-hub-card {
  animation: cardSlideIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(0.04s + var(--i, 0) * 0.04s); /* --i set per card in js/hub.js */
}

@media (prefers-reduced-motion: reduce) {
  .unit-card,
  .game-hub-card {
    animation: none !important;
  }
}

/* ── View transitions (js/ui.js runViewTransition) ──
   The page glides and crossfades; a game card grows into the game; titles move into the header. */
::view-transition-old(root) { animation: vtPageOut 0.26s cubic-bezier(0.4, 0, 1, 1) both; }
::view-transition-new(root) { animation: vtPageIn 0.42s cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes vtPageOut { to { opacity: 0; transform: translateY(-6px) scale(0.995); } }
@keyframes vtPageIn { from { opacity: 0; transform: translateY(10px) scale(0.995); } }

::view-transition-group(game-card),
::view-transition-group(game-title),
::view-transition-group(unit-title) {
  animation-duration: 0.46s;
  animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
}
::view-transition-group(game-card) { border-radius: 18px; overflow: clip; }
::view-transition-old(game-card) { animation: vtFadeOut 0.22s ease-out both; }
::view-transition-new(game-card) { animation: vtFadeIn 0.34s 0.1s ease-in both; }
@keyframes vtFadeOut { to { opacity: 0; } }
@keyframes vtFadeIn { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
