/* ============================================================
   S7 Builders — Animations Stylesheet
   GPU-accelerated, accessible, CWV-friendly
   ============================================================ */

/* -----------------------------------------------------------
   1. KEYFRAME DEFINITIONS
   ----------------------------------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-24px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeLeft {
  from { opacity: 0; transform: translateX(32px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes fadeRight {
  from { opacity: 0; transform: translateX(-32px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.88); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.92) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-60px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(60px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes blur-in {
  from { opacity: 0; filter: blur(8px); transform: scale(0.97); }
  to   { opacity: 1; filter: blur(0); transform: scale(1); }
}

@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

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

@keyframes dash {
  to { stroke-dashoffset: 0; }
}

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

@keyframes rotate-slow {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes progress-in {
  from { transform: scaleX(0); transform-origin: left; }
  to   { transform: scaleX(1); transform-origin: left; }
}

@keyframes hero-text-reveal {
  from {
    opacity: 0;
    clip-path: inset(100% 0 0 0);
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    clip-path: inset(0% 0 0 0);
    transform: translateY(0);
  }
}

/* -----------------------------------------------------------
   2. SCROLL-TRIGGERED ANIMATION CLASSES
      JS adds .animate class when element enters viewport
   ----------------------------------------------------------- */

/* Initial hidden states */
.anim-fade-up,
.anim-fade-in,
.anim-fade-left,
.anim-fade-right,
.anim-scale-in,
.anim-slide-left,
.anim-slide-right,
.anim-blur-in {
  opacity: 0;
  will-change: opacity, transform;
  transition:
    opacity 0.7s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.anim-fade-up     { transform: translateY(40px); }
.anim-fade-down   { transform: translateY(-24px); opacity: 0; }
.anim-fade-in     { }
.anim-fade-left   { transform: translateX(40px); }
.anim-fade-right  { transform: translateX(-40px); }
.anim-scale-in    { transform: scale(0.88); }
.anim-slide-left  { transform: translateX(-60px); }
.anim-slide-right { transform: translateX(60px); }
.anim-blur-in     { filter: blur(8px); transform: scale(0.97); }

/* Animated states */
.anim-fade-up.animate,
.anim-fade-down.animate,
.anim-fade-in.animate,
.anim-fade-left.animate,
.anim-fade-right.animate,
.anim-scale-in.animate,
.anim-slide-left.animate,
.anim-slide-right.animate,
.anim-blur-in.animate {
  opacity: 1;
  transform: none;
  filter: none;
}

/* -----------------------------------------------------------
   3. STAGGERED CHILDREN
      Parent gets data-stagger, children get delays
   ----------------------------------------------------------- */
.stagger-children > * {
  opacity: 0;
  transform: translateY(32px);
  transition:
    opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.stagger-children.animate > *:nth-child(1)  { transition-delay: 0ms; }
.stagger-children.animate > *:nth-child(2)  { transition-delay: 80ms; }
.stagger-children.animate > *:nth-child(3)  { transition-delay: 160ms; }
.stagger-children.animate > *:nth-child(4)  { transition-delay: 240ms; }
.stagger-children.animate > *:nth-child(5)  { transition-delay: 320ms; }
.stagger-children.animate > *:nth-child(6)  { transition-delay: 400ms; }
.stagger-children.animate > *:nth-child(7)  { transition-delay: 480ms; }
.stagger-children.animate > *:nth-child(8)  { transition-delay: 560ms; }
.stagger-children.animate > *:nth-child(n+9) { transition-delay: 640ms; }

.stagger-children.animate > * {
  opacity: 1;
  transform: translateY(0);
}

/* -----------------------------------------------------------
   4. DELAY UTILITIES
   ----------------------------------------------------------- */
.delay-100 { transition-delay: 100ms !important; }
.delay-200 { transition-delay: 200ms !important; }
.delay-300 { transition-delay: 300ms !important; }
.delay-400 { transition-delay: 400ms !important; }
.delay-500 { transition-delay: 500ms !important; }
.delay-600 { transition-delay: 600ms !important; }
.delay-700 { transition-delay: 700ms !important; }
.delay-800 { transition-delay: 800ms !important; }

/* -----------------------------------------------------------
   5. HERO ANIMATIONS (run on page load)
   ----------------------------------------------------------- */
.hero-label {
  animation: fadeDown 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.2s both;
}

.hero-title {
  animation: fadeUp 0.9s cubic-bezier(0.4, 0, 0.2, 1) 0.4s both;
}

.hero-subtitle {
  animation: fadeUp 0.9s cubic-bezier(0.4, 0, 0.2, 1) 0.6s both;
}

.hero-actions {
  animation: fadeUp 0.9s cubic-bezier(0.4, 0, 0.2, 1) 0.8s both;
}

.hero-stats {
  animation: fadeUp 0.9s cubic-bezier(0.4, 0, 0.2, 1) 1.0s both;
}

/* -----------------------------------------------------------
   6. COUNTER ANIMATION
   ----------------------------------------------------------- */
.counter-value {
  transition: none;
}

.stat-item.animate .stat-number {
  animation: countUp 0.5s ease both;
}

/* -----------------------------------------------------------
   7. HOVER MICRO-INTERACTIONS
   ----------------------------------------------------------- */
/* Image zoom on card hover — handled in components.css */

/* Icon bounce on hover */
.icon-bounce:hover {
  animation: float 0.6s ease;
}

/* Gradient shimmer text */
.shimmer-text {
  background: linear-gradient(
    90deg,
    var(--c-blue) 0%,
    var(--c-green) 40%,
    var(--c-blue) 80%,
    var(--c-green) 100%
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 3s linear infinite;
}

/* -----------------------------------------------------------
   8. PAGE TRANSITION
   ----------------------------------------------------------- */
.page-transition {
  animation: fadeIn 0.4s ease;
}

/* -----------------------------------------------------------
   9. LOADING SPINNER
   ----------------------------------------------------------- */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--c-gray-200);
  border-top-color: var(--c-blue);
  border-radius: 50%;
  animation: rotate-slow 0.8s linear infinite;
}

/* -----------------------------------------------------------
   10. REVEAL LINE (section divider accent)
   ----------------------------------------------------------- */
.reveal-line {
  width: 0;
  height: 3px;
  background: var(--g-brand);
  border-radius: var(--r-full);
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1) 0.3s;
}

.reveal-line.animate {
  width: 60px;
}

/* -----------------------------------------------------------
   11. IMAGE REVEAL (wipe effect)
   ----------------------------------------------------------- */
.img-reveal {
  position: relative;
  overflow: hidden;
}

.img-reveal::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--c-blue);
  transform: translateX(0);
  transition: transform 0.8s cubic-bezier(0.77, 0, 0.175, 1);
}

.img-reveal.animate::after {
  transform: translateX(101%);
}

/* -----------------------------------------------------------
   12. FLOATING ELEMENTS
   ----------------------------------------------------------- */
.float-1 { animation: float 4s ease-in-out infinite; }
.float-2 { animation: float 5s ease-in-out infinite 0.5s; }
.float-3 { animation: float 6s ease-in-out infinite 1s; }

/* -----------------------------------------------------------
   13. REDUCED MOTION — ALWAYS LAST
      Override all animations for users who prefer no motion
   ----------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }

  .anim-fade-up,
  .anim-fade-in,
  .anim-fade-left,
  .anim-fade-right,
  .anim-scale-in,
  .anim-slide-left,
  .anim-slide-right,
  .anim-blur-in {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }

  .stagger-children > * {
    opacity: 1 !important;
    transform: none !important;
  }

  .hero-label,
  .hero-title,
  .hero-subtitle,
  .hero-actions,
  .hero-stats {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .reveal-line {
    width: 60px !important;
  }

  .img-reveal::after {
    transform: translateX(101%) !important;
  }
}
