/* ==========================================================
   Abertura cinematográfica — "O livro que vira borboleta"
   Linha do tempo (segundos após o clique):
   0,1 lombada · 0,6–2,2 páginas · 1,9–3,1 asas · 2,8 antenas
   3,3–4,4 nome · 4,75 voo até o cabeçalho · ~6 site
   ========================================================== */
.intro {
  position: fixed; inset: 0; z-index: 500;
  display: grid; place-items: center;
  background:
    radial-gradient(60% 55% at 50% 45%, rgba(217,196,236,.0) 0%, rgba(217,196,236,0) 70%),
    var(--creme);
  overflow: hidden;
  transition: opacity .65s var(--ease), background-color .65s var(--ease);
}
.intro[hidden] { display: none; }
/* luz lilás que cresce atrás da borboleta */
.intro::before {
  content: ""; position: absolute; left: 50%; top: 38%;
  width: 90vmin; height: 90vmin; border-radius: 50%;
  transform: translate(-50%, -50%) scale(.3);
  background: radial-gradient(circle, rgba(217,196,236,.85) 0%, rgba(241,232,248,.5) 38%, rgba(253,246,232,0) 70%);
  opacity: 0; pointer-events: none;
}
/* grão e vinheta, para dar textura de filme */
.intro::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(91,44,122,.10) 100%),
    radial-gradient(rgba(46,34,54,.05) 1px, transparent 1px);
  background-size: auto, 3px 3px;
}
.intro.rodando::before { animation: intro-luz 5.5s 1.2s var(--ease) forwards; }
@keyframes intro-luz { to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

.intro.saindo { opacity: 0; pointer-events: none; }

/* ---------- Convite (antes do play) ---------- */
.intro__convite {
  position: relative; z-index: 3; text-align: center; padding: var(--s5);
  max-width: 34rem;
  animation: intro-convite 1.1s var(--ease) both;
}
.intro__convite[hidden] { display: none; }
@keyframes intro-convite { from { opacity: 0; transform: translateY(14px); } }
.intro__sobre { font-size: var(--fs-sm); font-weight: 600; color: var(--lavanda-texto); margin-bottom: var(--s3); }
.intro__titulo { font-size: clamp(2.8rem, 2rem + 4vw, 4.8rem); font-weight: 600; letter-spacing: -.03em; margin-bottom: var(--s3); }
.intro__texto { font-size: var(--fs-lg); color: var(--texto-suave); margin-bottom: var(--s6); }
.intro__botoes { display: flex; flex-wrap: wrap; gap: var(--s3); justify-content: center; }
.intro__pular-link {
  margin-top: var(--s5); background: none; border: 0; color: var(--texto-suave);
  font-size: var(--fs-sm); text-decoration: underline; text-underline-offset: .25em;
}
.intro__pular-link:hover { color: var(--roxo); }

/* ---------- Palco ---------- */
.intro__palco {
  position: absolute; inset: 0; z-index: 2;
  display: grid; place-items: center; pointer-events: none;
  opacity: 0;
}
.intro.rodando .intro__palco { opacity: 1; }
.intro-svg { width: min(78vw, 560px); height: auto; overflow: visible; margin-top: -4vh; }

.intro__legenda {
  position: absolute; z-index: 3; left: 0; right: 0; bottom: max(9vh, 64px);
  text-align: center; font-family: var(--serif); font-style: italic; font-weight: 400;
  font-size: clamp(1.15rem, 1rem + .6vw, 1.5rem); color: var(--texto-suave);
  min-height: 1.6em;
}
.intro.rodando .intro__legenda { animation: intro-legenda 8.1s .3s linear both; }
@keyframes intro-legenda { 0% { opacity: 0; } 3% { opacity: 1; } 97% { opacity: 1; } 100% { opacity: 0; } }
@keyframes intro-legenda { 0% { opacity: 0; } 8% { opacity: 1; } 92% { opacity: 1; } 100% { opacity: 0; } }

.intro__pular {
  position: absolute; z-index: 4; right: 20px; bottom: 20px;
  background: rgba(255,255,255,.7); border: 1px solid var(--linha); color: var(--roxo);
  border-radius: var(--raio-pill); padding: .55rem 1rem; font-size: var(--fs-xs); font-weight: 600;
}
.intro__pular:hover { background: #fff; }
.intro__pular[hidden] { display: none; }

/* ---------- Estado inicial das peças ---------- */
.intro-svg .body { transform-box: view-box; transform-origin: 200px 222px; transform: scaleY(0); }
.intro-svg .pg { transform-box: view-box; transform-origin: 198px 206px; transform: scaleX(0) rotate(6deg); opacity: 0; }
.intro-svg .w { transform-box: view-box; transform-origin: 196px 162px; transform: rotate(-78deg) scale(.35); opacity: 0; }
.intro-svg .head { transform-box: fill-box; transform-origin: center; transform: scale(0); }
.intro-svg .ant { stroke-dasharray: 150; stroke-dashoffset: 150; }
.intro-svg .iw { opacity: 0; transform-box: fill-box; transform-origin: center; }
.intro-svg .iw-es, .intro-svg .iw-rec, .intro-svg .iw-tag { transform: translateY(14px); }
.intro-svg .iw-sw { transform: scaleX(0); }

/* ---------- Animação ---------- */
.intro.fase2 .body { animation: i-cresce 1.44s 0.16s var(--ease) forwards; }
.intro.fase2 .pg { animation: i-pagina 1.60s var(--ease) forwards; }
.intro.fase2 .pg5 { animation-delay: 0.96s; }
.intro.fase2 .pg4 { animation-delay: 1.23s; }
.intro.fase2 .pg3 { animation-delay: 1.50s; }
.intro.fase2 .pg2 { animation-delay: 1.78s; }
.intro.fase2 .pg1 { animation-delay: 2.05s; }
.intro.fase2 .w { animation: i-asa 1.84s cubic-bezier(.3, 1.35, .45, 1) forwards; }
.intro.fase2 .w1 { animation-delay: 3.04s; }
.intro.fase2 .w2 { animation-delay: 3.23s; }
.intro.fase2 .w3 { animation-delay: 3.42s; }
.intro.fase2 .head { animation: i-cabeca 0.88s 4.40s cubic-bezier(.3, 1.6, .5, 1) forwards; }
.intro.fase2 .ant { animation: i-antena 1.28s 4.56s var(--ease) forwards; }
.intro.fase2 .iw-es { animation: i-sobe 1.44s 5.28s var(--ease) forwards; }
.intro.fase2 .iw-rec { animation: i-sobe 1.60s 5.52s var(--ease) forwards; }
.intro.fase2 .iw-sw { animation: i-traco 1.44s 6.16s var(--ease) forwards; }
.intro.fase2 .iw-tag { animation: i-sobe 1.44s 6.40s var(--ease) forwards; }

@keyframes i-cresce { to { transform: scaleY(1); } }
@keyframes i-pagina { 60% { opacity: 1; } to { transform: none; opacity: 1; } }
@keyframes i-asa { 25% { opacity: 1; } to { transform: none; opacity: 1; } }
@keyframes i-cabeca { to { transform: scale(1); } }
@keyframes i-antena { to { stroke-dashoffset: 0; } }
@keyframes i-sobe { to { opacity: 1; transform: none; } }
@keyframes i-traco { to { opacity: 1; transform: none; } }

/* ---------- Voo ---------- */
.intro.voando .iw { transition: opacity .45s var(--ease); opacity: 0 !important; animation: none; }
.intro.voando .intro__legenda { opacity: 0; transition: opacity .3s; }
.intro.voando::before { transition: opacity .8s; opacity: 0; animation: none; }
.intro.voando { background-color: rgba(253,246,232,.0); }

/* ---------- Movimento reduzido: só um esmaecer ---------- */
.intro.reduzido .intro-svg * { animation: none !important; transform: none !important; opacity: 1 !important; stroke-dashoffset: 0 !important; }
.intro.reduzido .intro__palco { animation: i-fade 1s ease both; }
@keyframes i-fade { from { opacity: 0; } }

/* Borboleta que voa até a prévia publicada no mural */
.voo { position: fixed; left: 0; top: 0; z-index: 260; width: 90px; display: none; pointer-events: none; margin: -30px 0 0 -45px; }
.intro .botao:focus-visible { outline-color: var(--lavanda); }
/* Abertura: controles de som e pular */
.intro__controles { position: absolute; z-index: 4; right: 20px; bottom: 20px; display: flex; gap: var(--s2); }
.intro__controles[hidden] { display: none; }
.intro__controles .intro__pular { position: static; }
.intro__som {
  background: rgba(255,255,255,.7); border: 1px solid var(--linha); color: var(--roxo);
  border-radius: var(--raio-pill); padding: .55rem 1rem; font-size: var(--fs-xs); font-weight: 600; min-height: 40px;
}
.intro__som:hover { background: #fff; }
.intro__som[hidden] { display: none; }
.intro__pular { min-height: 40px; }

/* ==========================================================
   Livro que se folheia sozinho (fase 1: 0 a 6,7 s)
   Capa abre e cinco páginas viram, uma palavra em cada:
   "Eu", "sou", "porque", "nós", "somos."
   ========================================================== */
.intro-svg { opacity: 0; transition: opacity .8s var(--ease); }
.intro.fase2 .intro-svg { opacity: 1; }
.abertura-livro {
  position: absolute; left: 50%; top: 46%; width: min(86vw, 600px); aspect-ratio: 3 / 2;
  transform: translate(-50%, -50%) scale(.92); perspective: 2000px; opacity: 0; pointer-events: none;
}
.intro.rodando .abertura-livro { animation: livro-entra 1.1s .1s var(--ease) forwards; }
.intro.fase2 .abertura-livro { animation: livro-sai 1.2s var(--ease) forwards; }
@keyframes livro-entra { from { opacity: 0; transform: translate(-50%, -46%) scale(.86); } to { opacity: 1; transform: translate(-50%, -50%) scale(.92); } }
@keyframes livro-sai { from { opacity: 1; transform: translate(-50%, -50%) scale(.92); filter: blur(0); } to { opacity: 0; transform: translate(-50%, -54%) scale(.7); filter: blur(6px); } }
.abertura-livro::after { /* sombra no chão */
  content: ""; position: absolute; left: 6%; right: 6%; bottom: -8%; height: 12%;
  background: radial-gradient(closest-side, rgba(67,32,91,.22), transparent); z-index: -1;
}
.papel {
  background-color: #FFFCF6;
  background-image: repeating-linear-gradient(transparent 0 calc(10% - 1px), rgba(166,124,203,.22) calc(10% - 1px) 10%);
  background-position: 0 6%;
}
.abertura-livro__base { position: absolute; left: 50%; top: 0; width: 50%; height: 100%; border-radius: 0 8px 8px 0;
  box-shadow: inset 10px 0 18px -12px rgba(67,32,91,.35), 0 10px 30px -14px rgba(67,32,91,.45); }
.folha { position: absolute; left: 50%; top: 0; width: 50%; height: 100%; transform-origin: left center; transform-style: preserve-3d; }
.folha > div { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 0 8px 8px 0; }
.folha .verso { transform: rotateY(180deg); border-radius: 8px 0 0 8px; display: grid; place-items: center;
  box-shadow: inset -10px 0 18px -12px rgba(67,32,91,.35); }
.folha .frente { box-shadow: inset 10px 0 18px -12px rgba(67,32,91,.3); }
.folha--capa .frente { background: linear-gradient(135deg, #6E3A92, var(--roxo) 60%, #43205B); display: grid; place-items: center; }
.folha--capa .frente svg { width: 62%; filter: drop-shadow(0 6px 10px rgba(0,0,0,.25)); }
.folha--capa .verso { background: #EADCF6; }
.palavra-livro { font-family: var(--serif); font-weight: 600; font-size: clamp(2.2rem, 1rem + 6vw, 4.6rem); letter-spacing: -.03em; color: var(--roxo); }
.palavra-livro--nos { color: var(--lavanda); font-style: italic; font-weight: 500; }
.intro.rodando .folha { animation: virar 1.25s var(--d) cubic-bezier(.5,.08,.25,1) forwards; }
@keyframes virar {
  0% { transform: rotateY(0) skewY(0); }
  45% { transform: rotateY(-95deg) skewY(-2deg); }
  100% { transform: rotateY(-180deg) skewY(0); }
}
.intro.reduzido .abertura-livro { display: none; }
