/*
 * Écran d'accueil, affiché avant que l'application ne soit téléchargée.
 *
 * Il vit hors du bundle, parce qu'il doit peindre avant lui : le bundle et sa
 * feuille de style ne sont pas encore là, d'où des couleurs écrites ici en dur
 * — les mêmes que --color-bg-base et --color-accent de index.css, qu'il faut
 * garder alignées. theme-init.js pose la classe « dark » avant la première
 * peinture, si bien que le thème sombre n'éclaire jamais l'écran en blanc.
 *
 * React le retire en fondu quand l'application est prête (lib/splash.ts). Si
 * le JavaScript ne vient jamais — réseau coupé, bundle refusé — le délai de
 * sécurité en bas de fichier l'efface quand même : un écran d'attente figé
 * serait pire qu'une page qui se charge à vue.
 */

#splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: #f7f6f4;
  color: #1b3a5c;
  font-family: "DM Sans", system-ui, sans-serif;
  transition: opacity 280ms ease-out, visibility 0s linear 280ms;
  /* Filet de sécurité : jamais plus de douze secondes, même sans JavaScript. */
  animation: splash-timeout 280ms ease-out 12s forwards;
}

.dark #splash {
  background: #15171a;
  color: #e8eef6;
}

#splash.splash--leaving {
  opacity: 0;
  visibility: hidden;
}

.splash__mark {
  width: 64px;
  height: 64px;
  animation:
    splash-in 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both,
    splash-breathe 2.4s ease-in-out 520ms infinite;
}

.splash__name {
  font-size: 15px;
  letter-spacing: 0.02em;
  opacity: 0;
  animation: splash-fade 420ms ease-out 180ms forwards;
}

.splash__bar {
  position: relative;
  width: 120px;
  height: 2px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(27, 58, 92, 0.12);
  opacity: 0;
  animation: splash-fade 420ms ease-out 260ms forwards;
}

.dark .splash__bar {
  background: rgba(232, 238, 246, 0.14);
}

.splash__bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  border-radius: 2px;
  background: currentColor;
  animation: splash-slide 1.1s ease-in-out infinite;
}

@keyframes splash-in {
  from {
    opacity: 0;
    transform: scale(0.86);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes splash-breathe {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.045);
  }
}

@keyframes splash-fade {
  to {
    opacity: 1;
  }
}

@keyframes splash-slide {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(250%);
  }
}

@keyframes splash-timeout {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  #splash,
  .splash__mark,
  .splash__name,
  .splash__bar,
  .splash__bar::after {
    animation-duration: 1ms;
    animation-iteration-count: 1;
    animation-delay: 0ms;
  }
  #splash {
    transition: none;
    /* Le filet de sécurité garde son délai, sans animation. */
    animation: splash-timeout 1ms linear 12s forwards;
  }
}
