/* =============================================================================
   Tenet · css/cenas.css · as cenas de rolagem presa (rodada 2 de motion)
   Uma cena é uma seção alta (data-cena) com o conteúdo preso na tela
   (sticky) enquanto a rolagem anda: a rolagem vira a agulha do tempo, como a
   linha do tempo do Remotion. Linha do tempo: view-timeline da própria seção,
   faixa "contain" (o trecho em que ela cobre a tela inteira).
   Sem suporte a animation-timeline, com movimento reduzido ou em tela baixa
   ou estreita, a cena volta a ser uma seção comum, inteira e parada.
   Camada movimento (a última): ganha das regras de home.css sem disputa de
   especificidade.
   ========================================================================== */

@layer movimento {
  /* ================================================ cena C · herói da /otto
     O filme do Remotion (video/cena-c.mp4) no lugar do celular parado. Sem
     movimento liberado, o filme some e fica o celular de sempre (que tem o
     próprio aria-label); com ele, o celular sai e o filme leva o rótulo. */
  .heroi-filme { display: none; margin: 0; }
  @media (prefers-reduced-motion: no-preference) {
    .heroi-filme {
      position: relative; display: block; justify-self: center;
      inline-size: min(100%, 460px); aspect-ratio: 864 / 1080;
      border-radius: 40px; overflow: hidden; background: #0b0a0f;
      box-shadow: 0 0 0 1px var(--linha-forte), 0 50px 100px -40px rgb(40 16 90 / .55), 0 24px 48px -30px var(--sombra-cor);
      animation: c-entra 1.1s .25s var(--mv-suave) both;
    }
    .heroi-filme video { display: block; inline-size: 100%; block-size: 100%; object-fit: cover; }
    /* o aro de vidro por cima do filme */
    .heroi-filme::after {
      content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1.5px; pointer-events: none;
      background: linear-gradient(135deg, rgb(255 255 255 / .55), rgb(255 255 255 / 0) 30%, rgb(178 152 249 / .5) 60%, rgb(211 185 151 / .45));
      -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); -webkit-mask-composite: xor;
      mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); mask-composite: exclude;
    }
    .heroi-filme + .heroi-peca { display: none; }
    @supports (animation-timeline: view()) {
      .heroi-filme { animation: c-entra 1.1s .25s var(--mv-suave) both, sai-devagar linear; animation-timeline: auto, view(); animation-range: normal, exit 0% exit 100%; }
    }
  }
  @keyframes c-entra { from { opacity: 0; translate: 0 40px; scale: .94; } }

  @supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) and (min-width: 861px) and (min-height: 640px) {

      /* ================================================ cena B · home
         O celular entra de lado, em 3D, gira de frente e a conversa da
         Mariana se escreve com a rolagem; as três promessas acendem quando
         o Otto as cumpre (responde, mostra foto e preço, manda o link). */
      .cena-b { block-size: 360svh; view-timeline: --cena-b block; }
      .cena-b > .celula {
        position: sticky; top: var(--topo);
        min-block-size: calc(100svh - var(--topo));
        display: grid; align-content: center;
        padding-block: 24px;
      }
      .cena-b .otto-cartao { perspective: 1600px; overflow: visible; }
      .cena-b .otto-cartao .celular {
        transform-style: preserve-3d;
        animation: b-camera linear both; animation-timeline: --cena-b; animation-range: contain 0% contain 100%;
        will-change: transform;
      }
      /* o cartão abre como uma janela: começa recolhido e se expande */
      .cena-b .otto-cartao {
        animation: b-cartao linear both; animation-timeline: --cena-b; animation-range: contain 0% contain 16%;
      }

      /* a conversa: cada fala tem seu trecho da rolagem e fica (fill both) */
      .cena-b .otto-vitrine:has(#seg-1:checked) .c1 > * {
        animation: fala-v linear both; animation-timeline: --cena-b; animation-delay: 0s;
      }
      .cena-b .otto-vitrine:has(#seg-1:checked) .c1 > .m1 { animation-range: contain 16% contain 24%; }
      .cena-b .otto-vitrine:has(#seg-1:checked) .c1 > .digitando { animation-name: b-digitando; animation-range: contain 24% contain 36%; }
      .cena-b .otto-vitrine:has(#seg-1:checked) .c1 > .m2 { animation-range: contain 34% contain 41%; }
      .cena-b .otto-vitrine:has(#seg-1:checked) .c1 > .m3 { animation-name: b-produto; animation-range: contain 44% contain 56%; }
      .cena-b .otto-vitrine:has(#seg-1:checked) .c1 > .m4 { animation-range: contain 58% contain 65%; }
      .cena-b .otto-vitrine:has(#seg-1:checked) .c1 > .m5 { animation-range: contain 68% contain 75%; }
      .cena-b .otto-vitrine:has(#seg-1:checked) .c1 > .m6 { animation-name: b-evento; animation-range: contain 78% contain 90%; }

      /* as promessas acendem no momento em que acontecem */
      .cena-b .promessas li { animation: b-acende linear both; animation-timeline: --cena-b; }
      .cena-b .promessas li:nth-child(1) { animation-range: contain 34% contain 42%; }
      .cena-b .promessas li:nth-child(2) { animation-range: contain 46% contain 56%; }
      .cena-b .promessas li:nth-child(3) { animation-range: contain 78% contain 88%; }
      .cena-b .promessas .icone-vidro { animation: b-icone linear both; animation-timeline: --cena-b; }
      .cena-b .promessas li:nth-child(1) .icone-vidro { animation-range: contain 34% contain 44%; }
      .cena-b .promessas li:nth-child(2) .icone-vidro { animation-range: contain 46% contain 58%; }
      .cena-b .promessas li:nth-child(3) .icone-vidro { animation-range: contain 78% contain 90%; }

      /* o título entra junto com o cartão */
      .cena-b .otto-texto > :not(.promessas) { animation: revela linear both; animation-timeline: --cena-b; animation-range: contain 10% contain 22%; }
    }
  }

  @keyframes b-cartao {
    from { clip-path: inset(6% 4% round 64px); scale: .9; opacity: 0; }
    to   { clip-path: inset(0 0 round clamp(22px, 3vw, 36px)); scale: 1; opacity: 1; }
  }
  @keyframes b-camera {
    0%   { transform: translate3d(48%, 14%, -420px) rotateY(-58deg) rotateX(20deg) rotateZ(7deg); opacity: 0; }
    4%   { opacity: 1; }
    22%  { transform: translate3d(6%, 0, -60px) rotateY(-16deg) rotateX(6deg) rotateZ(1deg); }
    34%  { transform: translate3d(0, 0, 0) rotateY(-4deg) rotateX(1deg); }
    50%  { transform: translate3d(-10%, -2%, 160px) rotateY(9deg) rotateX(-2deg) scale(1.14); }
    64%  { transform: translate3d(0, 0, 0) rotateY(-3deg) scale(1); }
    88%  { transform: translate3d(-6%, -3%, 130px) rotateY(-7deg) rotateX(3deg) scale(1.1); }
    100% { transform: translate3d(12%, -8%, -160px) rotateY(22deg) rotateX(-6deg) scale(.9); }
  }
  @keyframes b-digitando { 0% { opacity: 0; } 15%, 75% { opacity: 1; } 100% { opacity: 0; } }
  @keyframes b-produto {
    0%   { opacity: 0; translate: 0 1.2em; scale: .7; }
    60%  { opacity: 1; scale: 1.04; }
    100% { opacity: 1; translate: 0 0; scale: 1; }
  }
  @keyframes b-evento {
    0%   { opacity: 0; scale: .6; }
    40%  { opacity: 1; scale: 1.12; box-shadow: 0 0 0 0 rgb(79 107 42 / .5); }
    100% { opacity: 1; scale: 1; box-shadow: 0 0 0 14px rgb(79 107 42 / 0); }
  }
  @keyframes b-acende { from { opacity: .32; translate: -6px 0; } to { opacity: 1; translate: 0 0; } }
  @keyframes b-icone { 0% { scale: .7; rotate: -12deg; } 60% { scale: 1.25; rotate: 4deg; } 100% { scale: 1; rotate: 0deg; } }

  /* ======================================================= cena E · /otto
     "Como vende": a seção fica presa e o celular gira em 3D de ramo em
     ramo (moda → colchões → ótica → estética → veículos), cada conversa se
     escrevendo com a rolagem e a aba do ramo acesa. Só enquanto a Moda,
     que abre escolhida, segue escolhida: quem clica numa aba manda, e o
     ciclo para (fica o ramo escolhido, parado). Faixas geradas: 20% da
     cena por ramo. */
  @supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) and (min-width: 960px) and (min-height: 820px) {
      #catalogo.cena-e { block-size: 520svh; view-timeline: --cena-e block; padding-block: 0; }
      .cena-e > .largura { position: sticky; top: 76px; min-block-size: calc(100svh - 76px); display: grid; align-content: center; }
      .cena-e .ramos-telas { display: grid; perspective: 1400px; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela { display: block; grid-area: 1 / 1; }
      /* a aba marcada (Moda) não fica acesa o tempo todo: o anel segue a cena */
      .cena-e .ramos:has(#ramo-moda:checked) .ramos-abas input:checked + label { font-weight: 560; background: var(--gv-placa); box-shadow: inset 0 1px 0 var(--gv-topo), 0 0 0 .5px var(--gv-aro-liso), 0 1px 2px var(--sombra-cor); }
      .cena-e .ramos:has(#ramo-moda:checked) .ramos-abas label::after {
        content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
        box-shadow: 0 0 0 1.5px var(--otto), 0 10px 24px -12px color-mix(in oklab, var(--otto) 60%, transparent);
        opacity: 0; animation: e-aba linear both; animation-timeline: --cena-e;
      }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela .digitando { display: none; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela [data-t] { animation: surge-baixo linear both; animation-timeline: --cena-e; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="moda"] { animation: e-sai linear both; animation-timeline: --cena-e; animation-range: contain 16% contain 20%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="moda"] [data-t="1"] { animation-range: contain 2.0% contain 4.6%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="moda"] [data-t="2"] { animation-range: contain 4.6% contain 7.2%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="moda"] [data-t="3"] { animation-range: contain 7.2% contain 9.8%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="moda"] [data-t="4"] { animation-range: contain 9.8% contain 12.4%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="moda"] [data-t="5"] { animation-range: contain 12.4% contain 15.0%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramos-abas input:nth-of-type(1) + label::after { animation-range: contain 0% contain 20%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="colchoes"] { animation: e-entra linear both, e-sai linear both; animation-timeline: --cena-e, --cena-e; animation-range: contain 20% contain 24%, contain 36% contain 40%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="colchoes"] [data-t="1"] { animation-range: contain 22.0% contain 24.6%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="colchoes"] [data-t="2"] { animation-range: contain 24.6% contain 27.2%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="colchoes"] [data-t="3"] { animation-range: contain 27.2% contain 29.8%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="colchoes"] [data-t="4"] { animation-range: contain 29.8% contain 32.4%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="colchoes"] [data-t="5"] { animation-range: contain 32.4% contain 35.0%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramos-abas input:nth-of-type(2) + label::after { animation-range: contain 20% contain 40%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="otica"] { animation: e-entra linear both, e-sai linear both; animation-timeline: --cena-e, --cena-e; animation-range: contain 40% contain 44%, contain 56% contain 60%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="otica"] [data-t="1"] { animation-range: contain 42.0% contain 44.6%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="otica"] [data-t="2"] { animation-range: contain 44.6% contain 47.2%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="otica"] [data-t="3"] { animation-range: contain 47.2% contain 49.8%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="otica"] [data-t="4"] { animation-range: contain 49.8% contain 52.4%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="otica"] [data-t="5"] { animation-range: contain 52.4% contain 55.0%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramos-abas input:nth-of-type(3) + label::after { animation-range: contain 40% contain 60%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="estetica"] { animation: e-entra linear both, e-sai linear both; animation-timeline: --cena-e, --cena-e; animation-range: contain 60% contain 64%, contain 76% contain 80%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="estetica"] [data-t="1"] { animation-range: contain 62.0% contain 64.6%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="estetica"] [data-t="2"] { animation-range: contain 64.6% contain 67.2%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="estetica"] [data-t="3"] { animation-range: contain 67.2% contain 69.8%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="estetica"] [data-t="4"] { animation-range: contain 69.8% contain 72.4%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="estetica"] [data-t="5"] { animation-range: contain 72.4% contain 75.0%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramos-abas input:nth-of-type(4) + label::after { animation-range: contain 60% contain 80%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="veiculos"] { animation: e-entra linear both; animation-timeline: --cena-e; animation-range: contain 80% contain 84%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="veiculos"] [data-t="1"] { animation-range: contain 82.0% contain 84.6%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="veiculos"] [data-t="2"] { animation-range: contain 84.6% contain 87.2%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="veiculos"] [data-t="3"] { animation-range: contain 87.2% contain 89.8%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="veiculos"] [data-t="4"] { animation-range: contain 89.8% contain 92.4%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramo-tela[data-ramo="veiculos"] [data-t="5"] { animation-range: contain 92.4% contain 95.0%; }
      .cena-e .ramos:has(#ramo-moda:checked) .ramos-abas input:nth-of-type(5) + label::after { animation-range: contain 80% contain 100%; }
    }
  }
  @keyframes e-entra { from { opacity: 0; transform: rotateY(-75deg) translateX(40%) scale(.82); } }
  @keyframes e-sai { to { opacity: 0; transform: rotateY(75deg) translateX(-40%) scale(.82); } }
  @keyframes e-aba { 0% { opacity: 0; } 8%, 90% { opacity: 1; } 100% { opacity: 0; } }


  /* ======================================================= cena D · /otto
     A técnica na seção Ametista: o cabeçalho passa e a conversa da Renata
     fica presa ao lado do funil; cada fala chega com a rolagem, o passo da
     margem acende, o ticket cresce de R$ 69 para R$ 119 e as etapas do
     funil acendem juntas (oi, entendeu, sugeriu, link). No fim entram as
     duas saídas: comprou ou pronta para o time. */
  @supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) and (min-width: 960px) and (min-height: 820px) {
      #tecnica.cena-d { view-timeline: --cena-d block; }
      .cena-d > .largura { block-size: 300svh; }
      .cena-d .tecnica-grade { position: sticky; top: 96px; }
      .cena-d .peca-tecnica { animation: d-mesa linear both; animation-timeline: --cena-d; animation-range: contain 0% contain 14%; }
      .cena-d .peca-tecnica :is(.tec:not(:first-child), .tec-fim) { animation: surge-baixo linear both; animation-timeline: --cena-d; }
      .cena-d .peca-tecnica .tec-passo { animation: acende linear both; animation-timeline: --cena-d; }
      .cena-d .ticket-barra i[data-parte="par"] { animation: ticket-cresce linear both; animation-timeline: --cena-d; animation-range: contain 58% contain 72%; }
      .cena-d .funil-etapas li { animation: d-etapa linear both; animation-timeline: --cena-d; }
      .cena-d .funil-saidas li { animation: surge-baixo linear both; animation-timeline: --cena-d; }
      .cena-d .funil-saidas li:nth-child(1) { animation-range: contain 78% contain 86%; }
      .cena-d .funil-saidas li:nth-child(2) { animation-range: contain 82% contain 90%; }
      .cena-d .peca-tecnica .tecnica-lista > .tec:nth-child(2) { animation-range: contain 6% contain 14%; }
      .cena-d .peca-tecnica .tecnica-lista > .tec:nth-child(2) .tec-passo { animation-range: contain 6% contain 17%; }
      .cena-d .peca-tecnica .tecnica-lista > .tec:nth-child(3) { animation-range: contain 15% contain 23%; }
      .cena-d .peca-tecnica .tecnica-lista > .tec:nth-child(3) .tec-passo { animation-range: contain 15% contain 26%; }
      .cena-d .peca-tecnica .tecnica-lista > .tec:nth-child(4) { animation-range: contain 24% contain 32%; }
      .cena-d .peca-tecnica .tecnica-lista > .tec:nth-child(4) .tec-passo { animation-range: contain 24% contain 35%; }
      .cena-d .peca-tecnica .tecnica-lista > .tec:nth-child(5) { animation-range: contain 33% contain 41%; }
      .cena-d .peca-tecnica .tecnica-lista > .tec:nth-child(5) .tec-passo { animation-range: contain 33% contain 44%; }
      .cena-d .peca-tecnica .tecnica-lista > .tec:nth-child(6) { animation-range: contain 42% contain 50%; }
      .cena-d .peca-tecnica .tecnica-lista > .tec:nth-child(6) .tec-passo { animation-range: contain 42% contain 53%; }
      .cena-d .peca-tecnica .tecnica-lista > .tec:nth-child(7) { animation-range: contain 51% contain 59%; }
      .cena-d .peca-tecnica .tecnica-lista > .tec:nth-child(7) .tec-passo { animation-range: contain 51% contain 62%; }
      .cena-d .funil-etapas li:nth-child(1) { animation-range: contain 2% contain 8%; }
      .cena-d .funil-etapas li:nth-child(2) { animation-range: contain 22% contain 30%; }
      .cena-d .funil-etapas li:nth-child(3) { animation-range: contain 42% contain 50%; }
      .cena-d .funil-etapas li:nth-child(4) { animation-range: contain 60% contain 68%; }
    }
  }
  @keyframes d-mesa { from { opacity: .3; transform: perspective(1200px) rotateX(16deg) translateY(40px) scale(.94); } }
  @keyframes d-etapa {
    0%   { opacity: .35; translate: -10px 0; box-shadow: inset 0 0 0 1px var(--linha); }
    60%  { opacity: 1; translate: 0 0; box-shadow: inset 0 0 0 1.5px var(--otto), 0 0 28px -6px var(--otto-fio); }
    100% { opacity: 1; translate: 0 0; box-shadow: inset 0 0 0 1px var(--otto-fio); }
  }

  /* ===================================================== cena F · títulos
     Os títulos de seção entram palavra por palavra (cada palavra é um
     .pal no HTML): sobem girando em X, como letreiro de filme, seguindo a
     rolagem do próprio título. As do <em> vêm depois das de fora. Os da
     cena B ficam de fora (já entram com a cena presa). Fora da faixa, o
     título está inteiro. */
  .pal { display: inline-block; }
  @supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
      .frase:has(.pal) { view-timeline: --titulo block; perspective: 700px; }
      :is(.cena-cabeca, .contato-texto, .gente-fala, .otto-texto) .frase:has(.pal) { animation: none; }
      .frase .pal { transform-origin: 50% 100%; animation: f-palavra linear both; animation-timeline: --titulo; }
      .frase > .pal:nth-of-type(1) { animation-range: cover 4% cover 22%; }
      .frase > .pal:nth-of-type(2) { animation-range: cover 7% cover 25%; }
      .frase > .pal:nth-of-type(3) { animation-range: cover 10% cover 28%; }
      .frase > .pal:nth-of-type(4) { animation-range: cover 13% cover 31%; }
      .frase > .pal:nth-of-type(5) { animation-range: cover 16% cover 34%; }
      .frase > .pal:nth-of-type(6) { animation-range: cover 19% cover 37%; }
      .frase > .pal:nth-of-type(7) { animation-range: cover 22% cover 40%; }
      .frase > .pal:nth-of-type(8) { animation-range: cover 25% cover 43%; }
      .frase em > .pal:nth-of-type(1) { animation-range: cover 13% cover 31%; }
      .frase em > .pal:nth-of-type(2) { animation-range: cover 16% cover 34%; }
      .frase em > .pal:nth-of-type(3) { animation-range: cover 19% cover 37%; }
      .frase em > .pal:nth-of-type(4) { animation-range: cover 22% cover 40%; }
      .frase em > .pal:nth-of-type(5) { animation-range: cover 25% cover 43%; }
      .frase em > .pal:nth-of-type(6) { animation-range: cover 28% cover 46%; }
      :is(.cena-b, .cena-e) .frase .pal { animation: none; }
    }
  }
  @keyframes f-palavra { from { opacity: 0; transform: translateY(.45em) rotateX(-75deg); } }
}
