/* ==========================================================================
   Zapbot — blocos que permanecem escuros por decisão de design.
   O tema (claro/escuro) vive em app-ui.css. Aqui ficam só o preloader e o
   painel ilustrado do portão: são AMBIENTE de marca, não interface. Um
   painel de produto pode seguir a preferência da pessoa; a ilustração que
   representa o produto, não — ela é a mesma sempre, como o hero da landing.
   ========================================================================== */

/* ==========================================================================
   Preloader
   Mesmo gesto da landing (letras com shimmer, cortina subindo com a borda
   curvando), reproduzido em CSS puro. A landing usa GSAP porque o tema já
   carrega; aqui importar GSAP + jQuery custaria ~700KB numa tela de login.

   Ele não é decorativo: cobre a espera real do boot(), que valida o token
   e decide entre portão e painel. Sem isso a tela pisca entre estados.
   ========================================================================== */
.preloader {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--zap-surface-0);
  transition: transform 0.7s cubic-bezier(0.65, 0, 0.35, 1),
    border-radius 0.7s cubic-bezier(0.65, 0, 0.35, 1);
}

/* Saída: a borda inferior curva enquanto a cortina sobe — mesmo efeito
   elástico que o morph do path faz na landing, sem depender de SVG. */
.preloader.is-out {
  transform: translateY(-100%);
  border-radius: 0 0 50% 50% / 0 0 14vh 14vh;
}
.preloader.is-gone {
  display: none;
}

.preloader__text {
  display: flex;
  font-family: var(--zap-display);
  font-size: 100px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #fff;
  transition: transform 0.4s ease, opacity 0.4s ease;
}
.preloader.is-out .preloader__text {
  transform: translateY(-100px);
  opacity: 0;
}

/* O shimmer: cada letra pisca 1s alternando, defasada em 0.1s.
   Valores copiados do tema para o gesto ser o mesmo. */
.preloader__text span {
  animation: zap-loading 1s infinite alternate;
}
.preloader__text span:nth-child(1) { animation-delay: 0s; }
.preloader__text span:nth-child(2) { animation-delay: 0.1s; }
.preloader__text span:nth-child(3) { animation-delay: 0.2s; }
.preloader__text span:nth-child(4) { animation-delay: 0.3s; }
.preloader__text span:nth-child(5) { animation-delay: 0.4s; }
.preloader__text span:nth-child(6) { animation-delay: 0.5s; }

@keyframes zap-loading {
  0% { opacity: 1; }
  100% { opacity: 0.15; }
}

@media (max-width: 767px) {
  .preloader__text {
    font-size: 50px;
  }
}

/* Quem pede menos movimento não precisa esperar a coreografia. */
@media (prefers-reduced-motion: reduce) {
  .preloader__text span {
    animation: none;
  }
  .preloader {
    transition-duration: 0.001ms;
  }
}

/* Lado esquerdo: mesmo ambiente verde-terminal do hero da landing.
   Como ele é escuro SEMPRE, a cor do texto precisa ser explícita: herdar
   do body faria o título virar quase preto no tema claro — escuro sobre
   escuro, invisível. */
.auth-aside {
  color: var(--zap-text-dark);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--zap-6);
  padding: var(--zap-8) clamp(32px, 6vw, 88px);
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 15% 10%, rgba(37, 211, 102, 0.14), transparent 60%),
    linear-gradient(160deg, #0a1a10 0%, #07100c 60%);
  border-right: 1px solid var(--zap-line-dark);
}
/* Grade sutil: textura de terminal, não papel de parede. */
.auth-aside::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--zap-line-dark) 1px, transparent 1px),
    linear-gradient(90deg, var(--zap-line-dark) 1px, transparent 1px);
  background-size: 64px 64px;
  opacity: 0.5;
  mask-image: radial-gradient(80% 70% at 30% 30%, #000 30%, transparent 80%);
  pointer-events: none;
}
.auth-aside > * {
  position: relative;
}
/* Sem a marca aqui (ela vive no cartão à direita), o título é o primeiro
   elemento e não precisa da margem que o separava do logo. */
.auth-aside h2 {
  font-family: var(--zap-display);
  font-size: clamp(26px, 2.4vw, 34px);
  line-height: 1.18;
  letter-spacing: -0.02em;
  margin: 0 0 var(--zap-3);
  max-width: 16ch;
}
.auth-aside p {
  margin: 0;
  color: var(--zap-muted-dark);
  max-width: 42ch;
}

/* --------------------------------------------------------------------------
   Cenas — uma por aba. Empilhadas no mesmo lugar: a troca deve ler como o
   painel se reconfigurando, não como dois slides de carrossel passando.
   -------------------------------------------------------------------------- */
.auth-aside {
  display: grid;
}
.auth-aside .scene {
  grid-area: 1 / 1;
  align-self: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px);
  transition: opacity 0.42s ease, transform 0.42s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0s linear 0.42s;
}
.auth-aside .scene.is-active {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s, 0s, 0s;
}

/* Cada filho entra escalonado, para a cena montar em vez de aparecer. */
.scene.is-active > * {
  animation: scene-in 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.scene.is-active > *:nth-child(1) { animation-delay: 0.05s; }
.scene.is-active > *:nth-child(2) { animation-delay: 0.12s; }
.scene.is-active > *:nth-child(3) { animation-delay: 0.19s; }
@keyframes scene-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* Os dois cartões ocupam o MESMO lugar, um por cena. Margem e largura
   precisam bater: se divergirem, o painel salta ao trocar de aba em vez
   de se reconfigurar no lugar. O parágrafo acima tem margin 0, daí os
   20px; `auto` nas laterais centraliza na coluna. */
.auth-preview,
.stage {
  width: 100%;
  max-width: 380px;
  margin: 20px auto 0;
}

/* Prévia do painel: mostra o que existe do outro lado da porta. */
.auth-preview {
  border-radius: var(--zap-r-lg);
  background: var(--zap-surface-1);
  border: 1px solid var(--zap-line-dark);
  box-shadow: 0 30px 80px -40px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}
.auth-preview__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px var(--zap-4);
  background: var(--zap-surface-2);
  border-bottom: 1px solid var(--zap-line-dark);
  font-size: 13px;
  font-weight: 600;
}
.auth-preview__head span {
  font-family: var(--zap-mono);
  font-size: 11px;
  font-weight: 400;
  color: var(--zap-muted-dark);
}
.auth-preview__row {
  display: flex;
  align-items: center;
  gap: var(--zap-3);
  padding: 12px var(--zap-4);
  border-bottom: 1px solid var(--zap-line-dark);
  font-family: var(--zap-mono);
  font-size: 12.5px;
}
.auth-preview__row:last-child {
  border-bottom: 0;
}
.auth-preview__row em {
  margin-left: auto;
  font-style: normal;
  font-family: var(--zap-sans);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--zap-green);
  background: rgba(37, 211, 102, 0.1);
}
.auth-preview__row.is-pairing em {
  color: var(--zap-amber);
  background: rgba(245, 165, 36, 0.12);
}
.auth-preview__row.is-pairing .zap-dot {
  background: var(--zap-amber);
}

/* Idem para os elementos internos que herdavam do body. */
.auth-aside h2,
.auth-preview__head,
.auth-preview__row,
.beat__label,
.stage .wire code {
  color: var(--zap-text-dark);
}
.auth-preview__head span,
.beat__label {
  color: var(--zap-muted-dark);
}
.auth-preview__head { color: var(--zap-text-dark); }
.stage .wire code { color: var(--zap-green); }
.bubble { color: var(--zap-ink); }


/* --------------------------------------------------------------------------
   Cena 2 — o ritual: parear → conectar → enviar
   Os três tempos ocupam o mesmo palco, um de cada vez.
   -------------------------------------------------------------------------- */
/* Largura e margem vêm da regra compartilhada com .auth-preview. */
.stage {
  position: relative;
  min-height: 300px;
  padding: var(--zap-5);
  border-radius: var(--zap-r-lg);
  background: var(--zap-surface-1);
  border: 1px solid var(--zap-line-dark);
  box-shadow: 0 30px 80px -40px rgba(0, 0, 0, 0.8);
}

.beat {
  position: absolute;
  /* Insets simétricos: os 52px de baixo reservam espaço para os
     indicadores, então o topo precisa dos mesmos 52px — senão o conteúdo
     centraliza num box deslocado e fica acima do centro real do cartão. */
  inset: 52px var(--zap-5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--zap-4);
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  /* Sai rápido (0.2s); entra depois de uma pausa (0.16s). Com tempos
     iguais os dois ficam meio-visíveis no mesmo box e a cena embola. */
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
.beat.is-on {
  opacity: 1;
  transform: none;
  transition: opacity 0.32s ease 0.16s,
    transform 0.38s cubic-bezier(0.4, 0, 0.2, 1) 0.16s;
}
.beat__label {
  font-size: 13px;
  color: var(--zap-muted-dark);
  text-align: center;
}

/* --- Tempo 1: o QR sendo lido ------------------------------------------ */
/* Fundo branco de propósito: leitor de QR precisa de contraste real, e a
   moldura clara é o que a pessoa vai ver de verdade no painel. */
.qr {
  position: relative;
  width: 132px;
  height: 132px;
  padding: 10px;
  border-radius: var(--zap-r-md);
  background: #fff;
  overflow: hidden;
}
/* O desenho vem do SVG inline: três olhos localizadores, alinhamento e
   módulos irregulares. Gradiente listrado lia como grade, não como QR. */
.qr__code {
  position: relative;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.qr__scan {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 36%;
  z-index: 2;
  background: linear-gradient(180deg, transparent, rgba(37, 211, 102, 0.55));
  border-bottom: 2px solid var(--zap-green);
  animation: qr-scan 1.8s ease-in-out infinite;
}
@keyframes qr-scan {
  0%, 100% { transform: translateY(-30%); }
  50% { transform: translateY(190%); }
}

/* --- Tempo 2: conectou ------------------------------------------------- */
.ok-ring {
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 32px;
  color: var(--zap-ink);
  background: var(--zap-green);
  position: relative;
}
.beat--ok.is-on .ok-ring {
  animation: ok-pop 0.42s cubic-bezier(0.34, 1.2, 0.64, 1) both;
}
/* Onda que sai do check: o eco de "entrou no ar". */
.beat--ok.is-on .ok-ring::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--zap-green);
  animation: ok-wave 1.6s ease-out infinite;
}
@keyframes ok-pop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes ok-wave {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.9); opacity: 0; }
}

/* --- Tempo 3: a mensagem sai ------------------------------------------- */
.wire {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--zap-4);
}
.wire code {
  font-family: var(--zap-mono);
  font-size: 12px;
  padding: 6px 11px;
  border-radius: 7px;
  color: var(--zap-green);
  background: rgba(37, 211, 102, 0.08);
  border: 1px solid var(--zap-line-dark);
}
.beat--send.is-on .wire code {
  animation: scene-in 0.36s ease both;
}
/* O balão sai do canto e assenta à direita, como no aparelho. */
.bubble {
  position: relative;
  align-self: flex-end;
  max-width: 84%;
  padding: 9px 14px 9px 13px;
  border-radius: 12px 12px 3px 12px;
  font-size: 13.5px;
  color: var(--zap-ink);
  background: var(--zap-green);
}
.bubble i {
  font-style: normal;
  margin-left: 8px;
  font-size: 11px;
  letter-spacing: -2px;
  opacity: 0;
}
.beat--send.is-on .bubble {
  animation: bubble-in 0.44s cubic-bezier(0.34, 1.15, 0.64, 1) 0.28s both;
}
/* O check duplo só aparece depois que o balão assenta — a ordem importa:
   primeiro sai, depois confirma. */
.beat--send.is-on .bubble i {
  animation: tick-in 0.3s ease 0.95s both;
}
@keyframes bubble-in {
  from { opacity: 0; transform: translate(18px, 10px) scale(0.94); }
  to { opacity: 1; transform: none; }
}
@keyframes tick-in {
  from { opacity: 0; }
  to { opacity: 0.75; }
}

/* --- Indicador de etapa, clicável -------------------------------------- */
.beats-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--zap-5);
  display: flex;
  justify-content: center;
  gap: 6px;
}
.beats-nav button {
  width: 20px;
  height: 3px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: background 0.24s ease, width 0.24s ease;
}
.beats-nav button:hover {
  background: rgba(255, 255, 255, 0.28);
}
.beats-nav button.is-on {
  width: 28px;
  background: var(--zap-green);
}

@media (prefers-reduced-motion: reduce) {
  .qr__scan,
  .beat--ok.is-on .ok-ring::after {
    animation: none;
  }
  .scene.is-active > *,
  .beat--send.is-on .bubble,
  .beat--send.is-on .bubble i,
  .beat--ok.is-on .ok-ring {
    animation: none;
  }
  .bubble i { opacity: 0.75; }
}

