/* ==============================================================================
   عُمْرَان | UMRAN — Architectural Editorial
   css/animations.css: الحركات التحريرية الهادئة على المعالج الرسومي (Compositor)
   ============================================================================== */

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

@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 revealFadeUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes revealFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

@keyframes gentleFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* ------------------------------------------------------------------------------
   ب) حركات التمرير الحديثة (Scroll-Driven Animations - Chrome 115+)
   ------------------------------------------------------------------------------ */

@supports (animation-timeline: view()) {
  .reveal-from-right {
    animation: revealFromRight 900ms var(--ease-out-expo) both;
    animation-timeline: view();
    animation-range: entry 0% cover 35%;
  }

  .reveal-from-left {
    animation: revealFromLeft 900ms var(--ease-out-expo) both;
    animation-timeline: view();
    animation-range: entry 0% cover 35%;
  }

  .reveal-from-bottom {
    animation: revealFromBottom 900ms var(--ease-out-expo) both;
    animation-timeline: view();
    animation-range: entry 0% cover 35%;
  }

  .reveal-fade-up {
    animation: revealFadeUp 900ms var(--ease-out-expo) both;
    animation-timeline: view();
    animation-range: entry 0% cover 30%;
  }

  .reveal-fade-in {
    animation: revealFadeIn 900ms var(--ease-out-expo) both;
    animation-timeline: view();
    animation-range: entry 0% cover 30%;
  }
}

/* ------------------------------------------------------------------------------
   ج) البديل للمتصفحات الأخرى (Fallback via IntersectionObserver)
   ------------------------------------------------------------------------------ */

@supports not (animation-timeline: view()) {
  .reveal-from-right,
  .reveal-from-left,
  .reveal-from-bottom {
    clip-path: inset(0 0 0 100%);
    transition: clip-path 900ms var(--ease-out-expo);
  }

  .reveal-from-bottom {
    clip-path: inset(100% 0 0 0);
  }

  .reveal-from-left {
    clip-path: inset(0 100% 0 0);
  }

  .reveal-fade-up {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 900ms var(--ease-out-expo),
                transform 900ms var(--ease-out-expo);
  }

  .reveal-fade-in {
    opacity: 0;
    transition: opacity 900ms var(--ease-out-expo);
  }
  
  .reveal-from-right.is-visible,
  .reveal-from-left.is-visible,
  .reveal-from-bottom.is-visible {
    clip-path: inset(0 0 0 0);
  }

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

  .reveal-fade-in.is-visible {
    opacity: 1;
  }
}

/* ------------------------------------------------------------------------------
   د) تتابع ظهور الكلمات (Word-Split)
   ------------------------------------------------------------------------------ */

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

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

/* ------------------------------------------------------------------------------
   هـ) البارالاكس المعماري الهادئ للصور (Parallax)
   ------------------------------------------------------------------------------ */

.parallax-img {
  will-change: transform;
  transform: translateY(0);
}

.parallax-container {
  overflow: hidden;
}

.parallax-container img {
  transform: scale(1.08);
  /* هامش تكبير بسيط لمنع الفراغات أثناء حركة البارالاكس */
}

/* ------------------------------------------------------------------------------
   و) رسم الخطوط الحية للمخطط الزمني (Timeline SVG Drawing)
   ------------------------------------------------------------------------------ */

.timeline-svg-line {
  stroke-dasharray: 2000;
  stroke-dashoffset: 2000;
  stroke: var(--gold);
  stroke-width: 1;
  fill: none;
  stroke-linecap: round;
}

@supports (animation-timeline: view()) {
  .timeline-svg-line {
    animation: drawLine 1ms linear both;
    animation-timeline: view();
    animation-range: entry 0% cover 80%;
  }
}

@supports not (animation-timeline: view()) {
  .timeline-svg-line.is-visible {
    transition: stroke-dashoffset 1800ms var(--ease-out-expo);
    stroke-dashoffset: 0;
  }
}

/* ------------------------------------------------------------------------------
   ز) إدارة عتاد المعالجة (will-change Optimization)
   ------------------------------------------------------------------------------ */

.project-card-img,
.journal-card-media img,
.team-member img {
  will-change: transform;
}

.animations-ready .project-card-img,
.animations-ready .journal-card-media img,
.animations-ready .team-member img {
  will-change: auto;
}

/* ------------------------------------------------------------------------------
   ح) احترام تفضيلات تقليل الحركة (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-fade-up,
  .reveal-fade-in {
    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;
  }
  
  .parallax-container img {
    transform: none !important;
  }
  
  .timeline-svg-line {
    stroke-dashoffset: 0 !important;
    animation: none !important;
  }
  
  html {
    scroll-behavior: auto;
  }
}
