/* Página de entrega dos e-books: mobile-first, uma identidade por produto (paletas de backend/entrega/paletas.py) */

:root {
  --escuro: #060912;
  --escuro2: #1A1F45;
  --acento: #B9B4D8;
  --acento2: #8E9BF0;
  --ouro: #D9B872;
  --ouro-claro: #EBD49E;
  --texto: #F2EEE4;
  --nevoa: #B8B3C9;
  --linha: rgba(242, 238, 228, 0.14);
  --vidro: rgba(242, 238, 228, 0.06);
  --vidro-borda: rgba(242, 238, 228, 0.16);
  --erro: #EBA38C;
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --suave: cubic-bezier(0.22, 0.7, 0.2, 1);
}

/* uma cor de assinatura por produto (a cliente reconhece "o meu" e-book pela cor) */
body[data-produto="perfil-dominante"] { --escuro: #0B0F2A; --escuro2: #262D6B; --acento: #A9B4F5; --acento2: #8E9BF0; --nevoa: #C9C6E0; --texto: #F4F1FA; }
body[data-produto="mapa-completo"]    { --escuro: #0E1533; --escuro2: #22306A; --acento: #A9C1EA; --acento2: #7E9CC4; --nevoa: #A9B1D6; --texto: #F2EEE4; }
body[data-produto="sinastria"]        { --escuro: #070812; --escuro2: #3A1830; --acento: #E3A6A1; --acento2: #C2566C; --nevoa: #B9A9C4; --texto: #F4EDE4; }
body[data-produto="revolucao-solar"]  { --escuro: #0E0B1A; --escuro2: #3A2340; --acento: #F3C77A; --acento2: #F0A43A; --nevoa: #AE9FC6; --texto: #F7EFE1; }
body[data-produto="revolucao-lunar"]  { --escuro: #060912; --escuro2: #1A2A48; --acento: #DCE3EC; --acento2: #A9CBD3; --nevoa: #9BA6B8; --texto: #EEE9E1; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--escuro);
  background-image:
    radial-gradient(120% 70% at 50% 30%, color-mix(in srgb, var(--escuro2) 85%, transparent) 0%, transparent 70%),
    linear-gradient(180deg, var(--escuro) 0%, var(--escuro) 100%);
  color: var(--texto);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 600ms ease;
}
img { max-width: 100%; display: block; }
p { margin: 0; }
a { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- céu de fundo ---------- */
.ceu { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.ceu svg { width: 100%; height: 100%; }
.ceu .pisca { animation: piscar 4.5s ease-in-out infinite; }
@keyframes piscar { 0%, 100% { opacity: .25; } 50% { opacity: .9; } }

/* ---------- topo / rodapé ---------- */
.topo { padding: 18px 16px 4px; display: flex; justify-content: center; }
.marca { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.marca img { width: 36px; height: 36px; }
.marca span { font-family: var(--serif); font-weight: 500; font-size: 18px; letter-spacing: .01em; color: var(--ouro); }
.rodape { padding: 28px 16px 30px; text-align: center; font-size: 12.5px; color: color-mix(in srgb, var(--nevoa) 70%, transparent); }

/* ---------- telas ---------- */
.palco { flex: 1; width: 100%; max-width: 520px; margin: 0 auto; padding: 8px 16px 0; }
.tela { display: none; text-align: center; }
body[data-estado="carregando"] .tela-carregando,
body[data-estado="aguardando"] .tela-criacao,
body[data-estado="gerando"] .tela-criacao,
body[data-estado="pronto"] .tela-pronto,
body[data-estado="falhou"] .tela-falhou,
body[data-estado="central"] .tela-central { display: block; animation: entrar 420ms var(--suave) both; }
@keyframes entrar { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(25px, 7vw, 32px);
  line-height: 1.18;
  letter-spacing: -0.01em;
  margin: 6px auto 10px;
  max-width: 19ch;
  text-wrap: balance;
}
h1:focus { outline: none; }
h1 em { font-style: italic; color: var(--ouro); }
.rotulo { font-size: 11.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--acento); margin-top: 10px; }
.apoio { color: var(--nevoa); font-size: 15.5px; max-width: 34ch; margin: 0 auto; text-wrap: pretty; }
.suave { color: var(--nevoa); font-size: 14px; margin-top: 14px; }
.mini { font-size: 12.5px; margin-top: 10px; }

/* ---------- carregando ---------- */
.tela-carregando { padding-top: 30vh; }
.pontinhos { display: inline-flex; gap: 8px; }
.pontinhos i { width: 8px; height: 8px; border-radius: 50%; background: var(--ouro); animation: ponto 1.2s ease-in-out infinite; }
.pontinhos i:nth-child(2) { animation-delay: .15s; }
.pontinhos i:nth-child(3) { animation-delay: .3s; }
@keyframes ponto { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-4px); } }

/* ---------- janela da criação ---------- */
.janela {
  position: relative;
  width: min(78vw, 300px);
  aspect-ratio: 1;
  margin: 18px auto 0;
}
.janela::before { /* halo atrás da janela, na cor do produto */
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--acento2) 32%, transparent) 0%, transparent 70%);
  filter: blur(18px);
  opacity: .7;
}
.cena { position: relative; width: 100%; height: 100%; display: block; overflow: visible; }
.cena .cena-camada { transition: opacity 700ms ease; }

.leitura-progresso { margin-top: 10px; height: 46px; transition: opacity 300ms ease; }
body[data-estado="aguardando"] .leitura-progresso,
body[data-estado="aguardando"] .etapa,
body[data-estado="aguardando"] .micro { display: none; }
body[data-estado="aguardando"] .nota-envio { margin-top: 28px; }
.pct { font-family: var(--serif); font-weight: 500; font-size: 40px; line-height: 1; font-variant-numeric: tabular-nums; color: var(--texto); }
.pct small { font-size: 20px; margin-left: 2px; color: var(--ouro); }

.etapa { font-weight: 600; font-size: 15.5px; color: var(--texto); margin-top: 8px; min-height: 1.5em; }
.micro {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--acento);
  min-height: 3em;
  max-width: 30ch;
  margin: 6px auto 0;
  transition: opacity 450ms ease, transform 450ms var(--suave);
  text-wrap: balance;
}
.micro.trocando { opacity: 0; transform: translateY(4px); }

.aviso-lento {
  margin: 14px auto 0;
  max-width: 34ch;
  font-size: 14px;
  color: var(--texto);
  background: var(--vidro);
  border: 1px solid var(--vidro-borda);
  border-radius: 12px;
  padding: 10px 14px;
}

.nota-envio {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  text-align: left;
  max-width: 36ch;
  margin: 22px auto 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--vidro);
  border: 1px solid var(--vidro-borda);
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--nevoa);
}
.nota-envio svg { flex: none; width: 20px; height: 20px; color: var(--ouro); margin-top: 1px; }

/* ---------- pronto ---------- */
.tela-pronto { padding-top: 6px; }
.capa {
  position: relative;
  width: min(52vw, 210px);
  aspect-ratio: 1082 / 1921;
  margin: 10px auto 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 24px 60px -18px rgba(0, 0, 0, .75), 0 0 0 1px rgba(217, 184, 114, .35), 0 0 48px -6px color-mix(in srgb, var(--acento2) 45%, transparent);
  background: var(--escuro2);
}
.capa img { width: 100%; height: 100%; object-fit: cover; }
.capa-brilho {
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 244, 214, .55) 48%, transparent 64%);
  transform: translateX(-120%);
}
.capa.sem-imagem img { display: none; }
.capa.sem-imagem { display: grid; place-items: center; }
.capa.sem-imagem::after { content: ""; width: 40%; aspect-ratio: 1; background: url("assets/logo-dourado.svg") center / contain no-repeat; opacity: .9; }

.pronto-texto > * { opacity: 0; }
.revelada .capa { animation: revelar-capa 1100ms var(--suave) both; }
.revelada .capa-brilho { animation: brilho 1300ms ease-in-out 700ms both; }
.revelada .pronto-texto > * { animation: subir 560ms var(--suave) both; }
.revelada .pronto-texto > *:nth-child(1) { animation-delay: 520ms; }
.revelada .pronto-texto > *:nth-child(2) { animation-delay: 620ms; }
.revelada .pronto-texto > *:nth-child(3) { animation-delay: 740ms; }
.revelada .pronto-texto > *:nth-child(4) { animation-delay: 860ms; }
.revelada .pronto-texto > *:nth-child(5) { animation-delay: 940ms; }
@keyframes revelar-capa {
  0% { opacity: 0; transform: translateY(26px) scale(.9) rotate(-2deg); filter: blur(10px) brightness(1.8); }
  60% { opacity: 1; filter: blur(0) brightness(1.15); }
  100% { opacity: 1; transform: none; filter: none; }
}
@keyframes brilho { to { transform: translateX(120%); } }
@keyframes subir { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.tela-pronto h1 { margin-top: 22px; }
.botao {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 360px;
  min-height: 58px;
  margin: 20px auto 0;
  padding: 14px 20px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--ouro-claro) 0%, var(--ouro) 100%);
  color: #1D1626;
  font: 700 16.5px/1.2 var(--sans);
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 10px 28px -10px rgba(217, 184, 114, .7), inset 0 1px 0 rgba(255, 255, 255, .5);
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
  -webkit-tap-highlight-color: transparent;
}
.botao svg { width: 22px; height: 22px; }
.botao:hover { filter: brightness(1.05); }
.botao:active { transform: scale(.98); }
.botao:focus-visible { outline: 3px solid var(--acento); outline-offset: 3px; }
.botao[aria-disabled="true"], .botao:disabled { filter: saturate(.4) brightness(.8); cursor: progress; }
.dica { margin-top: 12px; font-size: 13.5px; color: var(--nevoa); }

/* ---------- falhou ---------- */
.tela-falhou { padding-top: 10vh; }
.selo-cuidado { width: 110px; margin: 0 auto 10px; color: var(--ouro); }
.selo-cuidado svg { width: 100%; }
.selo-cuidado path { transform-origin: 60px 60px; animation: respirar 4s ease-in-out infinite; }
@keyframes respirar { 0%, 100% { transform: scale(.92); opacity: .75; } 50% { transform: scale(1.04); opacity: 1; } }
.tela-falhou .apoio { margin-top: 4px; }

/* ---------- central ---------- */
.tela-central { padding-top: 10px; }
.aviso-topo {
  margin: 4px auto 14px;
  max-width: 36ch;
  font-size: 14px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(235, 163, 140, .1);
  border: 1px solid rgba(235, 163, 140, .35);
  color: var(--texto);
}
.busca {
  text-align: left;
  margin: 22px auto 0;
  max-width: 400px;
  padding: 20px 18px 18px;
  border-radius: 18px;
  background: var(--vidro);
  border: 1px solid var(--vidro-borda);
}
.busca label { display: block; font-size: 13.5px; font-weight: 600; margin: 0 0 6px; }
.busca input + .erro-campo + label, .busca input + label { margin-top: 14px; }
.busca input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--vidro-borda);
  background: rgba(6, 9, 18, .55);
  color: var(--texto);
  font: 500 16px/1.2 var(--sans);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.busca input::placeholder { color: color-mix(in srgb, var(--nevoa) 60%, transparent); }
.busca input:focus { outline: none; border-color: var(--ouro); box-shadow: 0 0 0 3px rgba(217, 184, 114, .22); }
.busca input[aria-invalid="true"] { border-color: var(--erro); }
.erro-campo { color: var(--erro); font-size: 13px; margin-top: 6px; }
.busca .botao { margin-top: 20px; max-width: none; }
.busca .mini { text-align: center; }

.resultado { margin: 20px auto 0; max-width: 400px; text-align: left; }
.resultado .vazio { text-align: center; padding: 16px 14px; border-radius: 14px; background: var(--vidro); border: 1px solid var(--vidro-borda); color: var(--nevoa); font-size: 14.5px; }
.resultado .vazio strong { display: block; color: var(--texto); font-family: var(--serif); font-weight: 500; font-size: 18px; margin-bottom: 6px; }
.resultado h2 { font-family: var(--serif); font-weight: 500; font-size: 20px; margin: 0 0 12px; text-align: center; }
.livro {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border-radius: 16px;
  background: var(--vidro);
  border: 1px solid var(--vidro-borda);
  margin-bottom: 12px;
  animation: subir 420ms var(--suave) both;
}
.livro-capa { width: 64px; aspect-ratio: 1082 / 1921; border-radius: 5px; overflow: hidden; background: var(--escuro2); box-shadow: 0 6px 16px -6px rgba(0, 0, 0, .7), 0 0 0 1px rgba(217, 184, 114, .3); }
.livro-capa img { width: 100%; height: 100%; object-fit: cover; }
.livro h3 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 17px; line-height: 1.25; }
.livro .quando { font-size: 12.5px; color: var(--nevoa); margin-top: 2px; }
.livro .botao { min-height: 44px; margin: 10px 0 0; padding: 10px 16px; font-size: 14.5px; width: auto; display: inline-flex; }
.livro .botao svg { width: 18px; height: 18px; }
.livro .preparando { font-size: 13px; color: var(--acento); margin-top: 8px; }

/* vidro de verdade: as estrelas do fundo não atravessam os cartões */
.nota-envio, .busca, .livro, .resultado .vazio, .aviso-lento {
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

/* ---------- movimento reduzido: tira deslocamento, mantém fades e o progresso ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .ceu .pisca, .pontinhos i, .selo-cuidado path { animation: none !important; }
  .pontinhos i { opacity: .7; }
  body[data-estado] .tela { animation: so-fade 180ms ease both !important; }
  .revelada .capa { animation: so-fade 200ms ease both !important; }
  .revelada .capa-brilho { animation: none !important; }
  .revelada .pronto-texto > * { animation: so-fade 200ms ease both !important; animation-delay: 0ms !important; }
  .livro { animation: so-fade 180ms ease both; }
  .micro { transition: opacity 180ms ease; }
  .micro.trocando { transform: none; }
}
@keyframes so-fade { from { opacity: 0; } to { opacity: 1; } }

@media (min-width: 720px) {
  .palco { padding-top: 24px; }
  .janela { width: 320px; }
}
