/* ==========================================================
   Hero cinematográfico · del caos a la calma
   Estado base = escena final (ordenada, cálida, con titular).
   Con movimiento, hero.js parte del desorden y lo resuelve
   con el scroll. Sin JS o con reduced-motion se ve la escena
   final, quieta.
   ========================================================== */

.hero {
  position: relative;
  height: 380vh;
  background: var(--madera-canto);
}
.sin-animacion .hero { height: auto; }

.escenario {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: linear-gradient(180deg, #F6F1E9 0%, #F3EDE3 55%, #EFE7DB 100%);
  contain: layout paint;
}

.escenario > * { position: absolute; }

/* Mientras arranca la animación, la escena espera en blanco
   cálido y luego entra despacio (nunca de golpe). */
.preparando .escenario > :not(.pared) { opacity: 0; }
.escenario > :not(.pared) { transition: opacity 900ms var(--suave); }
.animando .escenario > * { transition: none; }

/* ---------- Pared y luz ---------- */
.pared {
  inset: 0;
  background:
    radial-gradient(ellipse 70% 55% at 78% 30%, rgba(255, 249, 238, 0.9) 0%, rgba(255, 249, 238, 0) 70%),
    linear-gradient(180deg, #F6F1E9 0%, #F2EBE0 60%, #EEE5D8 100%);
}

.haz {
  inset: 0;
  pointer-events: none;
  background: linear-gradient(118deg,
    rgba(255, 246, 228, 0) 30%,
    rgba(255, 246, 228, 0.55) 46%,
    rgba(255, 246, 228, 0.2) 60%,
    rgba(255, 246, 228, 0) 72%);
  opacity: 0.9;
  will-change: opacity;
}

.luz-calida {
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 65% 60% at 74% 32%, rgba(232, 200, 150, 0.30) 0%, rgba(232, 200, 150, 0) 70%),
    linear-gradient(180deg, rgba(232, 207, 200, 0.08) 0%, rgba(216, 194, 154, 0.05) 100%);
  opacity: 1;
  will-change: opacity;
}

/* ---------- Ventana ---------- */
.ventana {
  top: calc(var(--cabecera) + 2svh);
  right: 8vw;
  width: 46vw;
  aspect-ratio: 328 / 396;
}
.ventana__vista {
  position: absolute;
  top: 4.55%;
  right: 9.76%;
  bottom: 6.06%;
  left: 9.76%;
  overflow: hidden;
  border-radius: 4px;
}
.cielo,
.cielo-calido,
.bosque {
  position: absolute;
  inset: 0;
}
.cielo {
  background: linear-gradient(180deg, #C9D7E1 0%, #DCE3E6 42%, #EED9D2 78%, #F2E3D3 100%);
}
.cielo-calido {
  background: linear-gradient(180deg, #D8DDE0 0%, #EFD8CC 45%, #F1D3BC 75%, #EBCF9F 100%);
  opacity: 1;
  will-change: opacity;
}
.bosque { top: auto; height: 46%; width: 100%; }

.ventana__marco { position: absolute; inset: 0; width: 100%; height: 100%; }

.barra {
  position: absolute;
  left: -7%;
  width: 114%;
  top: -3.2%;
  height: 5px;
  border-radius: 3px;
  background: var(--dorado);
}
.cortina {
  position: absolute;
  top: -2.6%;
  left: -5%;
  width: 33%;
  height: 101%;
  border-radius: 0 0 8px 6px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0) 40%),
    repeating-linear-gradient(90deg, #F2EADD 0 13px, #E8DDCC 13px 15px, #F4EDE2 15px 27px);
  box-shadow: 4px 6px 14px rgba(74, 70, 66, 0.06);
  transform-origin: 50% 0;
  animation: cortina 9s var(--suave) infinite alternate;
  will-change: transform;
}
@keyframes cortina {
  0%   { transform: skewX(0deg) scaleX(1); }
  50%  { transform: skewX(-1.4deg) scaleX(0.975); }
  100% { transform: skewX(0.6deg) scaleX(1.01); }
}

/* ---------- Nieve ---------- */
.nieve {
  inset: 0;
  pointer-events: none;
  opacity: 1;
  will-change: opacity;
}
.copo {
  position: absolute;
  top: 0;
  left: var(--x);
  width: var(--t);
  height: var(--t);
  border-radius: 50%;
  background: radial-gradient(circle, #FFFFFF 0%, rgba(255, 255, 255, 0.9) 40%, rgba(255, 255, 255, 0) 72%);
  opacity: var(--o, 0.85);
  transform: translate3d(0, var(--y0, 40vh), 0);
  animation: caer var(--d) linear var(--r) infinite;
  animation-play-state: paused;
  will-change: transform;
}
.nieve.activa .copo { animation-play-state: running; }
@keyframes caer {
  from { transform: translate3d(0, -4vh, 0); }
  to   { transform: translate3d(var(--deriva), 104vh, 0); }
}

/* ---------- Mesa y objetos ---------- */
.mesa {
  left: 50%;
  bottom: 0;
  width: 128vw;
  aspect-ratio: 10 / 4;
  margin-left: -64vw;
}
.mesa__fondo { position: absolute; inset: 0; width: 100%; height: 100%; }

.obj {
  position: absolute;
  left: var(--l);
  top: var(--a);
  width: var(--w);
  will-change: transform;
}
.obj__dibujo { position: relative; z-index: 1; will-change: transform; }
.obj__dibujo svg { width: 100%; height: auto; overflow: visible; }
.obj__sombra {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: -6%;
  height: 26%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(120, 100, 75, 0.22) 0%, rgba(120, 100, 75, 0) 70%);
  will-change: transform, opacity;
}

/* Colocación final: «knolling», todo alineado y con aire */
.obj--papeles  { --l: 15%;   --a: 32%; --w: 14%; }
.obj--papel2   { --l: 16.4%; --a: 28%; --w: 12.6%; }
.obj--tijeras  { --l: 33%;   --a: 24%; --w: 5.4%; }
.obj--cinta    { --l: 42%;   --a: 37%; --w: 8.4%; }
.obj--bola     { --l: 54.5%; --a: 32.5%; --w: 8.2%; }
.obj--rama     { --l: 66.5%; --a: 21%; --w: 5.2%; }
.obj--taza     { --l: 74%;   --a: 28%; --w: 11%; }

.vapor { opacity: 1; }

/* ---------- Grulla ---------- */
.grulla {
  left: 0;
  top: 0;
  width: clamp(78px, 17vw, 150px);
  pointer-events: none;
  opacity: 0;
  will-change: transform, opacity;
  z-index: 3;
}
.grulla svg { width: 100%; height: auto; overflow: visible; }
.grulla .ala { transform-box: fill-box; transform-origin: 50% 100%; }
.grulla.vuela .ala--cerca { animation: aleteo 1.9s var(--suave) infinite; }
.grulla.vuela .ala--lejos { animation: aleteo 1.9s var(--suave) -0.12s infinite; }
@keyframes aleteo {
  0%, 100% { transform: scaleY(1); }
  50%      { transform: scaleY(0.3); }
}

/* ---------- Velo y texto ---------- */
.velo {
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 130% 44% at 50% 42%, rgba(247, 243, 236, 0.97) 0%, rgba(247, 243, 236, 0.9) 50%, rgba(247, 243, 236, 0) 82%);
  opacity: 1;
  will-change: opacity;
}

.hero-texto {
  z-index: 5;
  bottom: calc(51.2vw + 14px);
  left: 0;
  right: 0;
  padding: 0 clamp(20px, 6vw, 40px);
  display: grid;
  gap: 1.1rem;
  justify-items: start;
}
.hero-texto > * { will-change: transform, opacity; }
.hero-texto .titular { font-size: clamp(1.95rem, 8.2vw, 4.4rem); max-width: 14ch; }
.hero-texto .entradilla { max-width: 34ch; }
.hero-texto .boton { margin-top: 0.4rem; }
.hero-texto .nota {
  margin: -0.2rem 0 0;
  font-size: 0.85rem;
  color: var(--texto-suave);
}

.pista {
  z-index: 6;
  left: 50%;
  bottom: calc(51.2vw + 36px);
  translate: -50% 0;
  display: grid;
  justify-items: center;
  gap: 10px;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--texto-suave);
  pointer-events: none;
}
.sin-animacion .pista { display: none; }
.pista__dentro {
  display: grid;
  justify-items: center;
  gap: 10px;
  animation: aparecer 1.6s var(--suave) 1s both;
}
@keyframes aparecer { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.pista__linea {
  width: 1px;
  height: 38px;
  background: linear-gradient(180deg, var(--texto-suave), rgba(122, 115, 108, 0));
  transform-origin: 50% 0;
  animation: respira 2.8s var(--suave) infinite;
}
@keyframes respira {
  0%   { transform: scaleY(0.2); opacity: 0.2; }
  50%  { transform: scaleY(1);   opacity: 1; }
  100% { transform: scaleY(0.2); opacity: 0.2; }
}

/* ---------- Escritorio ---------- */
@media (min-width: 860px) {
  .ventana {
    top: 11vh;
    right: 10vw;
    width: min(26vw, 33vh, 440px);
  }
  .mesa {
    width: min(1180px, 88vw, 125vh);
    margin-left: calc(min(1180px, 88vw, 125vh) / -2);
  }
  .velo {
    background: radial-gradient(ellipse 52% 46% at 26% 36%, rgba(247, 243, 236, 0.96) 0%, rgba(247, 243, 236, 0.85) 45%, rgba(247, 243, 236, 0) 78%);
  }
  .hero-texto {
    top: calc(var(--cabecera) + 7vh);
    bottom: auto;
    right: auto;
    left: 8vw;
    padding: 0;
    width: min(44vw, 600px);
  }
  .hero-texto .titular { font-size: clamp(2.3rem, min(3.9vw, 6.6vh), 4.2rem); }
  .pista { bottom: calc(min(1180px, 88vw, 125vh) * 0.4 + 40px); }
}

