/*
  Coreografia do scroll (só com .motion no <html>: desktop e sem pedido de menos movimento).
  Cada .scene é alta e tem um .stage que gruda no topo; motion.js escreve --p (0 a 1) e data-step na cena,
  e liga .on nos elementos [data-at] / [data-only] do passo atual.
*/

.motion .scene .stage {
  position: sticky;
  top: 0;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

/* ---------- Cena 1: a órbita encolhe, os produtos viram um ponto e o ponto abre a vitrine ---------- */

.motion .scene--orbit {
  --p: 0;
  /* t: produtos convergem; u: o ponto cresce e vira a cor do primeiro produto (Elenchos). */
  --t: min(1, calc(var(--p) * 1.6));
  --u: clamp(0, calc((var(--p) - 0.55) / 0.45), 1);
  /* Altura = o quanto se rola: 90vh de rolagem para a abertura inteira. */
  height: 190vh;
}

.motion .scene--orbit .hero-copy {
  opacity: max(0, calc(1 - var(--p) * 3.2));
  translate: 0 calc(var(--p) * -120px);
}

.motion .scene--orbit.copy-gone .hero-copy {
  visibility: hidden;
}

.motion .scene--orbit .orbit__plane {
  scale: max(0.02, calc(1 - var(--t) * 0.98));
}

.motion .scene--orbit .planet img {
  opacity: max(0, calc(1 - var(--t) * 1.15));
}

.motion .scene--orbit .orbit__track {
  opacity: max(0, calc(1 - var(--t) * 1.4));
}

.motion .scene--orbit .orbit__core {
  scale: calc(1 + var(--u) * var(--u) * 140);
  background: color-mix(in srgb, #2f6f69 calc(var(--u) * 100%), var(--una-lime));
  /* O brilho some logo no começo: escalado junto com o ponto, viraria um halo enorme. */
  box-shadow: 0 0 40px rgb(184 230 46 / calc(0.55 * (1 - min(1, var(--u) * 10))));
}

/* ---------- Cena 2: vitrine, um produto por passo ---------- */

.motion .scene--showcase {
  /* 140vh de rolagem para 4 produtos: uns 3 giros da roda do mouse por produto. */
  height: 240vh;
}

.motion .scene--showcase .stage {
  background-color: #2f6f69;
  transition: background-color 0.7s ease;
}

.motion .scene--showcase[data-step='1'] .stage {
  background-color: #1e2a44;
}

.motion .scene--showcase[data-step='2'] .stage {
  background-color: #006a6a;
}

.motion .scene--showcase[data-step='3'] .stage {
  background-color: #142c46;
}

.motion .slide {
  position: absolute;
  inset: 0;
  min-height: 0;
  padding: 96px clamp(48px, 6vw, 96px);
  background: transparent;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.45s ease, visibility 0.45s;
}

.motion .slide.on {
  opacity: 1;
  visibility: visible;
}

.motion .slide .pitch {
  translate: 0 24px;
  transition: translate 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.motion .slide.on .pitch {
  translate: 0 0;
}

/* Os aparelhos ficam no mesmo lugar em todos os passos: só a tela troca. Inclinam com o mouse (até 6°). */
.motion .devices {
  transform: perspective(1600px) rotateY(calc(var(--mx) * -6deg)) rotateX(calc(var(--my) * 6deg));
  transition: transform 0.3s ease-out;
}

.motion .phone {
  translate: 0 calc(var(--my) * -8px);
}

.motion .progress {
  position: absolute;
  right: clamp(20px, 2.5vw, 36px);
  top: 50%;
  translate: 0 -50%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.motion .progress li {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgb(242 238 229 / 0.3);
  transition: background-color 0.3s, scale 0.3s;
}

.motion .progress li.on {
  background: var(--una-cream);
  scale: 1.4;
}

/* A tela do celular se monta quando o produto entra: o destaque e depois cada linha. */
.motion .slide .pa__hero,
.motion .slide .pa__list li {
  opacity: 0;
  translate: 0 14px;
  transition:
    opacity 0.45s ease,
    translate 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
  transition-delay: calc(0.12s + var(--i, -1) * 0.08s + 0.08s);
}

.motion .slide.on .pa__hero,
.motion .slide.on .pa__list li {
  opacity: 1;
  translate: 0 0;
}

/* ---------- Celular e tablet em pé: a mesma coreografia, em coluna ---------- */

@media (max-width: 960px) {
  /* svh: a barra de endereço do navegador do celular não faz a cena pular. */
  .motion .scene .stage {
    height: 100svh;
  }

  .motion .slide {
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding: 72px 24px 0;
  }

  .motion .slide .pitch {
    max-width: none;
  }

  .motion .pitch__icon {
    width: 44px;
    height: 44px;
    margin-bottom: 16px;
  }

  .motion .pitch h2 {
    font-size: clamp(2.25rem, 10vw, 3.25rem);
  }

  /* O celular sobe da borda de baixo e fica no mesmo lugar em todos os produtos: só a tela troca. */
  .motion .slide .devices {
    flex: 1;
    max-width: none;
    transform: none;
  }

  .motion .slide .phone {
    position: absolute;
    top: 0;
    left: 50%;
    right: auto;
    width: min(72vw, 300px);
    margin: 0;
    translate: -50% 0;
  }

  /* Pontos de progresso em linha, no alto à direita (ao lado do ícone, longe do celular). */
  .motion .progress {
    top: 86px;
    right: 24px;
    translate: none;
    flex-direction: row;
    z-index: 2;
  }
}
