/* Écran de chargement (voir src/boot.js et src/ui/loadingScreen.js).
   Chargé en premier : il doit s'afficher correctement même si les autres feuilles tardent. */

/* Pendant le chargement, rien d'autre n'est visible ni cliquable (accueil pas encore prêt). */
body.booting #gameContainer > :not(#loadingScreen) {
  visibility: hidden;
}

#loadingScreen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at center, #1a0b2e 0%, #000000 100%);
  color: #ffffff;
  font-family: "Orbitron", sans-serif;
  pointer-events: auto;
  transition: opacity 0.35s ease;
}

#loadingScreen[hidden] {
  display: none;
}

/* Fondu de sortie : ne bloque plus les clics dès que le jeu est prêt. */
#loadingScreen.loading-done {
  opacity: 0;
  pointer-events: none;
}

.loading-box {
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  overflow: visible;
}

.loading-logo {
  width: 96px;
  height: 96px;
  filter: drop-shadow(0 0 12px rgba(255, 42, 109, 0.6));
  animation: loading-pulse 1.2s ease-in-out infinite;
}

.loading-title {
  overflow: visible;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 6px;
  color: #00ffff;
  text-shadow:
    0 0 10px rgba(0, 255, 255, 0.7),
    2px 0 #ff2a6d;
}

.loading-track {
  width: 100%;
  height: 10px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(0, 255, 255, 0.35);
}

.loading-fill {
  width: 0;
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, #ff2a6d, #aa66ff, #00ffff);
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.6);
  transition: width 0.25s ease-out;
}

.loading-info {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.7);
}

#loadingPercent {
  flex-shrink: 0;
  white-space: nowrap;
}

.loading-retry {
  display: none;
  margin-top: 6px;
  padding: 12px 26px;
  border: 2px solid #00ffff;
  border-radius: 10px;
  background: rgba(0, 255, 255, 0.1);
  color: #00ffff;
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
}

/* Échec (réseau coupé, démarrage trop long) : barre rouge et bouton pour recharger. */
#loadingScreen.loading-failed .loading-fill {
  background: #ff3b30;
  box-shadow: none;
}

#loadingScreen.loading-failed .loading-logo {
  animation: none;
}

#loadingScreen.loading-failed .loading-retry {
  display: block;
}

#loadingScreen.loading-failed #loadingLabel {
  color: #ff2a6d;
}

@keyframes loading-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

@media (prefers-reduced-motion: reduce) {
  .loading-logo {
    animation: none;
  }
}
