/**
 * سَرْد | SARD Studio — Interior Architecture & Haute Living
 * ملف الحركات المعمارية والانتقالات الانسيابية (Compositor Animations & Keyframes)
 */

/* ==========================================================================
   1. حركات التمرير الحديثة الأصلية (Scroll-Driven Animations)
   ========================================================================== */
@keyframes reveal-up {
  from {
    opacity: 0;
    transform: translateY(60px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes reveal-clip-right {
  from {
    clip-path: inset(0 0 0 100%);
  }
  to {
    clip-path: inset(0 0 0 0%);
  }
}

@keyframes reveal-clip-top {
  from {
    clip-path: inset(100% 0 0 0);
  }
  to {
    clip-path: inset(0 0 0 0%);
  }
}

@keyframes scale-in {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes rotate-in {
  from {
    opacity: 0;
    transform: translateY(30px) rotateX(15deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotateX(0);
  }
}

/* تفعيل الحركات المربوطة بالسكرول للمتصفحات الحديثة التي تدعم animation-timeline */
@supports (animation-timeline: view()) {
  .reveal {
    animation: reveal-up 800ms var(--ease-chromatic) both;
    animation-timeline: view();
    animation-range: entry 0% cover 35%;
  }

  .reveal-clip {
    animation: reveal-clip-right 900ms var(--ease-chromatic) both;
    animation-timeline: view();
    animation-range: entry 0% cover 35%;
  }

  .reveal-clip-top {
    animation: reveal-clip-top 900ms var(--ease-chromatic) both;
    animation-timeline: view();
    animation-range: entry 0% cover 35%;
  }

  .reveal-scale {
    animation: scale-in 800ms var(--ease-chromatic) both;
    animation-timeline: view();
    animation-range: entry 0% cover 30%;
  }

  .reveal-rotate {
    animation: rotate-in 800ms var(--ease-chromatic) both;
    animation-timeline: view();
    animation-range: entry 0% cover 35%;
  }
}

/* ==========================================================================
   2. البديل المعماري للمتصفحات (IntersectionObserver Fallback)
   ========================================================================== */
@supports not (animation-timeline: view()) {
  .reveal {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 800ms var(--ease-chromatic),
                transform 800ms var(--ease-chromatic);
  }

  .reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
  }

  .reveal-clip,
  .reveal-clip-top {
    clip-path: inset(0 0 0 100%);
    transition: clip-path 900ms var(--ease-chromatic);
  }

  .reveal-clip.is-visible,
  .reveal-clip-top.is-visible {
    clip-path: inset(0 0 0 0%);
  }

  .reveal-scale {
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 800ms var(--ease-chromatic),
                transform 800ms var(--ease-chromatic);
  }

  .reveal-scale.is-visible {
    opacity: 1;
    transform: scale(1);
  }

  .reveal-rotate {
    opacity: 0;
    transform: translateY(30px) rotateX(15deg);
    transition: opacity 800ms var(--ease-chromatic),
                transform 800ms var(--ease-chromatic);
  }

  .reveal-rotate.is-visible {
    opacity: 1;
    transform: translateY(0) rotateX(0);
  }
}

.js-reveal {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 800ms var(--ease-chromatic),
              transform 800ms var(--ease-chromatic);
}

.js-reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.js-reveal-clip {
  clip-path: inset(0 0 0 100%);
  transition: clip-path 900ms var(--ease-chromatic);
}

.js-reveal-clip.is-visible {
  clip-path: inset(0 0 0 0%);
}

.js-reveal-scale {
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 800ms var(--ease-chromatic),
              transform 800ms var(--ease-chromatic);
}

.js-reveal-scale.is-visible {
  opacity: 1;
  transform: scale(1);
}

.js-reveal-rotate {
  opacity: 0;
  transform: translateY(30px) rotateX(15deg);
  transition: opacity 800ms var(--ease-chromatic),
              transform 800ms var(--ease-chromatic);
}

.js-reveal-rotate.is-visible {
  opacity: 1;
  transform: translateY(0) rotateX(0);
}

/* ==========================================================================
   3. تحسين استهلاك المعالج الرسومي المحسوب (Calculated will-change)
   ========================================================================== */
.hero-visual img,
.chapter-number,
.cursor-halo,
.marquee-track {
  will-change: transform;
}

/* ==========================================================================
   4. هالة الفأرة وإلغاء الحركة عند تفضيل المستخدم (Prefers Reduced Motion)
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .cursor-halo {
    transition: none !important;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .reveal,
  .reveal-clip,
  .reveal-clip-top,
  .reveal-scale,
  .reveal-rotate,
  .js-reveal,
  .js-reveal-clip,
  .js-reveal-scale,
  .js-reveal-rotate {
    animation: none !important;
    clip-path: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .marquee-track {
    animation: none !important;
  }

  html {
    scroll-behavior: auto !important;
  }
}
