/* ANIMATIONS — New API Subtle Motion: cubic-bezier, no layout triggers, reduced-motion safe */

.page-wrapper {
  animation: page-enter 0.3s cubic-bezier(0.4, 0, 0.2, 1) both;
}
@keyframes page-enter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.stagger-enter {
  opacity: 0;
  transform: translateY(6px);
  animation: stagger-in 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  animation-delay: calc(var(--i, 0) * 40ms);
}
@keyframes stagger-in {
  to { opacity: 1; transform: translateY(0); }
}

.reveal {
  opacity: 0;
  transform: translateY(6px);
  animation: reveal-in 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes reveal-in {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.fade-in { animation: fade-in 0.2s cubic-bezier(0.4, 0, 0.2, 1) both; }

@keyframes fade-scale-in {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}
.fade-scale-in { animation: fade-scale-in 0.25s cubic-bezier(0.4, 0, 0.2, 1) both; }

@keyframes slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.slide-up { animation: slide-up 0.35s cubic-bezier(0.4, 0, 0.2, 1) both; }

@keyframes slide-down {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.slide-down { animation: slide-down 0.35s cubic-bezier(0.4, 0, 0.2, 1) both; }

@keyframes scale-in {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}
.scale-in { animation: scale-in 0.3s cubic-bezier(0.4, 0, 0.2, 1) both; }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; }
.spin-slow { animation: spin 1.5s linear infinite; }

.spinner-accent {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner-accent-sm { width: 14px; height: 14px; border-width: 1.5px; }
.spinner-accent-lg { width: 32px; height: 32px; border-width: 3px; }

/* ── Shake (form errors) ── */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80%       { transform: translateX(4px); }
}
.shake { animation: shake 0.5s ease; }

/* ── Toast notifications ── */
.toast-container {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: 0.5rem;
  pointer-events: none;
}
.toast-notification {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 0.7rem;
  padding: 0.75rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm); line-height: 1.5;
  min-width: 260px; max-width: 400px;
  transform: translateX(120%);
  animation: toast-in 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards,
             toast-out 0.4s ease-in 5s forwards;
  color: var(--foreground);
  box-shadow: var(--shadow-lg);
}
@keyframes toast-in { to { transform: translateX(0); } }
@keyframes toast-out { to { transform: translateX(120%); opacity: 0; } }
.toast-notification .toast-icon {
  width: 20px; height: 20px; min-width: 20px;
  border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 700; margin-top: 0.1rem;
  border: 1px solid var(--border);
}
@media (max-width: 575.98px) {
  .toast-container { left: 0.75rem; right: 0.75rem; bottom: 0.75rem; }
  .toast-notification { min-width: 0; max-width: 100%; }
}

/* ── Loading bar ── */
.load-loading::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  z-index: var(--z-toast);
  background: linear-gradient(90deg, color-mix(in srgb, var(--color-primary) 30%, transparent) 0%, var(--color-primary) 50%, color-mix(in srgb, var(--color-primary) 30%, transparent) 100%);
  background-size: 200% 100%;
  animation: load-bar 1.2s ease-in-out infinite;
}
@keyframes load-bar {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ── Loading → Reveal chain ── */
.load-reveal {
  opacity: 0;
  transform: translateY(6px);
  animation: load-reveal-in 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes load-reveal-in {
  to { opacity: 1; transform: translateY(0); }
}

/* ── Micro-interactions ── */
.hover-lift {
  transition: transform var(--transition-base);
}
.hover-lift:hover { transform: translateY(-1px); }

/* ── Gradient text (footer brand) ── */
.gradient-text {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .stagger-enter { opacity: 1; transform: none; animation: none; }
  .toast-notification { transform: none !important; animation: none !important; }
  .page-wrapper { animation: none !important; }
}

/* ── Alert pulse feedback ── */
@keyframes pulse-success {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 30%, transparent); }
  70%  { box-shadow: 0 0 0 8px color-mix(in srgb, var(--success) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 0%, transparent); }
}
@keyframes pulse-error {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 30%, transparent); }
  70%  { box-shadow: 0 0 0 8px color-mix(in srgb, var(--danger) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 0%, transparent); }
}
@keyframes pulse-warning {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--warning) 30%, transparent); }
  70%  { box-shadow: 0 0 0 8px color-mix(in srgb, var(--warning) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--warning) 0%, transparent); }
}
.pulse-success { animation: pulse-success 0.6s ease-out; }
.pulse-error   { animation: pulse-error 0.6s ease-out; }
.pulse-warning { animation: pulse-warning 0.6s ease-out; }
