/* Hybrid Minds: Atmosphere - animated preview (index2.html only), 22 Oct 2026.

   Three moving things, all slow and small:
   1. the smiley globe floats like a hot-air balloon (with ATMOSPHERE on it);
   2. the balloons in the trees bob, each on its own rhythm;
   3. the clouds drift sideways and back.

   The scene is the background plate rebuilt as a stage: a base picture plus each
   balloon and cloud as its own transparent piece, positioned in % of the stage. The
   stage is sized like `background-size: cover`, anchored like the .bg it sits on
   (desktop: centre bottom, mobile: centre top), so pieces land on the pixel.

   COVER RULE: every motion keeps each piece at least as large as its original outline
   (scale grows by more than twice the shift). Several desktop pieces are cut straight
   from the client's flat plate, which still has them painted in underneath; this rule
   is what stops that copy ever peeking out. Keep it if you change the numbers:
   (scale - 1) / 2 must be >= the translate, in the same axis. */

/* ---------- the scene ---------- */
.scene {
  position: fixed;
  inset: 0;
  z-index: -1;               /* same layer as .bg, later in the DOM, so on top of it */
  overflow: hidden;
  pointer-events: none;
  container-type: size;      /* cqw/cqh = the scene's own box, not guessed vh */
}
.scene__stage {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  opacity: 0;                /* anim.js adds .is-ready once every piece has loaded */
  transition: opacity .7s ease;
}
.scene__stage.is-ready { opacity: 1; }
/* portrait: cover, anchored top (as .bg's mobile crop) */
.scene__stage--mob {
  display: block;
  top: 0;
  width: max(100cqw, calc(100cqh * 1080 / 1920));
  aspect-ratio: 1080 / 1920;
}
/* landscape/square: cover, anchored bottom (as .bg's desktop crop); same 1/1
   switch as style.css */
@media (min-aspect-ratio: 1/1) {
  .scene__stage--mob { display: none; }
  .scene__stage--desk {
    display: block;
    bottom: 0;
    width: max(100cqw, calc(100cqh * 2560 / 1440));
    aspect-ratio: 2560 / 1440;
  }
}
.scene__base {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}
.pc {
  position: absolute;
  display: block;
  height: auto;
  max-width: none;
  transform-origin: 50% 50%;
  will-change: transform;
}

/* ---------- the globe: back layer of the split hero ---------- */
.hero--anim { position: relative; }
.hero--anim .hero__img { position: relative; z-index: 1; }
.hero__globe {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: auto;
  max-width: none;
  transform-origin: 50.2% 44.2%;   /* the globe's centre on the hero canvas */
}
/* landscape phones size the hero by height (style.css); keep the layers matched */
@media (min-width: 640px) and (min-aspect-ratio: 7/10) and (max-height: 520px) {
  .hero__globe { width: 100%; height: auto; }
}

@media (prefers-reduced-motion: no-preference) {
  .pc--b { animation: hm-bob var(--d, 8s) ease-in-out var(--dl, 0s) infinite; }
  .pc--c { animation: hm-drift var(--d, 24s) ease-in-out var(--dl, 0s) infinite; }
  /* same entrance as the front layer, then the float takes over */
  .hero__globe {
    animation:
      float-in 1.2s cubic-bezier(.22,1.3,.36,1) both,
      hm-globe 8s ease-in-out 1.2s infinite;
  }
}

/* balloon: rises while it swells; 4.5% growth covers a 2.2% rise */
@keyframes hm-bob {
  0%, 100% { transform: none; }
  50%      { transform: translateY(-2.2%) scale(1.045); }
}
/* cloud: drifts left or right (--dir) and back, stretching just enough to cover */
@keyframes hm-drift {
  0%, 100% { transform: none; }
  50%      { transform: translateX(calc(var(--dir, 1) * 0.9%)) scale(1.02, 1.015); }
}
/* globe: a slow hot-air-balloon float with a gentle sway */
@keyframes hm-globe {
  0%, 100% { transform: none; }
  25%      { transform: translateY(-1.4%) rotate(-1.2deg); }
  50%      { transform: translateY(-2.2%) rotate(0deg); }
  75%      { transform: translateY(-1%) rotate(1.2deg); }
}
