/* =========================
   EC@RT — UNITY ZONES
   CSS unifié — toutes les zones Unity
   Charge après : zone-core.css, zone-sidebar.css

   Remplace : zone_02.css, zone-02-unity.css
   et leurs équivalents pour les zones 03, 08, etc.

   v1.2 — correctif reload tablette :
   - Suppression de height: 100dvh (déclenchait resize à chaque
     apparition/disparition de la barre nav iOS, causant pertes WebGL)
   - width/height retirés de .zone-content-unity (inset: 0 suffit
     quand position est fixed)
   ========================= */

/* =========================
   OVERRIDE BODY OVERFLOW
   Unity WebGL exige overflow: auto sur body.
   zone-core.css met overflow-x: hidden → on écrase ici.
   ========================= */

html {
  overflow: hidden;
}

html,
body {
  overflow: hidden !important;
  overscroll-behavior: none;
}

/* =========================
   ZONE UNITY — CONTENEUR PRINCIPAL

   Position toujours fixed, quelle que soit l'orientation.
   On évite ainsi le changement de stacking context au passage
   paysage ↔ portrait, qui provoquait une perte du contexte WebGL
   et un rechargement de la scène Unity sur iPad/iPhone.

   IMPORTANT : avec position: fixed + inset: 0, le bloc couvre déjà
   exactement le viewport. Les propriétés width/height sont retirées
   car 100vw / 100dvh y seraient redondantes — et 100dvh est
   dangereux : sa valeur change quand la barre de navigation iOS
   apparaît/disparaît, ce qui génère des événements resize parasites
   pouvant provoquer une perte de contexte WebGL.
   ========================= */

.zone-content-unity {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #000;
}

/* =========================
   UNITY CONTAINER & CANVAS
   Plein écran dans la zone content.
   Pas de padding, pas de frame.
   ========================= */

#unity-container {
  position: absolute;
  inset: 0;
  background: #000;
}

#unity-canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  background: #000;
  border: none;
  outline: none;
  touch-action: none;
}

/* =========================
   LOADER UNIFIÉ EC@RT
   Structure HTML attendue :

   <div class="ecart-unity-loader" id="ecartLoader">
     <img class="ecart-loader-bg" src="./xx-image.png" alt="" />
     <div class="ecart-loader-ui">
       <div class="ecart-loader-signal">
         <span></span><span></span><span></span>
       </div>
       <div class="ecart-loader-text">
         <div class="ecart-loader-title">EC@RT</div>
         <div class="ecart-loader-status" id="ecartLoaderStatus"></div>
         <div class="ecart-loader-bar-wrap">
           <div class="ecart-loader-bar" id="ecartLoaderBar"></div>
         </div>
         <div class="ecart-loader-percent" id="ecartLoaderPercent">0%</div>
       </div>
     </div>
   </div>
   <div class="ecart-unity-warning" id="ecartUnityWarning"></div>
   ========================= */

.ecart-unity-loader {
  position: absolute;
  inset: 0;
  z-index: 30;

  display: flex;
  align-items: center;
  justify-content: center;

  background: #000;
  overflow: hidden;

  opacity: 1;
  transition: opacity 0.85s ease, filter 0.85s ease;
}

.ecart-unity-loader.is-hidden {
  opacity: 0;
  pointer-events: none;
  filter: blur(14px);
}

/* Image de fond spécifique par zone — suffit de changer le src dans le HTML */
.ecart-loader-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  opacity: 0.76;
  filter: grayscale(1) brightness(0.62) contrast(1.08);
  transform: scale(1.05);
  animation: ecartBgBreath 12s ease-in-out infinite;
  pointer-events: none;
  user-select: none;
}

/* Voile par-dessus l'image */
.ecart-unity-loader::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(circle at center, rgba(0,0,0,0.16), rgba(0,0,0,0.70)),
    rgba(0,0,0,0.42);
  pointer-events: none;
}

/* =========================
   UI DU LOADER
   ========================= */

.ecart-loader-ui {
  position: relative;
  z-index: 2;

  display: flex;
  align-items: center;
  gap: clamp(18px, 3.2vw, 42px);

  width: min(520px, 76vw);
  padding: clamp(20px, 3.2vw, 40px);

  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(0, 0, 0, 0.30);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);

  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.035),
    0 0 52px rgba(255, 255, 255, 0.04);

  animation: ecartLoaderBreath 5s ease-in-out infinite;
}

/* =========================
   SIGNAL ANIMÉ
   ========================= */

.ecart-loader-signal {
  position: relative;
  flex-shrink: 0;
  width: clamp(52px, 7vw, 86px);
  height: clamp(52px, 7vw, 86px);
}

.ecart-loader-signal span {
  position: absolute;
  inset: 50%;
  width: 10px;
  height: 10px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  transform: translate(-50%, -50%);
  opacity: 0;
  animation: ecartSignalPulse 3.6s ease-out infinite;
}

.ecart-loader-signal span:nth-child(2) { animation-delay: 1.2s; }
.ecart-loader-signal span:nth-child(3) { animation-delay: 2.4s; }

.ecart-loader-signal::after {
  content: "";
  position: absolute;
  inset: 50%;
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.65);
  animation: ecartSignalCore 2.4s ease-in-out infinite;
}

/* =========================
   TEXTE
   ========================= */

.ecart-loader-text {
  flex: 1;
  min-width: 0;
}

.ecart-loader-title {
  font-size: clamp(15px, 1.9vw, 23px);
  letter-spacing: 0.2em;
  font-weight: 600;
  color: #fff;
  margin: 0 0 7px 0;
}

.ecart-loader-status {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.52);
  letter-spacing: 0.07em;
  line-height: 1.45;
  margin: 0 0 15px 0;
  min-height: 1.45em;
  transition: opacity 0.25s ease;
}

/* =========================
   BARRE DE PROGRESSION
   ========================= */

.ecart-loader-bar-wrap {
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}

.ecart-loader-bar {
  height: 100%;
  width: 0%;
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.55);
  transition: width 0.08s linear;
}

.ecart-loader-percent {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.32);
  letter-spacing: 0.12em;
}

/* =========================
   WARNING
   ========================= */

.ecart-unity-warning {
  position: absolute;
  bottom: 18px;
  left: 18px;
  right: 18px;
  z-index: 40;

  padding: 10px 14px;

  background: rgba(155, 18, 18, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.18);

  color: #fff;
  font-size: 12px;
  line-height: 1.45;
  letter-spacing: 0.03em;

  display: none;
}

.ecart-unity-warning.is-visible {
  display: block;
}

/* =========================
   RESPONSIVE LOADER
   ========================= */

@media (max-width: 780px) {
  .ecart-loader-ui {
    flex-direction: column;
    text-align: center;
    width: min(290px, 84vw);
    gap: 14px;
    padding: 22px 18px;
  }

  .ecart-loader-signal {
    width: 52px;
    height: 52px;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .ecart-loader-ui {
    padding: 14px 20px;
    gap: 14px;
  }

  .ecart-loader-signal {
    width: 42px;
    height: 42px;
  }

  .ecart-loader-title {
    font-size: 14px;
    margin-bottom: 4px;
  }
}

/* =========================
   ANIMATIONS
   ========================= */

@keyframes ecartBgBreath {
  0%, 100% { transform: scale(1.05); opacity: 0.76; }
  50%       { transform: scale(1.09); opacity: 0.82; }
}

@keyframes ecartLoaderBreath {
  0%, 100% {
    box-shadow:
      0 0 0 1px rgba(255,255,255,0.035),
      0 0 30px rgba(255,255,255,0.03);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(255,255,255,0.075),
      0 0 62px rgba(255,255,255,0.07);
  }
}

@keyframes ecartSignalPulse {
  0%   { width: 10px; height: 10px; opacity: 0.88; }
  100% { width: 100%; height: 100%; opacity: 0; }
}

@keyframes ecartSignalCore {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50%       { transform: translate(-50%, -50%) scale(1.38); }
}
