/* =====================================================================
   Parallaxe MoonCloud — plans qui se chevauchent au défilement.

   Principe : la scène d'accueil reste épinglée pendant --hero-run, et
   chaque plan remonte à sa propre vitesse. Les plans proches rattrapent
   puis recouvrent les plans lointains : c'est le chevauchement.

   Latence : le mouvement est décrit en CSS et piloté par les
   scroll-driven animations (animation-timeline). Le navigateur les
   exécute sur le thread de composition, donc collées au défilement,
   même pendant l'inertie du trackpad. site.js ne touche jamais à ces
   transformations ; il ne prend le relais que si le navigateur ne
   connaît pas encore animation-timeline.
   ===================================================================== */

:root{
  --hero-h:100svh;      /* hauteur de la scène épinglée */
  --hero-run:90svh;     /* course de défilement pendant laquelle elle le reste */
  --px:0;               /* pointeur, écrit par site.js */
  --py:0;
}

/* ---------- Scène d'accueil ---------- */
.hero{
  position:relative;
  height:calc(var(--hero-h) + var(--hero-run));
  min-height:0;
  max-height:none;
  overflow:visible;
  isolation:auto;
}
.hero-stage{
  position:sticky;
  top:0;
  height:var(--hero-h);
  overflow:hidden;
  isolation:isolate;
}
.landscape{position:absolute;inset:0;z-index:-3;background:#050f1e}
.mobile-hero-static{display:none}

/* ---------- Les plans ----------
   --rise : course verticale, en svh, sur toute la durée d'épinglage
   --grow : agrandissement en fin de course (effet de travelling avant)
   --sway : amplitude du mouvement au pointeur                        */
.landscape .plane,
.fox-anchor{
  --rise:0;
  --grow:0;
  --sway:0;
  position:absolute;
  translate:calc(var(--px) * var(--sway) * 30px) calc(var(--py) * var(--sway) * 16px);
  backface-visibility:hidden;
  will-change:transform,translate;
}
.landscape .plane{
  left:-5%;top:-5%;width:110%;height:110%;max-width:none;
  object-fit:cover;object-position:62% 50%;
  transform-origin:50% 60%;
}
.landscape .plane-sky        {--rise:4 ;--grow:.04;--sway:.10}
.landscape .plane-ridge      {--rise:9 ;--grow:.05;--sway:.24}
.landscape .plane-forest-far {--rise:14;--grow:.07;--sway:.42;filter:brightness(.95)}
/* Les deux plans proches sont cadrés plus large : ils paraissent plus
   près et gardent de la matière sous le cadre pendant leur remontée. */
.landscape .plane-forest-near{
  --rise:21;--grow:.11;--sway:.66;
  left:-13%;top:1%;width:126%;height:126%;
  filter:brightness(.78);
}
.landscape .plane-rocks{
  --rise:26;--grow:.16;--sway:.92;
  left:-7%;top:-3%;width:114%;height:114%;
  transform-origin:50% 100%;
  filter:brightness(.84);
  -webkit-mask-image:linear-gradient(transparent 34%,#000 66%);
  mask-image:linear-gradient(transparent 34%,#000 66%);
}
.fox-anchor{
  --rise:24;--grow:.12;--sway:1.15;
  z-index:2;right:9%;bottom:17%;
  width:clamp(92px,8.4vw,132px);
  transform-origin:50% 100%;
}
/* Le voile bas suit la course des plans : il masque le bas du décor
   là où les plans les plus proches finissent leur remontée. */
.hero-shade{
  background:
    linear-gradient(0deg,#071323 0,#071323 12%,transparent 37%),
    linear-gradient(90deg,rgba(4,15,30,.94),rgba(4,15,30,.74) 32%,rgba(4,15,30,.22) 64%,rgba(4,15,30,.04));
}
.hero-fox{width:100%;filter:drop-shadow(0 10px 12px #0004)}

/* ---------- Plans des scènes illustrées ---------- */
.journey-plane,
.contact-plane{--rise:0;--grow:0;backface-visibility:hidden;will-change:transform}
.journey-forest{
  position:absolute;inset:-8%;width:116%;height:116%;max-width:none;
  object-fit:cover;object-position:64% 64%;
  filter:brightness(.86);
}
.journey-background{--rise:2 ;--grow:.03}
.journey-forest    {--rise:4 ;--grow:.05}
.journey-rocks     {--rise:6 ;--grow:.07}
.journey-runner    {--rise:9 ;--grow:.06}
.contact-plane     {--rise:4 ;--grow:.04}

/* ---------- Mouvements ---------- */
@keyframes mc-plane{
  to{transform:translate3d(0,calc(var(--rise) * -1svh),0) scale(calc(1 + var(--grow)))}
}
@keyframes mc-scene{
  from{transform:translate3d(0,calc(var(--rise) * 1svh),0) scale(calc(1 + var(--grow)))}
  to  {transform:translate3d(0,calc(var(--rise) * -1svh),0) scale(1)}
}
@keyframes mc-copy{
  0%,36%{transform:translate3d(0,0,0);opacity:1}
  100%  {transform:translate3d(0,-11svh,0);opacity:0}
}
@keyframes mc-fade{0%{opacity:1;visibility:visible}55%,100%{opacity:0;visibility:hidden}}

/* Moteur natif : tout se joue sur le thread de composition. */
@supports (animation-timeline:scroll()){
  .landscape .plane,
  .fox-anchor,
  .hero-content,
  .hero-bottom{
    animation-timeline:scroll(root block);
    animation-range:0 var(--hero-run);
    animation-fill-mode:both;
    animation-timing-function:linear;
    animation-duration:auto;
  }
  .landscape .plane,
  .fox-anchor{animation-name:mc-plane}
  .hero-content{animation-name:mc-copy}
  .hero-bottom{animation-name:mc-fade}
}
@supports (animation-timeline:view()){
  .journey-stage{view-timeline-name:--mc-journey;view-timeline-axis:block}
  .contact{view-timeline-name:--mc-contact;view-timeline-axis:block}
  .journey-plane,
  .contact-plane{
    animation:mc-scene linear both;
    animation-duration:auto;
    animation-range:cover 0% cover 100%;
  }
  .journey-plane{animation-timeline:--mc-journey}
  .contact-plane{animation-timeline:--mc-contact}
}

/* ---------- Adaptations ---------- */
@media(max-height:820px){
  .hero-content{padding-top:clamp(128px,16vh,180px);padding-bottom:120px}
}
@media(max-width:1100px){
  :root{--hero-run:78svh}
}
@media(max-width:760px){
  :root{--hero-run:0svh}
  .hero{height:var(--hero-h);min-height:780px;overflow:hidden;isolation:isolate}
  .hero-stage{position:relative;height:100%;min-height:780px}
  .landscape .plane,.fox-anchor{display:none}
  .mobile-hero-static{display:block;position:absolute;inset:0;width:100%;height:100%;max-width:none;object-fit:cover;object-position:63% center}
  .hero-content,.hero-bottom,.journey-plane,.contact-plane{
    animation:none!important;transform:none!important;translate:none!important;opacity:1!important;will-change:auto
  }
  .hero-shade{
    background:
      linear-gradient(0deg,#071323 0,#071323 9%,transparent 32%),
      linear-gradient(90deg,#061225f0,#06122599 62%,#06122566);
  }
}

/* ---------- Mouvement réduit ---------- */
@media(prefers-reduced-motion:reduce){
  .hero{height:var(--hero-h)}
  .hero-stage{position:relative}
  .landscape .plane,
  .fox-anchor,
  .hero-content,
  .hero-bottom,
  .journey-plane,
  .contact-plane{
    animation:none!important;
    transform:none!important;
    translate:none!important;
    opacity:1!important;
    will-change:auto;
  }
}
