/* ==========================================================================
   animations.css — window lifecycle & misc motion
   All durations are driven by --dur-window / --dur-med set in base.css,
   and are scaled down automatically under reduced-motion.
   ========================================================================== */

.win {
  transition:
    transform var(--dur-window) var(--ease-out-back),
    opacity var(--dur-window) var(--ease-out),
    width var(--dur-med) var(--ease-in-out),
    height var(--dur-med) var(--ease-in-out),
    left var(--dur-med) var(--ease-in-out),
    top var(--dur-med) var(--ease-in-out),
    box-shadow var(--dur-fast) var(--ease-out);
}

/* While the user is actively dragging/resizing, kill the positional
   transition so movement tracks the pointer 1:1 with no lag. */
.win.interacting {
  transition: opacity var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

.win.state-opening {
  opacity: 0;
  transform: scale(0.55) translateY(40px);
}
.win.state-open {
  opacity: 1;
  transform: scale(1) translateY(0);
}
.win.state-closing {
  opacity: 0;
  transform: scale(0.5) translateY(30px);
}
.win.state-minimizing,
.win.state-minimized {
  opacity: 0;
  transform: scale(0.18) translateY(0);
  pointer-events: none;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 var(--accent-soft); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.dock-item.launching {
  animation: dock-bounce 520ms var(--ease-out-back);
}
@keyframes dock-bounce {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-14px) scale(1.08); }
  60% { transform: translateY(0) scale(0.97); }
  100% { transform: translateY(0) scale(1); }
}

.taskbar-app.launching {
  animation: taskbar-pop 320ms var(--ease-out-back);
}
@keyframes taskbar-pop {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Reduced motion: collapse everything to instant */
[data-reduce-motion="true"] .win,
[data-reduce-motion="true"] .dock-item,
[data-reduce-motion="true"] .taskbar-app {
  transition-duration: 1ms !important;
  animation-duration: 1ms !important;
}

/* ==========================================================================
   Exit transition — played by OS.pageTransition before navigating "_top" to
   an external link (data type: "external"). Skipped entirely under reduced
   motion (handled in JS), but the rules below also defend against it.
   ========================================================================== */

#desktop-root.desktop-leaving {
  transition:
    transform var(--dur-exit) var(--ease-in-out),
    filter var(--dur-exit) var(--ease-in-out),
    opacity var(--dur-exit) var(--ease-in-out);
  transform: scale(0.94);
  filter: blur(14px) saturate(1.3);
  opacity: 0.12;
}

#exit-transition {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, var(--accent-soft) 0%, var(--bg-0) 70%);
  transition: opacity var(--dur-exit) var(--ease-in-out);
}
#exit-transition.active {
  opacity: 1;
}

.exit-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  transform: scale(0.7) translateY(10px);
  opacity: 0;
  transition: transform var(--dur-exit) var(--ease-out-back), opacity var(--dur-exit) var(--ease-out);
}
#exit-transition.active .exit-badge {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.exit-badge-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  animation: exit-pulse 1.4s var(--ease-out) infinite;
}
@keyframes exit-pulse {
  0% { box-shadow: 0 0 0 0 var(--accent-soft); }
  70% { box-shadow: 0 0 0 22px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.exit-badge-text {
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.2px;
  opacity: 0.85;
}

[data-reduce-motion="true"] #desktop-root.desktop-leaving,
[data-reduce-motion="true"] #exit-transition,
[data-reduce-motion="true"] .exit-badge,
[data-reduce-motion="true"] .exit-badge-icon {
  transition-duration: 1ms !important;
  animation-duration: 1ms !important;
}
