/* ============================================================
   المُنظِّم | AL-MUNAZZIM — Motion System
   نظام حركة موحّد: انتقالات صفحات، دخول تدريجي، تفاعلات
   ============================================================ */

/* ---------- انتقال بين الصفحات ---------- */
.page-transition-enter {
  animation: pageEnter var(--duration-base) var(--ease-out-expo) forwards;
}

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

/* ---------- دخول تدريجي للعناصر (Staggered Reveal) ---------- */
.stagger-item {
  opacity: 0;
  animation: staggerIn var(--duration-base) var(--ease-out-expo) forwards;
}
.stagger-item:nth-child(1) { animation-delay: 0.03s; }
.stagger-item:nth-child(2) { animation-delay: 0.07s; }
.stagger-item:nth-child(3) { animation-delay: 0.11s; }
.stagger-item:nth-child(4) { animation-delay: 0.15s; }
.stagger-item:nth-child(5) { animation-delay: 0.19s; }
.stagger-item:nth-child(6) { animation-delay: 0.23s; }
.stagger-item:nth-child(7) { animation-delay: 0.27s; }
.stagger-item:nth-child(8) { animation-delay: 0.31s; }
.stagger-item:nth-child(9) { animation-delay: 0.35s; }
.stagger-item:nth-child(n+10) { animation-delay: 0.38s; }

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

/* ---------- ظهور توست ---------- */
.toast {
  animation: toastIn var(--duration-base) var(--ease-out-expo) forwards;
}
.toast.leaving {
  animation: toastOut var(--duration-fast) var(--ease-standard) forwards;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(8px) scale(0.95); }
}

/* ---------- ظهور نافذة سفلية (Sheet) ---------- */
.sheet-backdrop {
  animation: backdropIn var(--duration-base) var(--ease-standard) forwards;
}
@keyframes backdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.sheet {
  animation: sheetIn var(--duration-base) var(--ease-out-expo) forwards;
}
@keyframes sheetIn {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.sheet-backdrop.leaving {
  animation: backdropOut var(--duration-fast) var(--ease-standard) forwards;
}
@keyframes backdropOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
.sheet-backdrop.leaving .sheet {
  animation: sheetOut var(--duration-fast) var(--ease-standard) forwards;
}
@keyframes sheetOut {
  from { transform: translateY(0); }
  to { transform: translateY(100%); }
}

/* ---------- نبض خفيف للتأكيد (عند حفظ ناجح) ---------- */
.pulse-success {
  animation: pulseSuccess 0.5s var(--ease-out-expo);
}
@keyframes pulseSuccess {
  0% { transform: scale(1); }
  40% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

/* ---------- اهتزاز خفيف عند خطأ إدخال ---------- */
.shake-error {
  animation: shakeError 0.4s var(--ease-standard);
}
@keyframes shakeError {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ---------- ظهور حلقة الأوسمة (Badge Unlock) ---------- */
.badge-unlock-anim {
  animation: badgeUnlock 0.7s var(--ease-out-expo) forwards;
}
@keyframes badgeUnlock {
  0% { opacity: 0; transform: scale(0.3) rotate(-15deg); }
  60% { transform: scale(1.15) rotate(5deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

/* ---------- تبديل تدريجي بين تبويبات القسم ---------- */
.tab-content-switch {
  animation: tabSwitchIn var(--duration-fast) var(--ease-standard) forwards;
}
@keyframes tabSwitchIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .page-transition-enter,
  .stagger-item,
  .toast,
  .sheet-backdrop,
  .sheet,
  .pulse-success,
  .shake-error,
  .badge-unlock-anim,
  .tab-content-switch {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
