/**
 * Foundation Implants — Animations & Kinetic Effects
 *
 * 14 animation classes, all opt-in via class names.
 * JS adds .fi-visible to trigger entrance animations.
 *
 * @package foundation-implants
 */

/* ========================================================
   1. Word-by-word text reveal
   ======================================================== */
.fi-word-reveal .fi-word {
  display: inline-block;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

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

/* Stagger delays (set via inline style or nth-child) */
.fi-word-reveal.fi-visible .fi-word:nth-child(1)  { transition-delay: 0s; }
.fi-word-reveal.fi-visible .fi-word:nth-child(2)  { transition-delay: 0.05s; }
.fi-word-reveal.fi-visible .fi-word:nth-child(3)  { transition-delay: 0.1s; }
.fi-word-reveal.fi-visible .fi-word:nth-child(4)  { transition-delay: 0.15s; }
.fi-word-reveal.fi-visible .fi-word:nth-child(5)  { transition-delay: 0.2s; }
.fi-word-reveal.fi-visible .fi-word:nth-child(6)  { transition-delay: 0.25s; }
.fi-word-reveal.fi-visible .fi-word:nth-child(7)  { transition-delay: 0.3s; }
.fi-word-reveal.fi-visible .fi-word:nth-child(8)  { transition-delay: 0.35s; }
.fi-word-reveal.fi-visible .fi-word:nth-child(9)  { transition-delay: 0.4s; }
.fi-word-reveal.fi-visible .fi-word:nth-child(10) { transition-delay: 0.45s; }
.fi-word-reveal.fi-visible .fi-word:nth-child(11) { transition-delay: 0.5s; }
.fi-word-reveal.fi-visible .fi-word:nth-child(12) { transition-delay: 0.55s; }

/* ========================================================
   2. Glassmorphic floating
   ======================================================== */
.fi-glassmorphic {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--fi-radius, 12px);
}

@keyframes fi-slide-in-right {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.fi-glassmorphic.fi-slide-in-right {
  animation: fi-slide-in-right 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* ========================================================
   3. Shimmer CTA
   ======================================================== */
.fi-shimmer {
  position: relative;
  overflow: hidden;
}

.fi-shimmer::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.2) 50%,
    transparent 100%
  );
  animation: fi-shimmer-sweep 3s ease-in-out infinite;
}

@keyframes fi-shimmer-sweep {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* ========================================================
   4. Magnetic hover
   ======================================================== */
.fi-magnetic {
  transition: transform var(--fi-transition, 0.4s ease),
              box-shadow var(--fi-transition, 0.4s ease),
              border-color var(--fi-transition, 0.4s ease);
}

.fi-magnetic:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 20px rgba(var(--sapphire-rgb, 90, 159, 212), 0.2);
}

/* ========================================================
   5. Scroll progress bar
   ======================================================== */
.fi-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 9999;
  background: transparent;
  pointer-events: none;
}

.fi-progress-bar .fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(
    90deg,
    var(--sapphire, #5a9fd4),
    var(--sky, #82bde8)
  );
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.1s linear;
  will-change: transform;
}

/* ========================================================
   6. Infinite marquee
   ======================================================== */
.fi-marquee {
  overflow: hidden;
  white-space: nowrap;
}

.fi-marquee-track {
  display: inline-flex;
  animation: fi-marquee 20s linear infinite;
  will-change: transform;
}

.fi-marquee:hover .fi-marquee-track {
  animation-play-state: paused;
}

@keyframes fi-marquee {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

/* ========================================================
   7. Cards from alternating sides
   ======================================================== */
.fi-slide-left {
  opacity: 0;
  transform: translateX(-40px);
  transition: opacity 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.fi-slide-left.fi-visible {
  opacity: 1;
  transform: translateX(0);
}

.fi-slide-right {
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.fi-slide-right.fi-visible {
  opacity: 1;
  transform: translateX(0);
}

/* ========================================================
   8. Animated sweep line
   ======================================================== */
.fi-sweep-line {
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--sapphire, #5a9fd4),
    transparent
  );
  transform: scaleX(0);
  transform-origin: left center;
  animation: fi-sweep 1.2s ease forwards;
}

@keyframes fi-sweep {
  0% {
    transform: scaleX(0);
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: scaleX(1);
    opacity: 1;
  }
}

/* ========================================================
   9. Parallax
   ======================================================== */
.fi-parallax {
  /* will-change applied by JS when parallax is active */
}

/* ========================================================
   10. Animated counters — JS only (no CSS needed)
   ======================================================== */

/* ========================================================
   11. Card bottom-border grow
   ======================================================== */
.fi-border-grow {
  position: relative;
}

.fi-border-grow::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--sapphire, #5a9fd4);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--fi-transition, 0.4s ease);
}

.fi-border-grow:hover::before {
  transform: scaleX(1);
}

/* ========================================================
   12. Staggered fade-up
   ======================================================== */
.fi-fade-up {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

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

.fi-fade-up:nth-child(1) { transition-delay: 0s; }
.fi-fade-up:nth-child(2) { transition-delay: 0.1s; }
.fi-fade-up:nth-child(3) { transition-delay: 0.2s; }
.fi-fade-up:nth-child(4) { transition-delay: 0.3s; }
.fi-fade-up:nth-child(5) { transition-delay: 0.4s; }
.fi-fade-up:nth-child(6) { transition-delay: 0.5s; }

/* ========================================================
   13. Bidirectional scroll
   ======================================================== */
/* Uses the same slide/fade classes above.
   .fi-bidirectional signals JS to remove .fi-visible on exit. */
.fi-bidirectional {
  /* marker class — no additional CSS needed */
}

/* ========================================================
   14. Card glow on hover
   ======================================================== */
.fi-card-glow {
  transition: border-color var(--fi-transition, 0.4s ease),
              box-shadow var(--fi-transition, 0.4s ease);
}

.fi-card-glow:hover {
  border-color: rgba(var(--sapphire-rgb, 90, 159, 212), 0.3);
  box-shadow: 0 8px 32px rgba(var(--sapphire-rgb, 90, 159, 212), 0.1);
}

/* ========================================================
   Reduced motion
   ======================================================== */
@media (prefers-reduced-motion: reduce) {
  /* Kill transitions */
  .fi-word-reveal .fi-word,
  .fi-slide-left,
  .fi-slide-right,
  .fi-fade-up,
  .fi-magnetic,
  .fi-border-grow::before,
  .fi-card-glow {
    transition-duration: 0.01s !important;
  }

  /* Kill animations */
  .fi-shimmer::after,
  .fi-marquee-track,
  .fi-sweep-line,
  .fi-glassmorphic.fi-slide-in-right {
    animation-duration: 0.01s !important;
    animation-iteration-count: 1 !important;
  }

  /* Remove transforms — keep opacity */
  .fi-word-reveal .fi-word,
  .fi-slide-left,
  .fi-slide-right,
  .fi-fade-up {
    transform: none !important;
  }

  .fi-magnetic:hover {
    transform: none !important;
  }

  /* Progress bar can keep its width transition */
  .fi-progress-bar .fill {
    transition-duration: 0.01s !important;
  }

  /* Marquee stops */
  .fi-marquee-track {
    animation: none !important;
  }
}
