/*
 * ════════════════════════════════════════════════════════════════
 * AY-ANIMATIONS.CSS — Phase 3 : Animations
 * Armand Yomi Theme v2.5.2
 *
 * MODULE INDÉPENDANT — règles d'architecture :
 *   ✓ Chargé après ay-tokens.css et style.css
 *   ✓ Zéro couleur hardcodée — 100% var(--ay-*)
 *   ✓ prefers-reduced-motion respecté globalement
 *   ✓ GPU only : transform + opacity uniquement
 *   ✓ will-change appliqué uniquement sur les éléments actifs
 * ════════════════════════════════════════════════════════════════
 */

/* ════════════════════════════════════════════════════════════════
   A. KEYFRAMES CENTRALISÉS
   ════════════════════════════════════════════════════════════════ */

/* Fondu + montée */
@keyframes ay-fade-up {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Fondu + descente */
@keyframes ay-fade-down {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Fondu simple */
@keyframes ay-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Fondu + montée + blur (reveal premium) */
@keyframes ay-reveal {
  from {
    opacity: 0;
    transform: translateY(22px);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

/* Scale in */
@keyframes ay-scale-in {
  from { opacity: 0; transform: scale(.92); }
  to   { opacity: 1; transform: scale(1); }
}

/* Slide depuis la gauche */
@keyframes ay-slide-left {
  from { opacity: 0; transform: translateX(-32px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Slide depuis la droite */
@keyframes ay-slide-right {
  from { opacity: 0; transform: translateX(32px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Pulsation douce (badge, point live) */
@keyframes ay-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.08); opacity: .75; }
}

/* Clignotement point (status live) */
@keyframes ay-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: .2; }
}

/* Shimmer horizontal (boutons, cartes) */
@keyframes ay-shimmer {
  from { transform: translateX(-100%); }
  to   { transform: translateX(120%); }
}

/* Rotation (loader spinner) */
@keyframes ay-spin {
  to { transform: rotate(360deg); }
}

/* Remplissage barre loader */
@keyframes ay-loader-fill {
  from { width: 0; }
  to   { width: 100%; }
}

/* Flottement vertical (éléments décoratifs) */
@keyframes ay-float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

/* Gradient animé (fond hero) */
@keyframes ay-gradient-shift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Typing cursor */
@keyframes ay-cursor-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* CountUp — pas d'animation CSS, géré en JS */

/* ════════════════════════════════════════════════════════════════
   B. CLASSES REVEAL — améliorées avec blur
   Remplace les .reveal de style.css (chargé après = override)
   ════════════════════════════════════════════════════════════════ */
.reveal {
  opacity: 0;
  transform: translateY(22px);
  filter: blur(3px);
  transition:
    opacity    var(--ay-dur-slower) var(--ay-ease),
    transform  var(--ay-dur-slower) var(--ay-ease),
    filter     var(--ay-dur-slow)   var(--ay-ease);
  will-change: transform, opacity;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
  will-change: auto;
}

/* Délais stagger */
.reveal-d1 { transition-delay: 80ms; }
.reveal-d2 { transition-delay: 160ms; }
.reveal-d3 { transition-delay: 240ms; }
.reveal-d4 { transition-delay: 320ms; }

/* Variante slide gauche */
.reveal-left {
  opacity: 0;
  transform: translateX(-28px);
  transition: opacity var(--ay-dur-slower) var(--ay-ease),
              transform var(--ay-dur-slower) var(--ay-ease);
}
.reveal-left.visible { opacity: 1; transform: translateX(0); }

/* Variante slide droite */
.reveal-right {
  opacity: 0;
  transform: translateX(28px);
  transition: opacity var(--ay-dur-slower) var(--ay-ease),
              transform var(--ay-dur-slower) var(--ay-ease);
}
.reveal-right.visible { opacity: 1; transform: translateX(0); }

/* Variante scale */
.reveal-scale {
  opacity: 0;
  transform: scale(.94);
  transition: opacity var(--ay-dur-slow) var(--ay-ease),
              transform var(--ay-dur-slow) var(--ay-ease-spring);
}
.reveal-scale.visible { opacity: 1; transform: scale(1); }

/* ════════════════════════════════════════════════════════════════
   C. HERO — Entrée cinétique
   ════════════════════════════════════════════════════════════════ */

/* Lettres du titre hero — animées en stagger via JS */
.hero-letter {
  display: inline-block;
  opacity: 0;
  transform: translateY(40px) rotate(-2deg);
  transition:
    opacity   .5s var(--ay-ease),
    transform .5s var(--ay-ease-spring);
  will-change: transform, opacity;
}
.hero-letter.visible {
  opacity: 1;
  transform: translateY(0) rotate(0deg);
  will-change: auto;
}

/* Particle glow derrière le titre */
.hero-glow-particle {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, var(--ay-gold-glow) 0%, transparent 70%);
  pointer-events: none;
  animation: ay-pulse 4s var(--ay-ease) infinite;
  will-change: transform, opacity;
}

/* Cursor clignotant gold */
.hero-cursor {
  display: inline-block;
  width: 3px;
  height: 1em;
  background: var(--ay-gold);
  margin-left: 4px;
  vertical-align: middle;
  animation: ay-cursor-blink .9s step-end infinite;
}

/* Scroll hint arrow */
.hero-scroll-hint {
  animation: ay-float 2.5s var(--ay-ease) infinite;
}

/* ════════════════════════════════════════════════════════════════
   D. PORTFOLIO CARDS — Tilt 3D
   La transformation CSS est appliquée via JS (ay-tilt.js)
   Ces règles préparent le contexte GPU
   ════════════════════════════════════════════════════════════════ */
.project-card {
  transform-style: preserve-3d;
  transform: perspective(800px) rotateX(0deg) rotateY(0deg);
  transition: transform var(--ay-dur-base) var(--ay-ease),
              box-shadow var(--ay-dur-base) var(--ay-ease);
}
.project-card:hover { will-change: transform; }
.project-card:not(:hover) { will-change: auto; }

/* Reflet lumineux qui suit le curseur — positionné via JS */
.project-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    circle 120px at var(--mx, 50%) var(--my, 50%),
    rgba(var(--ay-rgb-fg), .08) 0%,
    transparent 60%
  );
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity var(--ay-dur-base) var(--ay-ease);
}
.project-card:hover::before { opacity: 1; }

/* ════════════════════════════════════════════════════════════════
   E. STATS COUNTUP — conteneur
   ════════════════════════════════════════════════════════════════ */
.stat-num[data-target] {
  display: inline-block;
  min-width: 2ch;
}

/* ════════════════════════════════════════════════════════════════
   F. CTA FLOTTANT CONTEXTUEL — Phase 4
   ════════════════════════════════════════════════════════════════ */
#ay-float-cta {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: var(--ay-z-overlay);
  opacity: 0;
  transform: translateY(16px) scale(.95);
  pointer-events: none;
  transition:
    opacity   var(--ay-dur-base) var(--ay-ease),
    transform var(--ay-dur-base) var(--ay-ease-spring);
  will-change: transform, opacity;
}
#ay-float-cta.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  will-change: auto;
}
#ay-float-cta .float-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: .75rem 1.5rem;
  border-radius: var(--ay-radius-pill);
  background: var(--ay-glass-tile-bg);
  backdrop-filter: blur(var(--ay-tile-blur)) saturate(var(--ay-tile-saturate));
  -webkit-backdrop-filter: blur(var(--ay-tile-blur)) saturate(var(--ay-tile-saturate));
  border: 1px solid var(--ay-glass-tile-border);
  box-shadow:
    var(--ay-shadow-md),
    inset 0 1px 0 var(--ay-glass-tile-shine),
    var(--ay-glow-gold);
  color: var(--ay-white);
  font-family: var(--ay-font-mono);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: var(--ay-tracking-mono);
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: transform var(--ay-dur-fast) var(--ay-ease),
              box-shadow var(--ay-dur-base) var(--ay-ease);
}
#ay-float-cta .float-btn:hover {
  transform: translateY(-2px);
  box-shadow:
    var(--ay-shadow-lg),
    inset 0 1px 0 var(--ay-glass-tile-shine),
    var(--ay-glow-gold);
}
#ay-float-cta .float-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ay-gold);
  animation: ay-pulse 2s var(--ay-ease) infinite;
  flex-shrink: 0;
}
/* Mobile : en bas centré, largeur auto */
@media (max-width: 640px) {
  #ay-float-cta {
    bottom: 80px; /* au-dessus du sticky mobile */
    right: 16px;
    left: 16px;
  }
  #ay-float-cta .float-btn { justify-content: center; width: 100%; }
}

/* ════════════════════════════════════════════════════════════════
   G. EXIT INTENT MODAL — Phase 4
   ════════════════════════════════════════════════════════════════ */
#ay-exit-modal {
  position: fixed;
  inset: 0;
  z-index: var(--ay-z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ay-dur-base) var(--ay-ease);
}
#ay-exit-modal.open {
  opacity: 1;
  pointer-events: auto;
}
#ay-exit-modal .modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--ay-overlay-md);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
#ay-exit-modal .modal-card {
  position: relative;
  z-index: 1;
  max-width: 480px;
  width: 100%;
  background: var(--ay-glass-tile-bg);
  backdrop-filter: blur(var(--ay-tile-blur)) saturate(var(--ay-tile-saturate));
  -webkit-backdrop-filter: blur(var(--ay-tile-blur)) saturate(var(--ay-tile-saturate));
  border: 1px solid var(--ay-glass-tile-border);
  border-radius: var(--ay-radius-lg);
  padding: 40px 36px;
  box-shadow:
    var(--ay-shadow-lg),
    inset 0 1px 0 var(--ay-glass-tile-shine);
  text-align: center;
  transform: scale(.96) translateY(12px);
  transition: transform var(--ay-dur-base) var(--ay-ease-spring);
}
#ay-exit-modal.open .modal-card {
  transform: scale(1) translateY(0);
}
#ay-exit-modal .modal-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(var(--ay-rgb-fg), .06);
  border: 1px solid var(--ay-border);
  color: var(--ay-muted);
  font-size: .9rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--ay-dur-fast) var(--ay-ease),
              color var(--ay-dur-fast) var(--ay-ease);
}
#ay-exit-modal .modal-close:hover { background: var(--ay-gold-dim); color: var(--ay-gold); }
#ay-exit-modal .modal-emoji { font-size: 2.5rem; margin-bottom: 12px; }
#ay-exit-modal .modal-title {
  font-family: var(--ay-font-display);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  color: var(--ay-white);
  margin-bottom: 10px;
  line-height: 1;
}
#ay-exit-modal .modal-title span { color: var(--ay-gold); }
#ay-exit-modal .modal-sub {
  font-size: .9rem;
  color: var(--ay-soft);
  line-height: 1.65;
  margin-bottom: 28px;
}
#ay-exit-modal .modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ════════════════════════════════════════════════════════════════
   H. READING TIME BADGE — Phase 4
   ════════════════════════════════════════════════════════════════ */
.ay-read-time {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--ay-font-mono);
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ay-muted);
  padding: 3px 10px;
  border-radius: var(--ay-radius-pill);
  border: 1px solid var(--ay-border);
  background: rgba(var(--ay-rgb-fg), .04);
}
.ay-read-time::before {
  content: '⏱';
  font-size: .7rem;
}

/* ════════════════════════════════════════════════════════════════
   I. TESTIMONIALS — Progress bar améliorée
   ════════════════════════════════════════════════════════════════ */
.testi-progress-bar {
  transition: width var(--ay-dur-slow) linear;
}

/* ════════════════════════════════════════════════════════════════
   J. LOADER BAR — animation correcte
   ════════════════════════════════════════════════════════════════ */
.loader-bar {
  animation: ay-loader-fill 1.4s var(--ay-ease) forwards;
}

/* ════════════════════════════════════════════════════════════════
   K. PREFERS-REDUCED-MOTION — désactiver toutes les animations
   ════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .reveal,
  .reveal-left,
  .reveal-right,
  .reveal-scale,
  .hero-letter,
  .hero-scroll-hint,
  .project-card,
  #ay-float-cta,
  #ay-exit-modal .modal-card {
    animation: none !important;
    transition: none !important;
    transform: none !important;
    filter: none !important;
    opacity: 1 !important;
  }

  .hero-cursor { animation: none; }
  .hero-glow-particle { animation: none; }
  .loader-bar { animation: none; width: 100%; }
  .testi-progress-bar { transition: none; }
}
