/* ==========================================================================
   Motion — انیمیشن‌ها و حرکت‌های ظریف (همه با prefers-reduced-motion خاموش می‌شوند)
   برای حذف کامل: خط link همین فایل و script مربوط به motion.js را از index.html پاک کنید.
   ========================================================================== */
:root { --ease-out: cubic-bezier(.22, 1, .36, 1); --ease-spring: cubic-bezier(.34, 1.56, .64, 1); }

/* ---- ورود صفحه (فقط هنگام عوض شدن مسیر) ---- */
@keyframes mo-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
html.route-enter .page > * { animation: mo-rise .5s var(--ease-out) both; }
html.route-enter .page > *:nth-child(2) { animation-delay: .05s; }
html.route-enter .page > *:nth-child(3) { animation-delay: .1s; }
html.route-enter .page > *:nth-child(4) { animation-delay: .15s; }
html.route-enter .page > *:nth-child(n+5) { animation-delay: .2s; }
html.route-enter .grid > * { animation: mo-rise .45s var(--ease-out) both; }
html.route-enter .grid > *:nth-child(2) { animation-delay: .06s; }
html.route-enter .grid > *:nth-child(3) { animation-delay: .12s; }
html.route-enter .grid > *:nth-child(4) { animation-delay: .18s; }

/* ---- کلیک و هاور ---- */
.btn, .icon-btn, .nav-item, .tabs button, .seg button, .wp-chip, .stepper-btn, .select-trigger, .menu-item {
  transition: transform .18s var(--ease-out), background-color .18s, border-color .18s, box-shadow .2s, color .18s, opacity .18s;
}
.btn:active:not(:disabled), .icon-btn:active, .tabs button:active, .seg button:active, .wp-chip:active, .stepper-btn:active { transform: scale(.94); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(22, 115, 220, .35); }
.btn-primary:active:not(:disabled) { transform: scale(.96); box-shadow: none; }
.nav-item:hover { transform: translateX(-3px); }
.nav-item:active { transform: scale(.97); }
.icon-btn:hover { transform: translateY(-1px); }
.card.hover:hover, .wp-tcard:hover { transform: translateY(-3px); }
.wp-card:hover { transform: translateY(-2px); }
.wp-card:active, .wp-tcard:active { transform: scale(.98); }
table.tbl tbody tr { transition: background-color .15s; }
.stat { transition: transform .2s var(--ease-out), box-shadow .2s; }
.stat.clickable:hover { transform: translateY(-3px); }

/* ریپل کلیک (motion.js) */
.btn, .icon-btn, .tabs button, .seg button { position: relative; overflow: hidden; }
.mo-ripple { position: absolute; border-radius: 50%; pointer-events: none; background: currentColor; opacity: .22; transform: scale(0); animation: mo-ripple .6s var(--ease-out) forwards; }
@keyframes mo-ripple { to { transform: scale(1); opacity: 0; } }

/* ---- منو، مودال، توست ---- */
@keyframes mo-pop { from { opacity: 0; transform: translateY(-6px) scale(.96); } to { opacity: 1; transform: none; } }
.menu { animation: mo-pop .18s var(--ease-out); transform-origin: top right; }
.cmdk { animation: mo-pop .22s var(--ease-out); }
.modal { animation: modalIn .32s var(--ease-spring) forwards; }
.toast { animation: toastIn .35s var(--ease-spring); }
@keyframes mo-slide-in { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
.menu-item { animation: mo-slide-in .2s var(--ease-out) both; }
.menu-item:nth-child(2) { animation-delay: .02s; } .menu-item:nth-child(3) { animation-delay: .04s; }
.menu-item:nth-child(4) { animation-delay: .06s; } .menu-item:nth-child(n+5) { animation-delay: .08s; }

/* ---- نوار پیشرفت، سوییچ، چک‌باکس ---- */
html.route-enter .bar > i { animation: mo-grow .9s var(--ease-out) both; transform-origin: right; }
@keyframes mo-grow { from { transform: scaleX(0); } to { transform: none; } }
.switch .track::before { transition: transform .28s var(--ease-spring); }
input[type="checkbox"]:checked { animation: mo-check .28s var(--ease-spring); }
@keyframes mo-check { 0% { transform: scale(.7); } 100% { transform: none; } }

/* ---- زنگ اعلان ---- */
@keyframes mo-ring { 0%, 100% { transform: none; } 15% { transform: rotate(14deg); } 30% { transform: rotate(-12deg); } 45% { transform: rotate(8deg); } 60% { transform: rotate(-6deg); } }
.icon-btn:hover svg { animation: mo-ring .7s ease; }
@keyframes mo-pulse { 0% { box-shadow: 0 0 0 0 rgba(224, 70, 70, .55); } 100% { box-shadow: 0 0 0 9px rgba(224, 70, 70, 0); } }
.icon-btn .dot { animation: mo-pulse 2.2s infinite; }

/* ---- برنامه هفتگی ---- */
/* فقط هنگام ورود به صفحه؛ با هر جابه‌جایی کارت، برنامه دوباره ساخته می‌شود و نباید انیمیشن ورود تکرار شود */
html.route-enter .wp-card, html.route-enter .wp-tcard { animation: mo-rise .35s var(--ease-out) both; }
.wp-tcard.dragging { box-shadow: 0 14px 30px rgba(0, 0, 0, .3); }

/* ---- تغییر تم ---- */
html.theme-fade, html.theme-fade * { transition: background-color .45s ease, border-color .45s ease, color .3s ease, box-shadow .45s ease !important; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { clip-path: circle(0 at var(--tx, 50%) var(--ty, 0)); animation: mo-reveal .75s var(--ease-out) forwards; }
@keyframes mo-reveal { to { clip-path: circle(150vmax at var(--tx, 50%) var(--ty, 0)); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; transition-duration: .001ms !important; }
}
