/* =========================================================
   نظام الحركة المشترك (الصفحات العامة والبوابة)
   - [data-reveal]: ظهور تدريجي عند دخول العنصر للشاشة (fade / up / zoom / side)
   - [data-reveal-stagger]: يتتابع ظهور الأبناء
   - [data-count]: عدّاد رقمي متحرك
   - يحترم prefers-reduced-motion (تُلغى كل الحركة)
   ========================================================= */
:root {
    --mo-ease: cubic-bezier(.22, 1, .36, 1);
    --mo-dur: .7s;
    --mo-shift: 18px;
}

/* ---------- الظهور عند التمرير ---------- */
.mo-ready [data-reveal] {
    opacity: 0;
    transform: translate3d(0, var(--mo-shift), 0);
    transition: opacity var(--mo-dur) var(--mo-ease), transform var(--mo-dur) var(--mo-ease);
    transition-delay: var(--mo-delay, 0s);
    will-change: opacity, transform;
}
.mo-ready [data-reveal="fade"] { transform: none; }
.mo-ready [data-reveal="zoom"] { transform: scale(.94); }
.mo-ready [data-reveal="start"] { transform: translate3d(calc(var(--mo-shift) * var(--mo-dir, -1)), 0, 0); }
.mo-ready [data-reveal="end"] { transform: translate3d(calc(var(--mo-shift) * var(--mo-dir, -1) * -1), 0, 0); }
[dir=rtl] { --mo-dir: 1; }
.mo-ready [data-reveal].mo-in { opacity: 1; transform: none; }

/* ---------- دخول الصفحة ---------- */
@keyframes mo-page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.mo-page { animation: mo-page-in .45s var(--mo-ease) backwards; }

/* ---------- تفاعل عام ---------- */
.btn { transition: transform .15s var(--mo-ease), box-shadow .2s, background-color .2s, border-color .2s, color .2s; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn-primary:hover { box-shadow: 0 8px 22px rgba(79, 70, 229, .3); }
.mo-lift { transition: transform .25s var(--mo-ease), box-shadow .25s var(--mo-ease), border-color .25s; }
.mo-lift:hover { transform: translateY(-4px); box-shadow: 0 16px 40px rgba(15, 23, 42, .12); }
.card { transition: box-shadow .25s var(--mo-ease), transform .25s var(--mo-ease); }
.side-link i, .dropdown-item i { transition: transform .2s var(--mo-ease); }
.side-link:hover i { transform: scale(1.12); }
.alert { animation: mo-page-in .4s var(--mo-ease) backwards; }
.dropdown-menu.show { animation: mo-drop .18s var(--mo-ease) backwards; }
@keyframes mo-drop { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- خلفية متحركة (البطل وصفحات الدخول) ---------- */
.mo-aurora { position: relative; isolation: isolate; overflow: hidden; }
.mo-aurora::before, .mo-aurora::after {
    content: ""; position: absolute; z-index: -1; border-radius: 50%; filter: blur(60px); opacity: .55; pointer-events: none;
}
.mo-aurora::before { width: 520px; height: 520px; background: #818cf8; top: -180px; inset-inline-end: -120px; animation: mo-float-a 16s ease-in-out infinite alternate; }
.mo-aurora::after { width: 460px; height: 460px; background: #f0abfc; bottom: -200px; inset-inline-start: -140px; animation: mo-float-b 19s ease-in-out infinite alternate; }
@keyframes mo-float-a { to { transform: translate(-60px, 80px) scale(1.15); } }
@keyframes mo-float-b { to { transform: translate(70px, -60px) scale(1.1); } }

/* أيقونات تطفو برفق */
.mo-float { animation: mo-bob 5s ease-in-out infinite; }
.mo-float:nth-child(2n) { animation-duration: 6.5s; animation-delay: -1.5s; }
.mo-float:nth-child(3n) { animation-duration: 7.5s; animation-delay: -3s; }
@keyframes mo-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* نص بتدرج لوني متحرك */
.mo-gradient-text {
    background: linear-gradient(90deg, #4f46e5, #a855f7, #ec4899, #4f46e5);
    background-size: 300% 100%;
    -webkit-background-clip: text; background-clip: text; color: transparent;
    animation: mo-shine 8s linear infinite;
}
@keyframes mo-shine { to { background-position: 300% 0; } }

/* ---------- تبويبات متحركة ---------- */
.mo-tabs { position: relative; display: flex; gap: .25rem; padding: .3rem; background: #fff; border: 1px solid var(--vg-line); border-radius: 14px; overflow-x: auto; scrollbar-width: none; }
.mo-tabs::-webkit-scrollbar { display: none; }
.mo-tab {
    position: relative; z-index: 1; display: inline-flex; align-items: center; gap: .45rem; white-space: nowrap;
    border: 0; background: transparent; color: var(--vg-muted); font-weight: 700; padding: .6rem 1rem; border-radius: 10px;
    transition: color .25s var(--mo-ease);
}
.mo-tab:hover { color: var(--vg-ink); }
.mo-tab[aria-selected=true] { color: #fff; }
.mo-tab .mo-tab-count { font-size: .72rem; background: rgba(15, 23, 42, .08); color: inherit; border-radius: 999px; padding: .05rem .45rem; transition: background .25s; }
.mo-tab[aria-selected=true] .mo-tab-count { background: rgba(255, 255, 255, .22); }
.mo-tab:focus-visible { outline: 2px solid #a5b4fc; outline-offset: 2px; }
.mo-tab-ink {
    position: absolute; z-index: 0; top: .3rem; bottom: .3rem; left: 0; width: 0; border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #4f46e5); box-shadow: 0 8px 20px rgba(79, 70, 229, .35);
    transition: transform .45s var(--mo-ease), width .45s var(--mo-ease);
}
.mo-panel { display: none; }
.mo-panel.active { display: block; animation: mo-panel-in .45s var(--mo-ease) backwards; }
@keyframes mo-panel-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- تقليل الحركة ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
    .mo-ready [data-reveal] { opacity: 1 !important; transform: none !important; }
}

/* ---------- البوابة: دخول متتابع بالـ CSS فقط (بلا وميض) ---------- */
@keyframes mo-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.app main.content > :not(.modal):not(.modal-backdrop):not(script),
.app main.content > .row > [class*="col"],
.app main.content > .kpi-grid > *,
.app main.content > .pkg-grid > *,
.app main.content > .char-grid > *,
.mo-panel.active .pkg-grid > * { animation: mo-rise .55s var(--mo-ease) backwards; }
.app main.content > :nth-child(2) { animation-delay: .05s; }
.app main.content > :nth-child(3) { animation-delay: .1s; }
.app main.content > :nth-child(4) { animation-delay: .15s; }
.app main.content > :nth-child(5) { animation-delay: .2s; }
.app main.content > :nth-child(n+6) { animation-delay: .25s; }
:is(.row, .kpi-grid, .pkg-grid, .char-grid) > :nth-child(2) { animation-delay: .08s; }
:is(.row, .kpi-grid, .pkg-grid, .char-grid) > :nth-child(3) { animation-delay: .14s; }
:is(.row, .kpi-grid, .pkg-grid, .char-grid) > :nth-child(4) { animation-delay: .2s; }
:is(.row, .kpi-grid, .pkg-grid, .char-grid) > :nth-child(5) { animation-delay: .26s; }
:is(.row, .kpi-grid, .pkg-grid, .char-grid) > :nth-child(n+6) { animation-delay: .32s; }
/* البطاقات القابلة للنقر في البوابة ترتفع عند المرور */
.char-card, .pkg-card, .kpi, .stat { transition: transform .25s var(--mo-ease), box-shadow .25s var(--mo-ease); }
.char-card:hover, .pkg-card:hover, .kpi:hover { transform: translateY(-4px); box-shadow: 0 16px 40px rgba(15, 23, 42, .12); }
