/* ==========================================================
   CodeCaps — طبقة الحركة (Animations & Transitions)
   حسب الهوية: الحركة تعبّر عن تقدم أو تدفق أو اتصال، وليست للزينة.
   تتوقف تلقائياً عند تفعيل «تقليل الحركة» في جهاز الزائر.
   ========================================================== */
@media (prefers-reduced-motion: no-preference) {

    /* ---------- انتقال ناعم بين الصفحات (المتصفحات الداعمة) ---------- */
    @view-transition { navigation: auto; }
    ::view-transition-old(root) { animation: ccPageOut .16s var(--ease-brand, cubic-bezier(.2, .8, .2, 1)) both; }
    ::view-transition-new(root) { animation: ccPageIn .32s var(--ease-brand, cubic-bezier(.2, .8, .2, 1)) both; }

    /* ---------- دخول الواجهة الرئيسية ---------- */
    .hero-badge, .hero-title, .hero-desc, .hero-cta, .hero-stats-row {
        animation: ccRise .64s var(--ease-brand, cubic-bezier(.2, .8, .2, 1)) backwards;
    }
    .hero-badge { animation-delay: .05s; }
    .hero-title { animation-delay: .15s; }
    .hero-desc { animation-delay: .27s; }
    .hero-cta { animation-delay: .38s; }
    .hero-stats-row { animation-delay: .5s; }
    .hero-visual { animation: ccSlideSide .64s var(--ease-brand, cubic-bezier(.2, .8, .2, 1)) .32s backwards; }

    /* ---------- عنوان الصفحات الداخلية ---------- */
    .page-hero h1 { animation: ccRise .64s var(--ease-brand, cubic-bezier(.2, .8, .2, 1)) .05s backwards; }
    .page-hero p { animation: ccRise .64s var(--ease-brand, cubic-bezier(.2, .8, .2, 1)) .18s backwards; }

    /* ---------- الظهور عند التمرير ---------- */
    .cc-js [data-cc-reveal] {
        transition: opacity .64s var(--ease-brand, cubic-bezier(.2, .8, .2, 1)), transform .64s var(--ease-brand, cubic-bezier(.2, .8, .2, 1));
        transition-delay: var(--cc-delay, 0s);
    }
    .cc-js [data-cc-reveal]:not(.cc-in) { opacity: 0; transform: translateY(26px); }
    .cc-js [data-cc-reveal="zoom"]:not(.cc-in) { transform: scale(.96) translateY(14px); }
    .cc-js [data-cc-reveal="start"]:not(.cc-in) { transform: translateX(28px); }
    .cc-js [data-cc-reveal="end"]:not(.cc-in) { transform: translateX(-28px); }
    [dir="ltr"].cc-js [data-cc-reveal="start"]:not(.cc-in), .cc-js [dir="ltr"] [data-cc-reveal="start"]:not(.cc-in) { transform: translateX(-28px); }

    /* ---------- الأزرار ---------- */
    .btn:hover { transform: translateY(-2px); }
    .btn:active { transform: translateY(0) scale(.98); }
    .btn .cc-icon, .bento-link .cc-icon { transition: transform .32s ease; }
    .btn:hover .cc-icon-arrow-left, .bento-link:hover .cc-icon-arrow-left { transform: translateX(-4px); }
    .btn:hover .cc-icon-arrow-right, .bento-link:hover .cc-icon-arrow-right { transform: translateX(4px); }


    /* أرقام «لماذا نحن»: تغيّر اللون فقط عند المرور */
    .why-num { transition: color .32s var(--ease-brand, cubic-bezier(.2, .8, .2, 1)); }
    .why-card:hover .why-num { color: var(--color-primary-text); }

    /* ---------- أقواس الهوية: ترسم نفسها من مركزها مرة واحدة (Flow arc · Slow 640ms، مرة لكل صفحة) ---------- */
    .hero-grid::after, .reels-banner-grid::before, .reels-banner-grid::after {
        animation: ccArcDraw .64s var(--ease-brand, cubic-bezier(.2, .8, .2, 1)) .45s backwards;
    }
    .reels-banner-grid::after { animation-delay: .6s; }

    /* ---------- صندوق الكود: الأسطر تظهر بالتتابع 120ms بعد دخول الواجهة (Progress) ---------- */
    .terminal-content.cc-typing .cc-line {
        display: block;
        animation: ccLine .32s var(--ease-brand, cubic-bezier(.2, .8, .2, 1)) backwards;
        animation-delay: calc(.9s + var(--cc-i, 0) * 120ms);
    }

    /* ---------- شارة الواجهة: النقاط الثلاث تمتلئ بالتتابع (Dot flow = تقدم) ---------- */
    .hero-badge-dot { --cc-d: 1; animation: ccBadgeDots 3.2s var(--ease-brand, cubic-bezier(.2, .8, .2, 1)) 1s infinite; }
    [dir="rtl"] .hero-badge-dot { --cc-d: -1; }

    /* ---------- خط تحت الشريط: مؤشر الصفحة الحالية يظهر بالتمدد (اتصال/موضع) ---------- */
    .nav-link.active::after { animation: ccGrow .64s var(--ease-brand, cubic-bezier(.2, .8, .2, 1)) .25s backwards; }

    /* ---------- «لماذا نحن»: خط تقدم يمر على الخطوات 01→04 بتتابع 120ms ---------- */
    .cc-steps .why-card::after { transform: scaleX(0); transition: transform .64s var(--ease-brand, cubic-bezier(.2, .8, .2, 1)); transition-delay: calc(var(--cc-i, 0) * 120ms + 150ms); }
    .cc-steps.cc-steps-on .why-card::after { transform: scaleX(1); }

    /* ---------- الأرقام: مسار تقدم يمتلئ مع العدّاد (Progress track) ---------- */
    .cc-js .hero-stat-item h3::after { transform: scaleX(0); }
    .cc-js .hero-stat-item h3.cc-counted::after { transform: scaleX(1); transition: transform 1.4s cubic-bezier(.2, .8, .2, 1); }

    /* ---------- فلاتر الأعمال: كبسولة تنزلق للاختيار (Overlap capsule) ---------- */
    .portfolio-filters.has-pill { position: relative; isolation: isolate; }
    .cc-filter-pill {
        position: absolute;
        top: 0;
        left: 0;
        z-index: -1;
        border-radius: var(--radius-full);
        background: var(--color-primary);
        transition: transform .32s var(--ease-brand, cubic-bezier(.2, .8, .2, 1)), width .32s var(--ease-brand, cubic-bezier(.2, .8, .2, 1)), height .32s var(--ease-brand, cubic-bezier(.2, .8, .2, 1));
        pointer-events: none;
    }
    .portfolio-filters.has-pill .portfolio-filter { background: transparent; }
    .portfolio-filters.has-pill .portfolio-filter.active { border-color: transparent; }

    /* ---------- مؤشر تقدم القراءة في صفحة المقال (حركة = تقدم) ---------- */
    .cc-readbar {
        position: fixed;
        top: 0;
        inset-inline-start: 0;
        width: 100%;
        height: 3px;
        z-index: 450;
        pointer-events: none;
    }
    .cc-readbar i {
        display: block;
        height: 100%;
        background-color: var(--color-primary);
        transform: scaleX(var(--cc-read, 0));
        transform-origin: 100% 0;
    }
    [dir="ltr"] .cc-readbar i { transform-origin: 0 0; }

    /* ---------- الأعمال: ظهور عند الفلترة ---------- */
    .portfolio-card.cc-pop { animation: ccPop .32s var(--ease-brand, cubic-bezier(.2, .8, .2, 1)) backwards; animation-delay: var(--cc-delay, 0s); }
    .portfolio-filter { transition: all .32s ease; }
    .portfolio-filter:active { transform: scale(.95); }

    /* ---------- روابط القوائم وأيقونات التواصل ---------- */
    .footer-links-list a { display: inline-block; transition: transform .32s ease, color .32s ease; }
    .footer-links-list a:hover { transform: translateX(-4px); }
    [dir="ltr"] .footer-links-list a:hover { transform: translateX(4px); }
    .footer-socials a { transition: transform .32s var(--ease-brand, cubic-bezier(.2, .8, .2, 1)), background-color .32s ease, color .32s ease; }
    .footer-socials a:hover { transform: translateY(-4px); }

    /* ---------- حقول النماذج ---------- */
    .contact-form input, .contact-form textarea, .booking-form-inner input, .booking-form-inner textarea, .comment-form input, .comment-form textarea {
        transition: border-color .32s ease, box-shadow .32s ease, transform .32s ease;
    }
    .contact-form input:focus, .contact-form textarea:focus, .booking-form-inner input:focus, .booking-form-inner textarea:focus {
        transform: translateY(-1px);
    }
    .time-slot { transition: all .16s ease; }
    .time-slot:not(.disabled):hover { transform: translateY(-2px); }
}

/* ---------- عناصر ثابتة تظهر للجميع (وتتحرك فقط لمن يسمح بالحركة) ---------- */
.why-card { position: relative; }
.why-card::after {
    content: '';
    position: absolute;
    top: -1px;
    inset-inline: 20px;
    height: 2px;
    border-radius: 2px;
    background: var(--color-primary);
    transform-origin: right center;
}
[dir="ltr"] .why-card::after { transform-origin: left center; }
.hero-stat-item h3::after {
    content: '';
    display: block;
    width: 28px;
    height: 2px;
    margin-top: 6px;
    border-radius: 2px;
    background: var(--color-primary);
    transform-origin: right center;
}
[dir="ltr"] .hero-stat-item h3::after { transform-origin: left center; }
@media (max-width: 991px) { .hero-stat-item h3::after { margin-inline: auto; transform-origin: center; } }

@keyframes ccRise { from { opacity: 0; transform: translateY(28px); } to { opacity: 1; transform: none; } }
@keyframes ccSlideSide { from { opacity: 0; transform: translateX(-40px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes ccPop { from { opacity: 0; transform: translateY(18px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes ccArcDraw { from { clip-path: circle(0% at 100% 0); } to { clip-path: circle(142% at 100% 0); } }
@keyframes ccGrow { from { width: 0; } }
@keyframes ccLine { from { opacity: 0; transform: translateX(calc(var(--cc-dir, 1) * -8px)); } }
@keyframes ccBadgeDots {
    0%, 100% { background: #a4f4ca; box-shadow: calc(var(--cc-d) * 10px) 0 0 #a4f4ca, calc(var(--cc-d) * 20px) 0 0 #a4f4ca; }
    10%      { background: #01e16b; box-shadow: calc(var(--cc-d) * 10px) 0 0 #a4f4ca, calc(var(--cc-d) * 20px) 0 0 #a4f4ca; }
    20%      { background: #01e16b; box-shadow: calc(var(--cc-d) * 10px) 0 0 #01e16b, calc(var(--cc-d) * 20px) 0 0 #a4f4ca; }
    30%, 88% { background: #01e16b; box-shadow: calc(var(--cc-d) * 10px) 0 0 #01e16b, calc(var(--cc-d) * 20px) 0 0 #01e16b; }
}
@keyframes ccPageOut { to { opacity: 0; } }
@keyframes ccPageIn { from { opacity: 0; transform: translateY(8px); } }
