/*
 * Motion is intentionally brief and spatial: Windows appear from their center,
 * flyouts rise from the taskbar, and minimized windows collapse toward it.
 */

@keyframes window-open {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.965);
  }

  62% {
    opacity: 1;
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes window-close {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(6px) scale(0.975);
  }
}

@keyframes window-minimize {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(calc(50vh - var(--taskbar-height))) scale(0.58);
  }
}

@keyframes window-restore {
  0% {
    opacity: 0;
    transform: translateY(34px) scale(0.9);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes window-maximize {
  0% {
    opacity: 0.82;
    transform: scale(0.985);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes icon-launch {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  44% {
    transform: translateY(-4px) scale(1.04);
  }
}

@keyframes boot-spin {
  to {
    transform: rotate(1turn);
  }
}

@keyframes boot-dots {
  0% {
    transform: rotate(0deg);
    opacity: 1;
  }

  30% {
    transform: rotate(220deg);
  }

  40% {
    transform: rotate(450deg);
    opacity: 1;
  }

  75% {
    transform: rotate(720deg);
    opacity: 1;
  }

  76% {
    opacity: 0;
  }

  100% {
    transform: rotate(0deg);
    opacity: 0;
  }
}

@keyframes boot-logo-arrive {
  0% {
    opacity: 0;
    transform: perspective(560px) rotateY(-12deg) skewX(-4deg) scale(0.94);
  }

  100% {
    opacity: 1;
    transform: perspective(560px) rotateY(-12deg) skewX(-4deg) scale(1);
  }
}

@keyframes toast-in {
  0% {
    opacity: 0;
    transform: translate(18px, 10px) scale(0.98);
  }

  100% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translate(16px, 6px) scale(0.98);
  }
}

@keyframes soft-pulse {
  0%,
  100% {
    opacity: 0.54;
  }

  50% {
    opacity: 1;
  }
}

.app-window.is-opening {
  animation: window-open var(--duration-slow) var(--ease-emphasized) both;
}

.app-window.is-closing {
  animation: window-close var(--duration-medium) var(--ease-exit) both;
  pointer-events: none;
}

.app-window.is-minimizing {
  visibility: visible;
  animation: window-minimize var(--duration-slow) var(--ease-standard) both;
  pointer-events: none;
}

.app-window.is-restoring {
  visibility: visible;
  animation: window-restore var(--duration-slow) var(--ease-emphasized) both;
}

.app-window.is-maximizing {
  animation: window-maximize var(--duration-medium) var(--ease-standard) both;
}

.desktop-icon.is-launching .app-icon,
.start-app.is-launching .app-icon,
.taskbar-app.is-launching .app-icon {
  animation: icon-launch 260ms var(--ease-emphasized);
}

.boot-spinner__arm {
  animation: boot-dots 3.5s linear infinite;
}

.boot-spinner__arm:nth-child(1) {
  animation-delay: 0.9s;
}

.boot-spinner__arm:nth-child(2) {
  animation-delay: 1.05s;
}

.boot-spinner__arm:nth-child(3) {
  animation-delay: 1.2s;
}

.boot-spinner__arm:nth-child(4) {
  animation-delay: 1.35s;
}

.boot-spinner__arm:nth-child(5) {
  animation-delay: 1.5s;
}

.boot-brand__mark {
  animation: boot-logo-arrive 700ms var(--ease-emphasized) both;
}

.toast {
  animation: toast-in var(--duration-slow) var(--ease-emphasized) both;
}

.toast.is-leaving {
  animation: toast-out var(--duration-medium) var(--ease-exit) both;
}

.loading-pulse {
  animation: soft-pulse 1.4s ease-in-out infinite;
}

.desktop-shell.is-booting .desktop-surface,
.desktop-shell.is-booting .taskbar {
  opacity: 0;
}

.desktop-shell.is-ready .desktop-surface {
  animation: desktop-arrive 420ms var(--ease-standard) both;
}

.desktop-shell.is-ready .taskbar {
  animation: taskbar-arrive 360ms var(--ease-emphasized) both;
}

@keyframes desktop-arrive {
  from {
    opacity: 0;
    filter: saturate(65%);
    transform: scale(1.015);
  }

  to {
    opacity: 1;
    filter: saturate(100%);
    transform: scale(1);
  }
}

@keyframes taskbar-arrive {
  from {
    opacity: 0;
    transform: translateY(100%);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-delay: 0s !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-delay: 0s !important;
    transition-duration: 0.01ms !important;
  }
}

.desktop-shell[data-reduce-motion="true"] *,
.desktop-shell[data-reduce-motion="true"] *::before,
.desktop-shell[data-reduce-motion="true"] *::after {
  scroll-behavior: auto !important;
  animation-delay: 0s !important;
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-delay: 0s !important;
  transition-duration: 0.01ms !important;
}
