/* ============================================
   HUVA-TECH ANIMATIONS — Issue #24 (v2)
   Compatible avec la restructuration Issue #21
   ============================================ */

/* Respect système reduced-motion en priorité */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .reveal, .anim-fade-up,
  .hero-word, .particle,
  .gradient-line {
    opacity: 1 !important;
    transform: none !important;
  }
  .hero-particles,
  .process-timeline-line,
  .process-timeline::before {
    display: none !important;
  }
}

/* -------------------------------------------------
   1. Scroll-triggered reveals (compat Issue #21)
   ------------------------------------------------- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  will-change: transform, opacity;
  transition: opacity 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

/* Alternative class */
.anim-fade-up {
  opacity: 0;
  transform: translateY(30px);
  will-change: transform, opacity;
  transition: opacity 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

/* Stagger sur enfants */
.anim-stagger > .reveal:nth-child(1) { transition-delay: 0ms; }
.anim-stagger > .reveal:nth-child(2) { transition-delay: 90ms; }
.anim-stagger > .reveal:nth-child(3) { transition-delay: 180ms; }
.anim-stagger > .reveal:nth-child(4) { transition-delay: 270ms; }
.anim-stagger > .reveal:nth-child(5) { transition-delay: 360ms; }
.anim-stagger > .reveal:nth-child(6) { transition-delay: 450ms; }

.anim-stagger > .anim-fade-up:nth-child(1) { transition-delay: 0ms; }
.anim-stagger > .anim-fade-up:nth-child(2) { transition-delay: 90ms; }
.anim-stagger > .anim-fade-up:nth-child(3) { transition-delay: 180ms; }
.anim-stagger > .anim-fade-up:nth-child(4) { transition-delay: 270ms; }
.anim-stagger > .anim-fade-up:nth-child(5) { transition-delay: 360ms; }
.anim-stagger > .anim-fade-up:nth-child(6) { transition-delay: 450ms; }

/* -------------------------------------------------
   2. Hero
   ------------------------------------------------- */
.hero {
  position: relative;
}

/* Particules flottantes */
.hero-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.particle {
  position: absolute;
  bottom: -10px;
  width: 3px;
  height: 3px;
  background: rgba(99, 102, 241, 0.35);
  border-radius: 50%;
  opacity: 0;
  animation-name: floatParticle;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  will-change: transform, opacity;
}

@keyframes floatParticle {
  0%   { opacity: 0; transform: translateY(0) scale(0); }
  8%   { opacity: 1; transform: translateY(-30px) scale(1); }
  92%  { opacity: 1; transform: translateY(-280px) scale(1); }
  100% { opacity: 0; transform: translateY(-300px) scale(0); }
}

/* Titre mot par mot */
.hero-word {
  display: inline-block;
  opacity: 0;
  transform: translateY(110%);
  animation: wordReveal 0.65s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes wordReveal {
  to { opacity: 1; transform: translateY(0); }
}

/* Gradient shimmer */
.hero-shimmer {
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 25%, #6366f1 50%, #a855f7 75%, #6366f1 100%);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 5s ease infinite;
}

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

/* -------------------------------------------------
   3. Cards & éléments interactifs
   ------------------------------------------------- */
.card,
.stack-card,
.timeline-card,
.example-card,
.team-card {
  transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              box-shadow 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              border-color 0.3s ease;
  will-change: transform;
}

.card:hover,
.stack-card:hover,
.timeline-card:hover,
.example-card:hover,
.team-card:hover {
  transform: translateY(-8px);
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: 0 20px 50px rgba(99, 102, 241, 0.12),
              0 0 0 1px rgba(99, 102, 241, 0.15);
}

/* Icon morphing */
.card-icon,
.timeline-header h3::before,
.member-avatar {
  transition: transform 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

.card:hover .card-icon {
  transform: scale(1.2) rotate(-6deg);
}

/* -------------------------------------------------
   4. Process timeline
   ------------------------------------------------- */
.process-timeline {
  position: relative;
}

/* Ligne de fond */
.process-timeline::before {
  content: '';
  position: absolute;
  left: 24px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(99, 102, 241, 0.12);
  border-radius: 2px;
}

/* Ligne de remplissage scroll */
.process-timeline-line {
  position: absolute;
  left: 24px;
  top: 0;
  width: 2px;
  background: linear-gradient(180deg, #6366f1, #a855f7);
  border-radius: 2px;
  height: 0%;
  will-change: height;
  z-index: 1;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

/* Cards process avec offset timeline */
#process .services {
  position: relative;
}

#process .card {
  position: relative;
  padding-left: 48px;
}

#process .card::before {
  content: '';
  position: absolute;
  left: 18px;
  top: 40px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #0a0a0f;
  border: 2px solid rgba(99, 102, 241, 0.4);
  z-index: 2;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}

#process .card:hover::before {
  border-color: #6366f1;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
  transform: scale(1.15);
}

/* Numéros animés */
.process-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(168,85,247,0.1));
  border: 1px solid rgba(99,102,241,0.25);
  font-weight: 800;
  font-size: 18px;
  color: #fff;
  opacity: 0;
  transform: scale(0.4);
  will-change: transform, opacity;
}

.process-count.visible,
.process-count.is-visible {
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.1s,
              transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.1s;
}

/* Sur desktop, timeline centrée pour les grands écrans */
@media (min-width: 768px) {
  .process-timeline::before,
  .process-timeline-line {
    left: 50%;
    transform: translateX(-50%);
  }

  #process .card {
    padding-left: 32px;
    width: calc(50% - 32px);
  }

  #process .card::before {
    left: auto;
  }

  #process .services {
    display: flex;
    flex-direction: column;
    gap: 24px;
    align-items: center;
  }

  #process .card:nth-child(odd) {
    align-self: flex-start;
    text-align: left;
  }

  #process .card:nth-child(odd)::before {
    right: -39px;
  }

  #process .card:nth-child(even) {
    align-self: flex-end;
    text-align: left;
  }

  #process .card:nth-child(even)::before {
    left: -39px;
  }
}

@media (max-width: 767px) {
  .process-timeline::before,
  .process-timeline-line {
    left: 20px;
  }
  #process .card {
    padding-left: 44px;
  }
  #process .card::before {
    left: 14px;
  }
}

/* -------------------------------------------------
   5. Stack section
   ------------------------------------------------- */
.stack-grid {
  transition: opacity 0.3s ease;
}

.stack-grid:has(.stack-card:hover) .stack-card:not(:hover) {
  opacity: 0.3;
  filter: grayscale(0.9);
}

.stack-card {
  transition: opacity 0.3s ease, filter 0.3s ease, transform 0.35s ease, box-shadow 0.35s ease, border-color 0.3s ease;
}

.stack-card:hover {
  border-color: rgba(99, 102, 241, 0.4);
}

.stack-card .why {
  transition: opacity 0.3s ease;
}

.stack-card:hover .why {
  opacity: 1;
}

/* -------------------------------------------------
   6. Footer wave & CTA pulse
   ------------------------------------------------- */
.footer-wave {
  width: 100%;
  overflow: hidden;
  line-height: 0;
  margin-bottom: -1px;
}

.footer-wave svg {
  display: block;
  width: calc(100% + 2px);
  height: 60px;
}

.footer-wave .shape-fill {
  fill: rgba(255,255,255,0.025);
}

.footer-wave .wave-path {
  animation: waveBob 4s ease-in-out infinite alternate;
  transform-origin: center;
}

@keyframes waveBob {
  0%   { transform: translateX(0) scaleY(1); }
  100% { transform: translateX(-15px) scaleY(1.05); }
}

/* CTA pulse subtil */
.cta-pulse {
  animation: ctaPulse 3s ease-in-out infinite;
  will-change: transform;
}

@keyframes ctaPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.02); }
}

.cta-pulse:hover {
  animation: none;
  transform: translateY(-2px) scale(1.02);
}

/* -------------------------------------------------
   Gradient line reveal
   ------------------------------------------------- */
.gradient-line {
  opacity: 0;
  transform: scaleX(0);
  will-change: transform, opacity;
  transition: opacity 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.gradient-line.visible,
.gradient-line.is-visible {
  opacity: 1;
  transform: scaleX(1);
}

/* -------------------------------------------------
   Team hover
   ------------------------------------------------- */
.team-card {
  transition: transform 0.35s ease;
  will-change: transform;
}

.team-card:hover {
  transform: translateY(-6px);
}

.team-card:hover .member-avatar {
  transform: scale(1.08);
  box-shadow: 0 0 40px rgba(99, 102, 241, 0.25);
}

/* -------------------------------------------------
   FAQ cards slide-in
   ------------------------------------------------- */
#faq .card {
  transition: transform 0.35s ease,
              border-color 0.3s ease,
              box-shadow 0.35s ease;
  will-change: transform;
}

#faq .card:hover {
  transform: translateX(10px);
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: -6px 0 24px rgba(99, 102, 241, 0.07);
}

/* -------------------------------------------------
   Chat toggle heartbeat
   ------------------------------------------------- */
.chat-toggle {
  animation: chatHeartbeat 2.5s ease-in-out infinite;
}

@keyframes chatHeartbeat {
  0%, 100% { box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4); }
  50%      { box-shadow: 0 4px 30px rgba(99, 102, 241, 0.55), 0 0 0 8px rgba(99, 102, 241, 0.08); }
}
