/* ==========================================================================
   رِواق | RIWAQ — css/animations.css
   منظومة الكشف التحريرية الهادئة: CSS Scroll-Driven مع البدائل المدعومة
   ========================================================================== */

/* --------------------------------------------------------------------------
   إطارات الحركة الأساسية (Keyframes Definition)
   -------------------------------------------------------------------------- */

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

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

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

@keyframes revealCircle {
  from {
    clip-path: circle(0% at 50% 50%);
  }
  to {
    clip-path: circle(75% at 50% 50%);
  }
}

@keyframes revealUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes drawLine {
  from {
    stroke-dashoffset: 2000;
  }
  to {
    stroke-dashoffset: 0;
  }
}

/* --------------------------------------------------------------------------
   الكشف المدفوع بالسكرول للمتصفحات الحديثة (Scroll-Driven Animations)
   -------------------------------------------------------------------------- */

@supports (animation-timeline: view()) {
  .reveal-from-right {
    animation: revealFromRight 800ms var(--ease-editorial) both;
    animation-timeline: view();
    animation-range: entry 0% cover 40%;
  }

  .reveal-from-left {
    animation: revealFromLeft 800ms var(--ease-editorial) both;
    animation-timeline: view();
    animation-range: entry 0% cover 40%;
  }

  .reveal-from-bottom {
    animation: revealFromBottom 800ms var(--ease-editorial) both;
    animation-timeline: view();
    animation-range: entry 0% cover 40%;
  }

  .reveal-circle {
    animation: revealCircle 1000ms var(--ease-editorial) both;
    animation-timeline: view();
    animation-range: entry 0% cover 45%;
  }

  .reveal-up {
    animation: revealUp 700ms var(--ease-editorial) both;
    animation-timeline: view();
    animation-range: entry 0% cover 35%;
  }

  .timeline-line-svg path,
  .timeline-line-svg line {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    animation: drawLine 1ms linear both;
    animation-timeline: view();
    animation-range: entry 0% cover 80%;
  }
}

/* --------------------------------------------------------------------------
   البديل المتوافق (Fallback via IntersectionObserver Classes)
   -------------------------------------------------------------------------- */

@supports not (animation-timeline: view()) {
  .reveal-from-right {
    clip-path: inset(0 0 0 100%);
    transition: clip-path 800ms var(--ease-editorial);
  }
  .reveal-from-right.is-visible {
    clip-path: inset(0 0 0 0);
  }

  .reveal-from-left {
    clip-path: inset(0 100% 0 0);
    transition: clip-path 800ms var(--ease-editorial);
  }
  .reveal-from-left.is-visible {
    clip-path: inset(0 0 0 0);
  }

  .reveal-from-bottom {
    clip-path: inset(100% 0 0 0);
    transition: clip-path 800ms var(--ease-editorial);
  }
  .reveal-from-bottom.is-visible {
    clip-path: inset(0 0 0 0);
  }

  .reveal-circle {
    clip-path: circle(0% at 50% 50%);
    transition: clip-path 1000ms var(--ease-editorial);
  }
  .reveal-circle.is-visible {
    clip-path: circle(75% at 50% 50%);
  }

  .reveal-up {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 700ms var(--ease-editorial),
                transform 700ms var(--ease-editorial);
  }
  .reveal-up.is-visible {
    opacity: 1;
    transform: none;
  }

  .timeline-line-svg path,
  .timeline-line-svg line {
    stroke-dasharray: none;
    stroke-dashoffset: 0;
  }
}

/* --------------------------------------------------------------------------
   كشف العناوين كلمة بكلمة (Word-Split Base Styles)
   -------------------------------------------------------------------------- */

.word-split > span {
  display: inline-block;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 600ms var(--ease-editorial),
              transform 600ms var(--ease-editorial);
  transition-delay: calc(var(--i, 0) * 0.06s);
}

.word-split.is-visible > span {
  opacity: 1;
  transform: translateY(0);
}

/* --------------------------------------------------------------------------
   رسم مسار الخط الزمني المعماري عبر SVG (process.html)
   -------------------------------------------------------------------------- */

.timeline-line-svg path,
.timeline-line-svg line {
  stroke: var(--accent-warm);
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
}

/* --------------------------------------------------------------------------
   تحسين الأداء عبر will-change (محسوب على عناصر محددة فقط)
   -------------------------------------------------------------------------- */

.hero-visual img,
.project-card-img {
  will-change: transform;
}

/* --------------------------------------------------------------------------
   الامتثال لتفضيل تقليل الحركة (prefers-reduced-motion)
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .reveal-from-right,
  .reveal-from-left,
  .reveal-from-bottom,
  .reveal-circle,
  .reveal-up {
    animation: none !important;
    clip-path: none !important;
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .word-split > span {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .footer-marquee-inner {
    animation: none !important;
  }

  html {
    scroll-behavior: auto;
  }
}
