/*
 * Todo o movimento da página mora aqui, dentro de prefers-reduced-motion: no-preference.
 * Quem pede menos movimento recebe a página no estado final, sem nada escondido.
 * Sistema: durações de 180, 420, 800 e 1200 ms, curvas amortecidas (sem repique),
 * deslocamento curto (8 a 24 px) com opacidade e leve desfoque, fila de 70 ms.
 * Momentos com efeito: hero, números, diagrama do híbrido, 943, troca de cor, pontos do
 * painel, mapa de dimensões e etapas do formulário. O resto só tem a entrada discreta.
 */
@media (prefers-reduced-motion: no-preference) {
  @keyframes surge {
    from {
      opacity: 0;
      filter: blur(6px);
      transform: translateY(1rem);
    }
  }

  @keyframes aparece {
    from {
      opacity: 0;
    }
  }

  /* toque */
  .botao:active {
    scale: 0.98;
  }

  .botao {
    transition:
      background-color var(--duracao-1) var(--curva),
      border-color var(--duracao-1) var(--curva),
      color var(--duracao-1) var(--curva),
      scale var(--duracao-1) var(--curva);
  }

  /* 1. hero: a foto assenta, o título sobe por dentro da máscara, o resto chega em fila */
  @keyframes hero-foto {
    from {
      transform: scale(1.08);
    }
  }

  @keyframes sobe-linha {
    from {
      transform: translateY(105%);
    }
  }

  .hero__imagem img {
    animation: hero-foto 2s var(--curva-forte) both;
  }

  .hero__rotulo {
    animation: surge var(--duracao-3) var(--curva-forte) 0.1s both;
  }

  .hero h1 .linha > span {
    animation: sobe-linha var(--duracao-4) var(--curva-forte) 0.15s both;
  }

  .hero h1 .linha:nth-child(2) > span {
    animation-delay: 0.23s;
  }

  .hero h1 .linha:nth-child(3) > span {
    animation-delay: 0.31s;
  }

  .hero__apoio {
    animation: surge var(--duracao-3) var(--curva-forte) 0.55s both;
  }

  .hero__acoes {
    animation: surge var(--duracao-3) var(--curva-forte) 0.65s both;
  }

  /* entrada discreta da cabeça de cada seção: título e apoio em fila */
  [data-js='on'] [data-entra='cabeca']:not([data-visivel]) > * {
    opacity: 0;
  }

  [data-entra='cabeca'][data-visivel] > * {
    animation: surge var(--duracao-3) var(--curva-forte) backwards;
  }

  [data-entra='cabeca'][data-visivel] > :nth-child(2) {
    animation-delay: 70ms;
  }

  [data-entra='cabeca'][data-visivel] > :nth-child(n + 3) {
    animation-delay: 140ms;
  }

  /* 2. diagrama do híbrido: as partes chegam em fila e a energia corre pelo fio */
  @keyframes pulso-corre {
    to {
      translate: 520% 0;
    }
  }

  [data-js='on'] .fluxo:not([data-visivel]) > * {
    opacity: 0;
  }

  .fluxo[data-visivel] > * {
    animation: surge var(--duracao-3) var(--curva-forte) backwards;
  }

  .fluxo[data-visivel] > .fluxo__no--eletrico {
    animation-delay: 80ms;
  }

  .fluxo[data-visivel] > .fluxo__linha {
    animation-name: aparece;
    animation-delay: 240ms;
  }

  .fluxo[data-visivel] > .fluxo__no--total {
    animation-delay: 320ms;
  }

  .fluxo[data-visivel] .fluxo__linha i::after {
    animation: pulso-corre 2.8s cubic-bezier(0.45, 0, 0.25, 1) 0.5s infinite;
  }

  .fluxo[data-visivel] .fluxo__linha i:last-child::after {
    animation-delay: 1.9s;
  }

  /* 3. mapa de dimensões: o carro chega e as cotas se abrem do centro */
  @keyframes carro-chega {
    from {
      opacity: 0;
      transform: translateX(1.5rem);
    }
  }

  @keyframes cota-abre-x {
    from {
      transform: scaleX(0);
    }
  }

  @keyframes cota-abre-y {
    from {
      transform: scaleY(0);
    }
  }

  @keyframes cota-letra {
    from {
      opacity: 0;
      transform: scale(0.6);
    }
  }

  [data-js='on'] .mapa:not([data-visivel]) :is(.mapa__carro, .mapa__cota) {
    opacity: 0;
  }

  .mapa[data-visivel] .mapa__carro {
    animation: carro-chega var(--duracao-4) var(--curva-forte) backwards;
  }

  .mapa[data-visivel] .mapa__cota {
    animation: aparece var(--duracao-1) linear 0.5s backwards;
  }

  .mapa[data-visivel] .mapa__cota line {
    animation: cota-abre-x var(--duracao-4) var(--curva-forte) 0.5s backwards;
  }

  .mapa[data-visivel] .mapa__cota--c line {
    animation-name: cota-abre-y;
  }

  .mapa[data-visivel] .mapa__cota :is(circle, text) {
    animation: cota-letra var(--duracao-2) var(--curva-forte) 1s backwards;
  }

  .mapa[data-visivel] .mapa__cota--b,
  .mapa[data-visivel] .mapa__cota--b line {
    animation-delay: 0.65s;
  }

  .mapa[data-visivel] .mapa__cota--c,
  .mapa[data-visivel] .mapa__cota--c line {
    animation-delay: 0.8s;
  }

  /* 4. pontos do painel: anel lento que convida ao toque */
  @keyframes ponto-pulsa {
    from {
      opacity: 0.8;
      transform: scale(0.4);
    }

    70%,
    to {
      opacity: 0;
      transform: scale(1.4);
    }
  }

  .ponto::after {
    animation: ponto-pulsa 3.2s var(--curva) infinite;
  }

  .ponto--sync::after {
    animation-delay: 1s;
  }

  .ponto--modos::after {
    animation-delay: 2s;
  }

  .ponto[aria-pressed='true']::after {
    animation: none;
  }

  /* 5. cores: a nova pintura se abre em círculo a partir do seletor e o carro assenta */
  @keyframes cor-revela {
    from {
      clip-path: circle(0% at 50% 100%);
    }

    to {
      clip-path: circle(125% at 50% 100%);
    }
  }

  @keyframes cor-carro {
    from {
      opacity: 0.4;
      transform: translateX(2.5%) scale(1.03);
    }
  }

  .cores__foto--entra {
    z-index: 1;
    animation: cor-revela var(--duracao-4) var(--curva-forte) both;
  }

  .cores__foto--entra img {
    animation: cor-carro var(--duracao-4) var(--curva-forte) both;
  }

  /* guia e formulário */
  @keyframes etapa-avanca {
    from {
      opacity: 0;
      transform: translateX(1.5rem);
    }
  }

  @keyframes etapa-volta {
    from {
      opacity: 0;
      transform: translateX(-1.5rem);
    }
  }

  @keyframes gira {
    to {
      rotate: 1turn;
    }
  }

  @keyframes selo-chega {
    from {
      opacity: 0;
      transform: scale(0.7);
    }
  }

  .guia__resultado [data-resultado]:not([hidden]) {
    animation: surge var(--duracao-3) var(--curva-forte) both;
  }

  .lead[data-direcao='avanca'] .lead__etapa:not([hidden]) {
    animation: etapa-avanca var(--duracao-2) var(--curva-forte) both;
  }

  .lead[data-direcao='volta'] .lead__etapa:not([hidden]) {
    animation: etapa-volta var(--duracao-2) var(--curva-forte) both;
  }

  .lead__erro:not([hidden]),
  .lead__aviso:not([hidden]),
  [data-lead-troca]:not([hidden]) {
    animation: surge var(--duracao-2) var(--curva-forte) both;
  }

  .lead[data-estado='enviando'] [data-lead-enviar]::after {
    animation: gira 0.8s linear infinite;
  }

  .lead__sucesso:not([hidden]) > * {
    animation: surge var(--duracao-3) var(--curva-forte) both;
  }

  .lead__sucesso:not([hidden]) > .lead__selo {
    animation-name: selo-chega;
  }

  .lead__sucesso:not([hidden]) > :nth-child(2) {
    animation-delay: 70ms;
  }

  .lead__sucesso:not([hidden]) > :nth-child(3) {
    animation-delay: 140ms;
  }

  .lead__sucesso:not([hidden]) > :nth-child(n + 4) {
    animation-delay: 210ms;
  }

  /* filme: o botão responde ao ponteiro com calma */
  .filme__play svg {
    transition: scale var(--duracao-2) var(--curva-forte);
  }

  .filme__play:hover svg {
    scale: 1.08;
  }

  .filme__play:active svg {
    scale: 0.96;
  }

  /* perguntas e ficha: o painel abre e fecha medindo a própria altura */
  @supports (interpolate-size: allow-keywords) {
    :root {
      interpolate-size: allow-keywords;
    }

    details::details-content {
      block-size: 0;
      overflow: clip;
      transition:
        block-size var(--duracao-2) var(--curva),
        content-visibility var(--duracao-2) allow-discrete;
    }

    details[open]::details-content {
      block-size: auto;
    }
  }

  /* presos à rolagem: só transform, amplitude pequena, só onde o navegador faz sem JavaScript */
  @supports (animation-timeline: view()) {
    @keyframes progresso {
      to {
        transform: scaleX(1);
      }
    }

    .cabecalho__estrada {
      animation: progresso linear both;
      animation-timeline: scroll(root);
    }

    @keyframes hero-afunda {
      to {
        transform: translateY(7%);
      }
    }

    .hero__imagem {
      animation: hero-afunda linear both;
      animation-timeline: scroll(root);
      animation-range: 0 100svh;
    }

    /* fotos com profundidade: a imagem anda um pouco mais devagar que a moldura */
    @keyframes foto-desliza {
      from {
        transform: scale(1.08) translateY(-3%);
      }

      to {
        transform: scale(1.08) translateY(3%);
      }
    }

    .bloco__imagem img,
    .cacamba__imagem img {
      animation: foto-desliza linear both;
      animation-timeline: view();
    }

    /* 6. 943 atravessa a foto da caçamba devagar */
    @keyframes numero-corre {
      from {
        transform: translateX(9%);
      }

      to {
        transform: none;
      }
    }

    .cacamba__numero {
      animation: numero-corre linear both;
      animation-timeline: view();
      animation-range: entry 10% cover 55%;
    }
  }
}
