/* ==========================================================================
   baair.solutions — scène stop-scroll de l'accueil
   Chargée uniquement sur la page d'accueil (voir functions.php).
   Spécification : design_handoff_baair_solutions/README.md §6
   ========================================================================== */

.baair-stage {
  /* 240vh et non 300 : bloquer le défilement sur deux écrans entiers est
     long. À 240vh la scène se joue en ~1,4 écran — l'effet reste, l'attente
     disparaît. Revenir à 300vh si l'on veut une lecture plus lente. */
  height: 240vh;
  position: relative;
  background: var(--paper);
}

.baair-stage__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.baair-stage__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 48px;
  width: 100%;
}

/* --------------------------------------------------------------------------
   Le carré violet et ses chiffres
   -------------------------------------------------------------------------- */

.baair-stage__cell {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 400px;
}

.baair-stage__square {
  background: var(--purple);
  /* Dimensions pilotées en JS : 4px de haut au départ, puis carré. */
  width: 4px;
  height: 4px;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  overflow: hidden;
  flex: 0 0 auto;
}

.baair-stage__lines {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.baair-stage__line {
  opacity: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.72);
  white-space: nowrap;
  display: flex;
  gap: 8px;
}

.baair-stage__line b {
  color: #FFFFFF;
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   Le portrait
   -------------------------------------------------------------------------- */

.baair-stage__portrait-cell {
  position: relative;
  display: flex;
  justify-content: center;
}

.baair-stage__portrait {
  position: relative;
  width: 100%;
  max-width: 460px;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  /* Le fond du portrait est blanc : sans filet, le cadre se fondait dans la
     page et l'image flottait sans limite. Le filet 1px est le langage du
     système. */
  border: 1px solid var(--rule);
  background: var(--paper);
  transform-origin: 50% 100%;
  will-change: transform;
}

/* Couche intérieure : la respiration, en CSS pur donc hors fil principal.
   Amplitude volontairement infime — on doit la sentir, pas la voir. */
.baair-stage__breathe {
  position: absolute;
  inset: 0;
  animation: baairBreathe 7.6s cubic-bezier(0.37, 0, 0.63, 1) infinite;
  will-change: transform;
}

@keyframes baairBreathe {
  0%, 100% { transform: scale(1) rotate(-0.28deg); }
  50%      { transform: scale(1.008) rotate(0.28deg); }
}

/* Les niveaux de gris ne sont pas garantis par la source : on les impose,
   et on remonte très légèrement le contraste pour tenir face au noir pur. */
.baair-stage__poster img,
.baair-stage__portrait video {
  filter: grayscale(1) contrast(1.05);
}

/* Le poster occupe le cadre ; la vidéo se superpose par-dessus.
   Quand la vidéo est masquée (petit écran, mouvement réduit), le poster
   reste visible — la scène ne se vide jamais. */
.baair-stage__poster,
.baair-stage__portrait video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.baair-stage__poster img,
.baair-stage__portrait video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* La vidéo est désormais encodée directement en 3/4, au format du cadre :
     le recadrage est fait à l'encodage, plus à l'affichage. Un décalage ici
     sortirait le sujet du champ. */
  object-position: 50% 50%;
  display: block;
}

.baair-stage__portrait video { z-index: 1; }
.baair-stage__ideas,
.baair-stage__play { z-index: 2; }

/* Repli de lecture — n'apparaît que si play() est refusé. */
.baair-stage__play {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  background: var(--ink);
  color: var(--paper);
  border: 0;
  padding: 10px 16px;
  cursor: pointer;
}

.baair-stage__play:hover { background: var(--purple); }
.baair-stage__play[hidden] { display: none; }

/* --------------------------------------------------------------------------
   Les idées qui s'échappent — animées en CSS pour survivre aux re-rendus
   -------------------------------------------------------------------------- */

.baair-stage__ideas {
  position: absolute;
  left: 44%;
  top: 8%;
  width: 0;
  height: 0;
  pointer-events: none;
}

.baair-stage__idea {
  position: absolute;
  background: var(--purple);
  opacity: 0;
  animation: baairIdeaRise 5.2s cubic-bezier(0.23, 1, 0.32, 1) infinite;
}

@keyframes baairIdeaRise {
  0%   { opacity: 0; transform: translate(0, 0) rotate(0deg) scale(0.5); }
  12%  { opacity: 1; }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), -230px) rotate(115deg) scale(1); }
}

.baair-stage__idea:nth-child(1) { width: 8px;  height: 8px;  --dx: -84px; animation-delay: 0s; }
.baair-stage__idea:nth-child(2) { width: 6px;  height: 6px;  --dx: -38px; animation-delay: 0.9s; }
.baair-stage__idea:nth-child(3) { width: 10px; height: 10px; --dx: 14px;  animation-delay: 1.8s; }
.baair-stage__idea:nth-child(4) { width: 7px;  height: 7px;  --dx: 62px;  animation-delay: 2.7s; }
.baair-stage__idea:nth-child(5) { width: 9px;  height: 9px;  --dx: -60px; animation-delay: 3.9s; }
.baair-stage__idea:nth-child(6) { width: 6px;  height: 6px;  --dx: 40px;  animation-delay: 5.3s; }

/* --------------------------------------------------------------------------
   Sous 900px : la scène se simplifie (carré au-dessus du portrait)
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .baair-stage { height: auto; }

  .baair-stage__sticky {
    position: static;
    height: auto;
    padding-block: 64px;
  }

  .baair-stage__grid {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  .baair-stage__cell {
    min-height: 0;
    justify-content: center;
  }

  /* Scène statique : le carré est formé, les chiffres sont lisibles. */
  .baair-stage__square {
    width: min(320px, 78vw) !important;
    height: min(320px, 78vw) !important;
  }

  .baair-stage__line { opacity: 1 !important; }

  .baair-stage__portrait {
    transform: none !important;
    max-width: 360px;
  }

  /* Pas de vidéo sur petit écran : le poster suffit. */
  .baair-stage__portrait video { display: none; }
  .baair-stage__breathe { animation: none; transform: none; }
  .baair-stage__ideas { display: none; }
}

/* --------------------------------------------------------------------------
   Mouvement réduit — la scène devient une image fixe qui garde son sens
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .baair-stage { height: auto; }

  .baair-stage__sticky {
    position: static;
    height: auto;
    padding-block: 80px;
  }

  .baair-stage__square {
    width: min(400px, 40vw) !important;
    height: min(400px, 40vw) !important;
  }

  .baair-stage__line { opacity: 1 !important; }

  .baair-stage__portrait { transform: none !important; }
  .baair-stage__breathe { animation: none; transform: none; }

  .baair-stage__idea { animation: none; opacity: 0; }
}
