/* Spawn — motion design system */

/* === Screen transitions === */
.screen {
  display: none;
  flex-direction: column;
  opacity: 0;
  transform: translateY(12px) scale(0.992);
  pointer-events: none;
  transition:
    opacity var(--duration-normal) var(--ease-smooth),
    transform var(--duration-normal) var(--ease-spring);
}
.screen.active {
  display: flex;
  opacity: 1;
  transform: none;
  pointer-events: auto;
  transition:
    opacity var(--duration-normal) var(--ease-smooth),
    transform var(--duration-slow) var(--ease-spring);
}
.screen.screen-swap-out {
  opacity: 0;
  transform: translateY(-8px) scale(0.996);
  pointer-events: none;
}
.screen.screen-enter-in {
  animation: screenEnterIn var(--duration-slow) var(--ease-spring);
}

/* Stagger children on screen enter */
.screen.active .news-card,
.screen.active .lfg-card {
  animation: riseIn var(--duration-slow) var(--ease-spring) backwards;
}
.motion-stagger {
  animation: riseIn var(--duration-slow) var(--ease-spring) backwards;
}

.screen.active .discover-toolbar,
.screen.active .world-toolbar,
.screen.active .account-header__title,
.screen.active .account-profile-card {
  animation: riseIn var(--duration-slow) var(--ease-spring) backwards;
}
.screen.active .settings-group {
  animation: riseIn var(--duration-slow) var(--ease-spring) backwards;
}
.screen.active .settings-group:nth-of-type(1) { animation-delay: 0.08s; }
.screen.active .settings-group:nth-of-type(2) { animation-delay: 0.14s; }
.screen.active .settings-group:nth-of-type(3) { animation-delay: 0.2s; }
.screen.active .discover-game-icon {
  animation: riseIn var(--duration-slow) var(--ease-spring) backwards;
}
.screen.active .discover-game-icon:nth-child(1) { animation-delay: 0.06s; }
.screen.active .discover-game-icon:nth-child(2) { animation-delay: 0.1s; }
.screen.active .discover-game-icon:nth-child(3) { animation-delay: 0.14s; }

/* === Stack screens === */
.stack-screen {
  display: flex;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(28px);
  opacity: 0;
  transition:
    transform var(--duration-slow) var(--ease-spring),
    opacity var(--duration-normal) var(--ease-smooth),
    visibility 0s linear var(--duration-slow);
}
.stack-screen.open {
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
  opacity: 1;
  transition:
    transform var(--duration-slow) var(--ease-spring),
    opacity var(--duration-normal) var(--ease-smooth),
    visibility 0s;
}
.stack-screen.stack-enter {
  animation: stackSlideIn var(--duration-slow) var(--ease-spring);
}
.stack-screen.stack-exit {
  animation: stackSlideOut 0.32s var(--ease-smooth) forwards;
}
.stack-screen--live {
  padding: 0;
  overflow: hidden auto;
}
.stack-server-root {
  min-height: 100%;
}
.stack-server-root.stack-content-enter .server-live__hero {
  animation: stackHeroIn 0.55s var(--ease-spring) backwards;
}
.stack-server-root.stack-content-enter .server-live__connect {
  animation: riseIn 0.45s var(--ease-spring) 0.08s backwards;
}
.stack-server-root.stack-content-enter .server-live__toolbar {
  animation: riseIn 0.5s var(--ease-spring) 0.12s backwards;
}
.stack-server-root.stack-content-enter .server-live__nav {
  animation: riseIn 0.5s var(--ease-spring) 0.16s backwards;
}
.stack-server-root.stack-content-enter .server-live__body {
  animation: riseIn 0.55s var(--ease-spring) 0.2s backwards;
}

.motion-press {
  animation: btnPress 0.22s var(--ease-spring);
}
.motion-join-success {
  animation: joinPop 0.55s var(--ease-spring);
}
.sheet-enter {
  animation: sheetRise 0.42s var(--ease-spring);
}
.join-info-scrim.open .join-info-sheet__step {
  animation: riseIn 0.4s var(--ease-spring) backwards;
}
.join-info-scrim.open .join-info-sheet__step:nth-child(1) { animation-delay: 0.06s; }
.join-info-scrim.open .join-info-sheet__step:nth-child(2) { animation-delay: 0.11s; }
.join-info-scrim.open .join-info-sheet__step:nth-child(3) { animation-delay: 0.16s; }
.join-info-scrim.open .join-info-sheet__step:nth-child(4) { animation-delay: 0.21s; }
.join-info-scrim.open .join-info-sheet__step:nth-child(5) { animation-delay: 0.26s; }

.stack-screen.open .server-hero,
.stack-screen.open .server-body > * {
  animation: riseIn var(--duration-slow) var(--ease-spring) backwards;
}
.stack-screen.open .server-body h1 { animation-delay: 0.06s; }
.stack-screen.open .server-body .tags { animation-delay: 0.1s; }
.stack-screen.open .server-actions { animation-delay: 0.14s; }

.stack-screen.open .chat-bubble {
  animation: riseIn var(--duration-normal) var(--ease-spring) backwards;
}
.stack-screen.open .chat-bubble:nth-child(1) { animation-delay: 0.05s; }
.stack-screen.open .chat-bubble:nth-child(2) { animation-delay: 0.12s; }
.stack-screen.open .chat-bubble:nth-child(3) { animation-delay: 0.18s; }

.settings-group .settings-row {
  transition: background var(--duration-fast), transform var(--duration-fast) var(--ease-spring);
}
.settings-group .settings-row:active { transform: scale(0.98); }

.discover-game-icon__thumb {
  transition: transform var(--duration-normal) var(--ease-spring), box-shadow var(--duration-normal);
}
.discover-game-icon:hover .discover-game-icon__thumb {
  box-shadow: var(--shadow-md);
}

.avatar .online {
  animation: onlinePulse 2.5s ease-in-out infinite;
}
@keyframes onlinePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(48, 209, 88, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(48, 209, 88, 0); }
}

/* === Tab bar === */
.tab-btn {
  transition: color var(--duration-fast) var(--ease-smooth), transform var(--duration-fast) var(--ease-spring), background var(--duration-normal) var(--ease-spring), box-shadow var(--duration-normal);
}
.tab-btn.active {
  transform: none;
}
.tab-btn:active { transform: scale(0.94); }

.tab-bar {
  transition: transform var(--duration-slow) var(--ease-spring), opacity var(--duration-normal);
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.tab-bar.hidden {
  display: flex !important;
  transform: translateX(-50%) translateY(calc(100% + 24px));
  opacity: 0;
  pointer-events: none;
}

/* === Feed & cards === */
.news-card {
  transition:
    transform var(--duration-normal) var(--ease-spring),
    box-shadow var(--duration-normal),
    border-color var(--duration-fast);
}
.news-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(255, 255, 255, 0.04);
}

/* === Discover / galaxy === */
#discover-map,
#discover-hub,
#discover-world {
  transition: opacity var(--duration-normal) var(--ease-smooth), transform var(--duration-slow) var(--ease-spring);
}
#discover-map.discover-enter {
  animation: mapEnter 0.55s var(--ease-spring) backwards;
}
#discover-hub.discover-enter {
  animation: worldEnter 0.6s var(--ease-spring) backwards;
}
#discover-hub.discover-enter-from-planet {
  animation: hubFromPlanet 0.85s var(--ease-smooth) forwards;
}
#discover-world.discover-enter-from-hub {
  animation: hubFromHubDeck 0.7s var(--ease-spring) backwards;
}
#discover-map.discover-exit-to-planet {
  animation: galaxyZoomToPlanet 0.48s var(--ease-smooth) forwards;
}
#discover-world.discover-enter {
  animation: worldEnter 0.6s var(--ease-spring) backwards;
}
#discover-map.discover-exit,
#discover-hub.discover-exit,
#discover-world.discover-exit {
  opacity: 0;
  transform: scale(0.97);
  pointer-events: none;
}

.galaxy-node {
  animation: planetFloat 6s ease-in-out infinite;
}
.galaxy-node--rust { animation-delay: 0s; }
.galaxy-planet-host.galaxy-node--rust { animation: planetFloat 6s ease-in-out infinite; }
.galaxy-node--mc { animation-delay: -2s; }
.galaxy-node--ark { animation-delay: -4s; }

.galaxy-node--active .galaxy-node__visual {
  animation: none;
  filter: none;
}

.galaxy-surface.is-ready .galaxy-node {
  animation: planetReveal 0.7s var(--ease-spring) backwards, planetFloat 6s ease-in-out 0.7s infinite;
}
.galaxy-surface.is-ready .galaxy-node--rust { animation-delay: 0.15s, 0.15s; }
.galaxy-surface.is-ready .galaxy-node--mc { animation-delay: 0.28s, -2s; }
.galaxy-surface.is-ready .galaxy-node--ark { animation-delay: 0.4s, -4s; }

.map-controls__btn {
  transition: transform var(--duration-fast) var(--ease-spring), border-color var(--duration-fast), background var(--duration-fast);
}
.map-controls__btn:active { transform: scale(0.88); }
.map-controls__btn:hover { transform: scale(1.06); }
.map-controls__level.is-pulse {
  animation: zoomPulse 0.35s var(--ease-spring);
}

/* === Nav overlay stagger === */
.nav-overlay.open .nav-overlay__item {
  animation: slideMenuItem 0.4s var(--ease-spring) backwards;
}
.nav-overlay.open .nav-overlay__item:nth-child(2) { animation-delay: 0.05s; }
.nav-overlay.open .nav-overlay__item:nth-child(3) { animation-delay: 0.1s; }
.nav-overlay.open .nav-overlay__item:nth-child(4) { animation-delay: 0.15s; }
.nav-overlay.open .nav-overlay__item:nth-child(5) { animation-delay: 0.2s; }

.desktop-topbar__menu {
  transition: transform var(--duration-fast) var(--ease-spring), border-color var(--duration-fast);
}
.desktop-topbar__menu:active { transform: scale(0.9); }
body.nav-open .desktop-topbar__menu { transform: rotate(90deg); }

/* === Modal & toast === */
.modal-scrim {
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-smooth);
}
.modal-scrim.open {
  display: flex;
  opacity: 1;
}
.modal-scrim .sheet {
  transform: translateY(100%);
  transition: transform var(--duration-slow) var(--ease-spring);
}
.modal-scrim.open .sheet {
  transform: translateY(0);
}

.toast {
  transform: translateX(-50%) translateY(-16px) scale(0.96);
  opacity: 0;
  display: block;
  pointer-events: none;
  transition:
    transform var(--duration-normal) var(--ease-spring),
    opacity var(--duration-normal);
}
.toast.show {
  transform: translateX(-50%) translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* === Progress & chips global === */
.progress-fill {
  position: relative;
  overflow: hidden;
  transition: width var(--duration-slow) var(--ease-spring);
}
.progress-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
  transform: translateX(-100%);
  animation: progressShine 2.5s ease-in-out infinite;
}

.chip:active { transform: scale(0.96); }

.btn-primary {
  position: relative;
  overflow: hidden;
}
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.2) 50%, transparent 60%);
  transform: translateX(-120%);
  transition: transform 0.6s ease;
}
.btn-primary:hover::after { transform: translateX(120%); }

/* === Keyframes === */
@keyframes screenEnterIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes riseIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}
@keyframes mapEnter {
  from { opacity: 0; transform: scale(1.03); }
  to { opacity: 1; transform: none; }
}
@keyframes worldEnter {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: none; }
}
@keyframes hubFromPlanet {
  from {
    opacity: 0;
    clip-path: circle(var(--planet-start-r, 80px) at var(--planet-origin-x, 50%) var(--planet-origin-y, 35%));
    transform: scale(0.92);
  }
  60% { opacity: 1; }
  to {
    opacity: 1;
    clip-path: circle(150vmax at 50% 35%);
    transform: none;
  }
}
@keyframes hubFromHubDeck {
  from { opacity: 0; transform: translateY(40px) scale(0.96); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: none; }
}
@keyframes galaxyZoomToPlanet {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: scale(1.08); filter: blur(2px); }
}
@keyframes planetReveal {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes planetFloat {
  0%, 100% { transform: translate(-50%, -50%) translateY(0); }
  50% { transform: translate(-50%, -50%) translateY(-8px); }
}
@keyframes planetGlow {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(232, 93, 4, 0.3)); }
  50% { filter: drop-shadow(0 0 18px rgba(232, 93, 4, 0.55)); }
}
@keyframes islandReveal {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.5) translateY(20px); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes islandFloat {
  0%, 100% { transform: translate(-50%, -50%) translateY(0); }
  50% { transform: translate(-50%, -50%) translateY(-5px); }
}
@keyframes lfgPass {
  to { transform: translateX(-120%) rotate(-12deg); opacity: 0; }
}
@keyframes lfgLike {
  to { transform: translateX(120%) rotate(12deg); opacity: 0; }
}
@keyframes lfgCardIn {
  from { opacity: 0; transform: scale(0.88) translateY(24px); }
  to { opacity: 1; transform: none; }
}
@keyframes chipPop {
  0% { transform: scale(0.92); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1.04); }
}
@keyframes scorePulse {
  0%, 100% { text-shadow: 0 0 0 transparent; }
  50% { text-shadow: 0 0 24px rgba(0, 212, 238, 0.35); }
}
@keyframes promoGlow {
  0%, 100% { box-shadow: var(--shadow-sm); }
  50% { box-shadow: var(--shadow-sm), 0 0 20px rgba(232, 121, 249, 0.15); }
}
@keyframes progressShine {
  0% { transform: translateX(-100%); }
  60%, 100% { transform: translateX(200%); }
}
@keyframes zoomPulse {
  0% { transform: scale(1); color: var(--muted); }
  50% { transform: scale(1.15); color: var(--accent-bright); }
  100% { transform: scale(1); color: var(--muted); }
}
@keyframes dockZoneIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@keyframes dockPulse {
  0%, 100% { opacity: 0.6; transform: scale(0.92); }
  50% { opacity: 1; transform: scale(1); }
}
@keyframes dockIslandFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.screen.active .dock-hero,
.screen.active .dock-zone.is-visible {
  animation: dockZoneIn 0.5s var(--ease-spring) backwards;
}

@keyframes stackSlideIn {
  from { opacity: 0; transform: translateX(32px) scale(0.98); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes stackSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(24px); }
}
@keyframes stackHeroIn {
  from { opacity: 0; transform: scale(1.04); }
  to { opacity: 1; transform: none; }
}
@keyframes btnPress {
  0% { transform: scale(1); }
  45% { transform: scale(0.94); }
  100% { transform: scale(1); }
}
@keyframes joinPop {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(48, 209, 88, 0.5); }
  40% { transform: scale(1.06); box-shadow: 0 0 0 10px rgba(48, 209, 88, 0); }
  100% { transform: scale(1); }
}
@keyframes sheetRise {
  from { opacity: 0; transform: translateY(24px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes slideMenuItem {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .screen, .stack-screen, .holo-card, .feed-card, .tab-bar, .tab-btn,
  .modal-scrim, .modal-scrim .sheet, .toast, #discover-map, #discover-hub, #discover-world,
  .galaxy-node, .world-node, .world-node__fav, .nav-overlay__item, .progress-fill::after {
    transition: none !important;
    animation: none !important;
  }
  .screen { opacity: 1; transform: none; visibility: visible; }
  .screen:not(.active) { opacity: 0; visibility: hidden; }
  .stack-screen:not(.open) { opacity: 0; visibility: hidden; transform: none; }
  .stack-screen.open { opacity: 1; visibility: visible; }
}
