/*
 * Splash screen de abertura (mesma animação do portal SPA). Carregada pela view auth.login só quando o splash é exibido (painel iMais e ambiente local).
 * Linha do tempo (~6,5 s): pingo e letras se desenhando (0,2–1,7 s) → "+" girando e brilho (1,5–2,8 s)
 * → "mais+" volta e entra no "i" (2,85–3,8 s) → o "i" vai ao centro, a haste recolhe no pingo,
 * que quica e estoura em faíscas (3,95–5,4 s) → tela branca → fade do branco para o login (5,6–6,5 s).
 *
 * Classes no <html> (colocadas por um script no <head> da view):
 *  - splash-on: o splash está sendo exibido nesta aba
 *  - splash-behind: o login por baixo ainda não é desenhado (fundo e cartão), para não disputar a CPU
 *  - splash-reduced: o sistema pede movimento reduzido (mostra só o logo parado)
 */
html:not(.splash-on) .splash { display: none; }
html.splash-behind #login-container,
html.splash-behind #fade-transition { visibility: hidden; }

/*
 * Fundo do login (mesma imagem e enquadramento do login.css) numa camada própria, em vez do <body>.
 * Fundo no <body> vira o fundo da página inteira, e o navegador decodificava a imagem de novo ao
 * revelá-lo: ~2 s de tela parada no meio do fade. Numa camada própria, aproveita a imagem pré-carregada.
 * Este arquivo só é carregado na view de teste (auth.login-splash); a rota "/" não muda.
 */
body { background-image: none; }
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2; /* atrás do #fade-transition (-1), como o fundo original */
  background: url('../../infografico2.webp') center / cover no-repeat;
}
html.splash-behind body::before { visibility: hidden; }

.splash {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: #fff;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* o branco esmaece devagar até o login */
.splash--out { animation: splash-out .9s cubic-bezier(.4, 0, .2, 1) forwards; }
@keyframes splash-out { to { opacity: 0; visibility: hidden; } }

/* tamanho do logo: 62% da largura da tela (celular), limitado a 460px (desktop) */
.splash__stage { position: relative; width: min(62vw, 460px); }
.splash__logo { width: 100%; }
.splash__logo svg { display: block; width: 100%; height: auto; overflow: visible; }

/* Letras se desenhando (atraso e duração de cada traço estão no HTML) */
.splash__draw { stroke-dasharray: 1 1.02; stroke-dashoffset: 1; opacity: 0; animation: splash-draw .59s cubic-bezier(.65, 0, .35, 1) forwards; }
/* a ponta arredondada desenharia um ponto antes do traço: fica invisível até começar */
@keyframes splash-draw { 0% { stroke-dashoffset: 1; opacity: 0; } 6% { opacity: 1; } 100% { stroke-dashoffset: 0; opacity: 1; } }

/* Pingo do "i" */
.splash__dot { transform-box: fill-box; transform-origin: center; transform: scale(0); animation: splash-pop .52s cubic-bezier(.34, 1.8, .5, 1) .22s forwards; }
@keyframes splash-pop { to { transform: scale(1); } }

/* "+" entra girando com um clarão */
.splash__plus { transform-box: fill-box; transform-origin: center; transform: scale(0) rotate(-180deg); animation: splash-plus .88s cubic-bezier(.34, 1.56, .5, 1) 1.52s forwards; }
@keyframes splash-plus { to { transform: scale(1) rotate(0deg); } }
.splash__flare { opacity: 0; transform-box: fill-box; transform-origin: center; animation: splash-flare 1.1s ease-out 1.69s forwards; }
@keyframes splash-flare { 0% { opacity: 0; transform: scale(.3); } 35% { opacity: 1; } 100% { opacity: 0; transform: scale(2.4); } }

/* Brilho atravessando o logo */
.splash__shine-band { transform: translateX(0); animation: splash-shine .88s ease-in-out 1.87s forwards; }
@keyframes splash-shine { to { transform: translateX(620px); } }
/* terminado o brilho, sai de cena (não precisa mais ser redesenhado) */
.splash__shine-layer { animation: splash-hide .01s linear 2.8s forwards; }
@keyframes splash-hide { to { visibility: hidden; } }

/* "mais+" volta e entra no "i", uma letra após a outra (atrasos no HTML) */
.splash__suck {
  transform-box: fill-box;
  transform-origin: center;
  animation: splash-suck .65s cubic-bezier(.55, 0, .85, .35) forwards;
}
@keyframes splash-suck {
  0% { transform: translate(0, 0) scale(1); }
  15% { transform: translate(6px, 0) scale(1.04); } /* pequeno recuo antes de ser puxada */
  85% { opacity: 1; }
  /* termina inteira à esquerda do meio da haste: o recorte esconde, nada fica sobrando ao lado do "i" */
  100% { transform: translate(var(--dx), var(--dy)) scale(.35); opacity: 0; }
}
/* o "i" reage ao "engolir" as letras */
.splash__igroup { transform-box: fill-box; transform-origin: 50% 100%; animation: splash-gulp .5s ease-in-out 3.45s; }
@keyframes splash-gulp { 0%, 100% { transform: scale(1); } 45% { transform: scale(1.12, 1.06); } }

/* ---- Final: o "i" some com um estouro ---- */
/* sozinho, o "i" desliza para o centro da tela enquanto a haste recolhe */
.splash__icenter { transform-box: view-box; animation: splash-icenter .55s cubic-bezier(.65, 0, .35, 1) 3.95s forwards; }
@keyframes splash-icenter { to { transform: translate(189px, 11.5px); } }
.splash__istem {
  animation: splash-draw .59s cubic-bezier(.65, 0, .35, 1) .41s forwards,
    splash-retract .38s cubic-bezier(.6, 0, .8, .4) 4.02s forwards;
}
@keyframes splash-retract { from { stroke-dashoffset: 0; opacity: 1; } 88% { opacity: 1; } to { stroke-dashoffset: 1; opacity: 0; } }
/* o pingo amassa, salta, incha e estoura */
.splash__dot {
  animation: splash-pop .52s cubic-bezier(.34, 1.8, .5, 1) .22s forwards,
    splash-dot-vanish .5s cubic-bezier(.45, 0, .55, 1) 4.4s forwards;
}
@keyframes splash-dot-vanish {
  0% { transform: scale(1); opacity: 1; }
  30% { transform: translateY(2px) scale(1.32, .7); }
  55% { transform: translateY(-9px) scale(.8, 1.24); }
  72% { transform: translateY(-6px) scale(1.55); opacity: 1; }
  100% { transform: translateY(-6px) scale(0); opacity: 0; }
}
.splash__burst-glow, .splash__ring, .splash__spark { transform-box: fill-box; transform-origin: center; opacity: 0; }
.splash__burst-glow { animation: splash-burst-glow .6s ease-out 4.72s forwards; }
@keyframes splash-burst-glow { 0% { opacity: 0; transform: scale(.2); } 25% { opacity: 1; } 100% { opacity: 0; transform: scale(3); } }
.splash__ring { --s: 9; animation: splash-ring .75s cubic-bezier(.2, .7, .3, 1) 4.74s forwards; }
.splash__ring--2 { --s: 6.5; animation-delay: 4.83s; }
@keyframes splash-ring { 0% { opacity: .95; transform: scale(.5); } 100% { opacity: 0; transform: scale(var(--s)); } }
.splash__spark { animation: splash-spark .8s cubic-bezier(.15, .75, .3, 1) forwards; }
@keyframes splash-spark {
  0% { opacity: 0; transform: translate(0, 0) scale(1.2); }
  12% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(0); }
}

/* Movimento reduzido: só o logo parado */
.splash-reduced .splash__draw { stroke-dashoffset: 0; opacity: 1; animation: none; }
.splash-reduced .splash__dot, .splash-reduced .splash__plus { transform: none; animation: none; }
.splash-reduced .splash__suck, .splash-reduced .splash__igroup, .splash-reduced .splash__icenter,
.splash-reduced .splash__shine-band, .splash-reduced .splash__flare { animation: none; }
.splash-reduced .splash__burst { display: none; }
