/* ═══════════════════════════════════════════════════════════════
   ANIMATIONS & MOTION SYSTEM
   Cinematic Transitions & GSAP-compatibility
   ═══════════════════════════════════════════════════════════════ */

/* ── GSAP CONFLICT RESOLUTION ──
   When GSAP is active, we disable CSS transition animations on these elements
   so they don't fight GSAP's frame updates. */
body.gsap-active .reveal-item,
body.gsap-active .reveal-up,
body.gsap-active .reveal-left,
body.gsap-active .reveal-right,
body.gsap-active .reveal-scale,
body.gsap-active .reveal-clip,
body.gsap-active .bento-card,
body.gsap-active .expertise__item,
body.gsap-active .project-row,
body.gsap-active .company-card,
body.gsap-active .exp-item,
body.gsap-active .exp-item__content,
body.gsap-active .research__card,
body.gsap-active .stack__category,
body.gsap-active .contact__left,
body.gsap-active .contact__right,
body.gsap-active .footer__inner {
  transition: none !important;
}

/* ── CSS Fallbacks (Only active if GSAP is not running) ── */
body:not(.gsap-active) .reveal-up,
body:not(.gsap-active) .reveal-left,
body:not(.gsap-active) .reveal-right,
body:not(.gsap-active) .reveal-scale,
body:not(.gsap-active) .reveal-clip {
  opacity: 0;
  will-change: transform, opacity;
  transition: opacity 1s var(--ease-smooth),
              transform 1s var(--ease-smooth),
              clip-path 1.2s var(--ease-smooth);
}

body:not(.gsap-active) .reveal-up    { transform: translateY(60px); }
body:not(.gsap-active) .reveal-left  { transform: translateX(-60px); }
body:not(.gsap-active) .reveal-right { transform: translateX(60px); }
body:not(.gsap-active) .reveal-scale { transform: scale(0.95); }
body:not(.gsap-active) .reveal-clip  { clip-path: inset(100% 0 0 0); }

body:not(.gsap-active) .reveal-up.visible,
body:not(.gsap-active) .reveal-left.visible,
body:not(.gsap-active) .reveal-right.visible,
body:not(.gsap-active) .reveal-scale.visible,
body:not(.gsap-active) .reveal-clip.visible {
  opacity: 1;
  transform: translate(0, 0) scale(1);
  clip-path: inset(0 0 0 0);
}

/* Fallback stagger delays */
.delay-1 { transition-delay: 0.1s; }
.delay-2 { transition-delay: 0.2s; }
.delay-3 { transition-delay: 0.3s; }
.delay-4 { transition-delay: 0.4s; }

/* ── Hero Entrance Keyframes (CSS Native) ── */
@keyframes hero-rise {
  from { opacity: 0; transform: translateY(40px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes hero-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Hero fallbacks in case JS fails */
body:not(.gsap-active) .hero__content .reveal-item {
  animation: hero-rise 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
}
body:not(.gsap-active) .hero__content .reveal-item:nth-child(1) { animation-delay: 0.1s; }
body:not(.gsap-active) .hero__content .reveal-item:nth-child(2) { animation-delay: 0.3s; }
body:not(.gsap-active) .hero__content .reveal-item:nth-child(3) { animation-delay: 0.5s; }
body:not(.gsap-active) .hero__content .reveal-item:nth-child(4) { animation-delay: 0.7s; }

/* ── Roles Slider Track Animation ── */
@keyframes role-slide {
  0%, 15% { transform: translateY(0); }
  20%, 35% { transform: translateY(-1.5em); }
  40%, 55% { transform: translateY(-3em); }
  60%, 75% { transform: translateY(-4.5em); }
  80%, 95% { transform: translateY(-6em); }
  100% { transform: translateY(-7.5em); }
}

.hero__roles-track {
  animation: role-slide 10s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}

/* ── Horizontal Infinite Marquee ── */
@keyframes marquee {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.hero__domain-track {
  animation: marquee 40s linear infinite;
}

/* ── Floating Scroll Indicator ── */
@keyframes scroll-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

.hero__scroll-indicator {
  animation: scroll-float 2.5s ease-in-out infinite;
}

@keyframes scroll-line-drop {
  0% { transform: scaleY(0); transform-origin: top; opacity: 0; }
  40% { transform: scaleY(1); transform-origin: top; opacity: 1; }
  80% { transform: scaleY(1); transform-origin: bottom; opacity: 0; }
  100% { transform: scaleY(0); transform-origin: bottom; opacity: 0; }
}

.hero__scroll-line::after {
  content: '';
  display: block;
  width: 1px;
  height: 100%;
  background: var(--clr-accent);
  animation: scroll-line-drop 2s infinite ease-in-out;
}

/* ── Section Title Text Clip (CSS Only Fallback) ── */
@keyframes text-clip-reveal {
  from { clip-path: polygon(0 0, 0 0, 0 100%, 0 100%); }
  to { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); }
}

body:not(.gsap-active) .section-title.animate-in {
  animation: text-clip-reveal 1.2s var(--ease-smooth) forwards;
}

/* ── Interactive Card Hover Animations ── */
.hover-glow-card {
  transition: border-color var(--dur-base) var(--ease-smooth),
              transform var(--dur-base) var(--ease-smooth),
              box-shadow var(--dur-base) var(--ease-smooth);
}

.hover-glow-card:hover {
  transform: translateY(-5px);
}

/* Tilt & scale on project image */
/* Handled in style.css */

/* ── Navigation Link Underline ── */
/* Handled in style.css */

/* ── Scroll Progress Bar ── */
#scrollProgress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--clr-accent), #f1d5a3);
  z-index: 9999;
  width: 0%;
}

/* ── Custom Dual Pointer Follower ── */
#customCursorDot {
  width: 8px;
  height: 8px;
  background: var(--clr-accent);
  border-radius: 50%;
  position: fixed;
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 10000;
  opacity: 0;
  transition: width 0.2s var(--ease-smooth), height 0.2s var(--ease-smooth), background 0.2s, opacity 0.3s var(--ease-smooth);
  will-change: width, height, transform, opacity;
}

#customCursorRing {
  width: 40px;
  height: 40px;
  border: 1.5px solid rgba(223, 186, 115, 0.4);
  border-radius: 50%;
  position: fixed;
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transition: width 0.3s var(--ease-smooth), height 0.3s var(--ease-smooth), border-color 0.3s, background 0.3s, opacity 0.3s var(--ease-smooth);
  will-change: width, height, transform, opacity;
}

#customCursorDot.hover-active {
  width: 4px;
  height: 4px;
  background: #ffffff;
}

#customCursorRing.hover-active {
  width: 60px;
  height: 60px;
  border-color: rgba(223, 186, 115, 0.85);
  background: rgba(223, 186, 115, 0.05);
}

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

  .reveal-item,
  .reveal-up,
  .reveal-left,
  .reveal-right,
  .reveal-scale,
  .reveal-clip {
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
  }

  .hero__roles-track,
  .hero__domain-track,
  .hero__scroll-indicator,
  .hero__scroll-line::after {
    animation: none !important;
  }

  #customCursorDot,
  #customCursorRing {
    display: none !important;
  }
}
