/* Calm entrance motion for the dashboard (پیشخوان), courses (دوره‌ها) and chats (گفتگو), in the same
 * family as the check-email page: things rise a few pixels and fade in, one after another, once.
 *
 * It plays only while <html> has "as-enter", which motion.js sets for a moment when a person
 * arrives on one of these pages, never when a page refreshes its own data. Nothing moves in lite
 * mode or when the device asks for reduced motion. Final states are the normal look, so a missed
 * or cut animation leaves nothing behind.
 */

@keyframes as-enter-rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

@keyframes as-enter-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes as-enter-pop {
  from { opacity: 0; transform: scale(0.86); }
  to { opacity: 1; transform: none; }
}

@keyframes as-enter-fill {
  from { transform: scaleX(0); }
  to { transform: none; }
}

@media (prefers-reduced-motion: no-preference) {
  /* ---------- پیشخوان (student) ---------- */
  html.as-enter:not(.as-lite) .student-dashboard-banner {
    animation: as-enter-fade 0.5s ease-out both;
  }
  html.as-enter:not(.as-lite) .student-dashboard-avatar {
    animation: as-enter-pop 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) 0.08s both;
  }
  html.as-enter:not(.as-lite) .student-dashboard-header .student-dashboard-greeting-stack {
    animation: as-enter-rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) 0.12s both;
  }
  html.as-enter:not(.as-lite) .dashboard-quick-stat {
    animation: as-enter-rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) 0.18s both;
  }
  html.as-enter:not(.as-lite) .dashboard-quick-stat:nth-child(2) { animation-delay: 0.23s; }
  html.as-enter:not(.as-lite) .dashboard-quick-stat:nth-child(3) { animation-delay: 0.28s; }
  html.as-enter:not(.as-lite) .dashboard-quick-stat:nth-child(4) { animation-delay: 0.33s; }
  html.as-enter:not(.as-lite) .main-panel .dashboard-section {
    animation: as-enter-rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) 0.36s both;
  }

  /* ---------- پیشخوان (staff) ---------- */
  html.as-enter:not(.as-lite) .dashboard-hero {
    animation: as-enter-rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  }
  html.as-enter:not(.as-lite) .dashboard-stat-card {
    animation: as-enter-rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) 0.1s both;
  }
  html.as-enter:not(.as-lite) .dashboard-stat-card:nth-child(2) { animation-delay: 0.15s; }
  html.as-enter:not(.as-lite) .dashboard-stat-card:nth-child(3) { animation-delay: 0.2s; }
  html.as-enter:not(.as-lite) .dashboard-stat-card:nth-child(4) { animation-delay: 0.25s; }
  html.as-enter:not(.as-lite) .dashboard-stat-card:nth-child(n + 5) { animation-delay: 0.3s; }
  html.as-enter:not(.as-lite) .dashboard-main-grid {
    animation: as-enter-rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) 0.3s both;
  }

  /* ---------- دوره‌ها ---------- */
  html.as-enter:not(.as-lite) .student-course-grid > .student-course-card {
    animation: as-enter-rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) 0.05s both;
  }
  html.as-enter:not(.as-lite) .student-course-grid > .student-course-card:nth-child(2) { animation-delay: 0.1s; }
  html.as-enter:not(.as-lite) .student-course-grid > .student-course-card:nth-child(3) { animation-delay: 0.15s; }
  html.as-enter:not(.as-lite) .student-course-grid > .student-course-card:nth-child(4) { animation-delay: 0.2s; }
  html.as-enter:not(.as-lite) .student-course-grid > .student-course-card:nth-child(5) { animation-delay: 0.25s; }
  html.as-enter:not(.as-lite) .student-course-grid > .student-course-card:nth-child(n + 6) { animation-delay: 0.3s; }
  /* Progress bars fill from the reading-start side. */
  html.as-enter:not(.as-lite) .student-course-progress-track > span {
    transform-origin: left center;
    animation: as-enter-fill 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) 0.35s both;
  }
  html.as-enter:not(.as-lite)[dir="rtl"] .student-course-progress-track > span,
  html.as-enter:not(.as-lite) [dir="rtl"] .student-course-progress-track > span {
    transform-origin: right center;
  }

  /* ---------- گفتگو ---------- */
  html.as-enter:not(.as-lite) .admin-inbox-row {
    animation: as-enter-rise 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) 0.04s both;
  }
  html.as-enter:not(.as-lite) .admin-inbox-row:nth-child(2) { animation-delay: 0.08s; }
  html.as-enter:not(.as-lite) .admin-inbox-row:nth-child(3) { animation-delay: 0.12s; }
  html.as-enter:not(.as-lite) .admin-inbox-row:nth-child(4) { animation-delay: 0.16s; }
  html.as-enter:not(.as-lite) .admin-inbox-row:nth-child(5) { animation-delay: 0.2s; }
  html.as-enter:not(.as-lite) .admin-inbox-row:nth-child(6) { animation-delay: 0.24s; }
  html.as-enter:not(.as-lite) .admin-inbox-row:nth-child(7) { animation-delay: 0.28s; }
  html.as-enter:not(.as-lite) .admin-inbox-row:nth-child(n + 8) { animation-delay: 0.32s; }
}
