/* ======================
   PREMIUM LOADING SCREEN
   ====================== */

/* Masquer tout le contenu pendant le loading */
body.loading-active {
  overflow: hidden;
}

body.loading-active > *:not(#premium-loader) {
  opacity: 0;
  transition: opacity 0.6s ease-out;
}

/* Désactiver les animations CSS du hero pendant le loading */
body.loading-active .animate-fade-in,
body.loading-active .animate-fade-in-delay,
body.loading-active .animate-fade-in-delay-2,
body.loading-active .text-line {
  animation: none !important;
  opacity: 0 !important;
}

/* Révéler le contenu en douceur après le loading */
body:not(.loading-active) > *:not(#premium-loader) {
  opacity: 1;
  transition: opacity 1.2s ease-out;
}

/* Loading overlay avec confettis */
#premium-loader {
  position: fixed;
  inset: 0;
  width: 100%;
  /* Fallback + moderne pour un centrage vertical fiable sur mobile */
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  /* Respect des zones sûres (notch) */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  opacity: 1;
  transition: opacity 1s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

/* Feux d'artifice élégants */
#premium-loader::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(circle at 20% 30%, rgba(23, 121, 170, 0.3) 2px, transparent 3px),
    radial-gradient(circle at 80% 25%, rgba(101, 180, 58, 0.28) 2px, transparent 3px),
    radial-gradient(circle at 35% 70%, rgba(23, 121, 170, 0.22) 2px, transparent 3px),
    radial-gradient(circle at 75% 80%, rgba(101, 180, 58, 0.24) 1px, transparent 2px),
    radial-gradient(circle at 15% 85%, rgba(23, 121, 170, 0.18) 1px, transparent 2px),
    radial-gradient(circle at 85% 55%, rgba(101, 180, 58, 0.2) 1px, transparent 2px);
  background-size: 200px 200px, 240px 240px, 170px 170px, 220px 220px, 160px 160px, 190px 190px;
  animation: fireworksFloat 10s ease-in-out infinite, fireworksConverge 1.5s ease-in 4.5s;
  pointer-events: none;
}

#premium-loader::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(circle at 45% 15%, rgba(23, 121, 170, 0.22) 2px, transparent 3px),
    radial-gradient(circle at 90% 45%, rgba(101, 180, 58, 0.2) 2px, transparent 3px),
    radial-gradient(circle at 25% 60%, rgba(101, 180, 58, 0.21) 1px, transparent 2px),
    radial-gradient(circle at 60% 90%, rgba(23, 121, 170, 0.19) 1px, transparent 2px);
  background-size: 280px 280px, 210px 210px, 250px 250px, 200px 200px;
  animation: fireworksFloat 13s ease-in-out infinite reverse, fireworksConverge 1.5s ease-in 4.5s;
  pointer-events: none;
}

@keyframes fireworksFloat {
  0%, 100% {
    transform: translateY(0) translateX(0) scale(1);
    opacity: 0.6;
  }
  30% {
    transform: translateY(-20px) translateX(12px) scale(1.08);
    opacity: 0.9;
  }
  70% {
    transform: translateY(-8px) translateX(-5px) scale(0.95);
    opacity: 0.7;
  }
}

/* Animation de convergence vers le logo - Aspiration */
@keyframes fireworksConverge {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 0.6;
  }
  50% {
    transform: translate(calc(50vw - 50%), calc(50vh - 50%)) scale(0.8);
    opacity: 1;
  }
  100% {
    transform: translate(calc(50vw - 50%), calc(50vh - 50%)) scale(0);
    opacity: 0;
  }
}

#premium-loader.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Container principal */
.loader-container {
  text-align: center;
  position: relative;
  z-index: 2;
}

/* Bouton skip discret */
.loader-skip {
  position: fixed;
  bottom: max(12px, env(safe-area-inset-bottom));
  right: max(12px, env(safe-area-inset-right));
  z-index: 100000; /* au-dessus de tout le contenu du loader */
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(6px);
  color: #0f172a;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.3s ease, transform 0.3s ease, background 0.2s ease;
}

.loader-skip.visible {
  opacity: 1;
  transform: translateY(0);
}

.loader-skip:hover {
  background: rgba(255, 255, 255, 0.85);
}

/* Logo iconique animé */
.loader-logo-icon {
  width: 180px;
  height: 180px;
  margin: 0 auto 1rem;
  opacity: 0;
  transform: scale(0.8);
  animation: logoIconReveal 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s forwards;
}

.loader-logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 12px 32px rgba(0, 0, 0, 0.12));
}

@keyframes logoIconReveal {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Logo container */
.loader-logo {
  font-family: 'Poppins', sans-serif;
  font-size: 6rem;
  font-weight: 800;
  margin-bottom: 1rem;
  position: relative;
  user-select: none;
  letter-spacing: -0.02em;
  animation: logoGlow 3s ease-in-out 2s infinite;
}

/* Effet de lueur élégant sur le logo */
@keyframes logoGlow {
  0%, 100% {
    filter: drop-shadow(0 0 0px rgba(23, 121, 170, 0));
  }
  50% {
    filter: drop-shadow(0 0 20px rgba(23, 121, 170, 0.3)) drop-shadow(0 0 40px rgba(101, 180, 58, 0.2));
  }
}

/* Lettres individuelles */
.loader-letter {
  display: inline-block;
  opacity: 0;
  transform: translateY(30px) scale(0.8);
  animation: letterReveal 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  position: relative;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  will-change: transform, opacity, filter;
}

/* Délais pour chaque lettre */
.loader-letter:nth-child(1) { animation-delay: 0.1s; }
.loader-letter:nth-child(2) { animation-delay: 0.2s; }
.loader-letter:nth-child(3) { animation-delay: 0.3s; } /* Re */
.loader-letter:nth-child(4) { animation-delay: 0.5s; }
.loader-letter:nth-child(5) { animation-delay: 0.6s; }
.loader-letter:nth-child(6) { animation-delay: 0.7s; }
.loader-letter:nth-child(7) { animation-delay: 0.8s; }
.loader-letter:nth-child(8) { animation-delay: 0.9s; } /* Fresh */
.loader-letter:nth-child(9) { animation-delay: 1.1s; }
.loader-letter:nth-child(10) { animation-delay: 1.2s; }
.loader-letter:nth-child(11) { animation-delay: 1.3s; } /* Web */

/* Couleurs spéc∫ifiques */
.loader-letter.re,
.loader-letter.web {
  color: #1779AA;
  text-shadow: 0 4px 16px rgba(23, 121, 170, 0.15);
}

.loader-letter.fresh {
  color: #65B43A;
  text-shadow: 0 4px 16px rgba(101, 180, 58, 0.15);
}

/* Animation de révélation des lettres - Simple et élégante */
@keyframes letterReveal {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.8);
    filter: blur(4px);
  }
  50% {
    opacity: 0.8;
    transform: translateY(5px) scale(1.02);
    filter: blur(1px);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0px);
  }
}

/* Effet de particules */
.loader-particles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.particle {
  position: absolute;
  width: 3px;
  height: 3px;
  background: #1779AA;
  border-radius: 50%;
  opacity: 0;
  animation: particleFloat 6s ease-in-out infinite;
}

.particle:nth-child(odd) {
  background: #65B43A;
}

@keyframes particleFloat {
  0% {
    opacity: 0;
    transform: translateY(100vh) translateX(0px);
  }
  20% {
    opacity: 0.6;
    transform: translateY(80vh) translateX(15px);
  }
  80% {
    opacity: 0.6;
    transform: translateY(20vh) translateX(-15px);
  }
  100% {
    opacity: 0;
    transform: translateY(0vh) translateX(0px);
  }
}

/* Tagline */
.loader-tagline {
  font-family: 'Poppins', sans-serif;
  font-size: 1.8rem;
  color: #475569;
  font-weight: 500;
  margin-top: 1rem;
  letter-spacing: 0.01em;
  text-align: center;
  line-height: 1.4;
  display: inline-block;
}

/* Animation des mots de la tagline */
.tagline-word {
  display: inline-block;
  opacity: 0;
  animation: taglineWordReveal 0.5s linear forwards;
}

/* Les délais sont maintenant définis directement dans le JS inline */

@keyframes taglineWordReveal {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* Barre de progression */
.loader-progress {
  width: 300px;
  height: 4px;
  background: rgba(100, 116, 139, 0.2);
  border-radius: 2px;
  margin: 2rem auto 0;
  position: relative;
  overflow: hidden;
}

.loader-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #1779AA 0%, #65B43A 100%);
  border-radius: 2px;
  width: 0%;
  animation: progressFill 5.5s cubic-bezier(0.4, 0, 0.2, 1) 0.5s forwards;
  position: relative;
}

.loader-progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.4) 50%, transparent 100%);
  animation: shimmer 1s ease-in-out infinite;
}

@keyframes progressFill {
  to {
    width: 100%;
  }
}

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

/* Animation de sortie - Fade élégant uniforme */
@keyframes loaderFadeOut {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.95);
  }
}

/* Responsive */
@media (max-width: 768px) {
  .loader-logo {
    font-size: 3.5rem;
    font-weight: 800;
  }
  
  .loader-progress {
    width: 280px;
  }
  
  .loader-tagline {
    font-size: 1.1rem;
    padding: 0 2rem;
    font-weight: 500;
  }
}

@media (max-width: 480px) {
  .loader-logo {
    font-size: 2.8rem;
  }
  
  .loader-tagline {
    font-size: 1rem;
  }
}

/* Plus d'effet de morphing */