/*
 * Abertura (20/10): a tela lilás do respiro é a primeira pintura do app.
 * Fica no index.html, só com HTML e CSS, e aparece antes de qualquer
 * JavaScript; o app carrega por trás dela (src/core/app/abertura.ts).
 * O halo nasce na base do celular, onde estão as mãos e o peito de quem
 * segura, e respira num ciclo calmo: inspira em 2,4 s, expira em 3,2 s.
 * Ao concluir, a última respiração cresce de baixo para cima e revela a tela.
 */
#abertura {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(180deg, #B9A6D6 0%, #8C74BD 55%, #6B4FA0 100%);
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}
/* Das 22h às 6h: ameixa, para não acender a tela de madrugada. */
html.abertura-noite #abertura {
  background: linear-gradient(180deg, #4A3460 0%, #3A2850 50%, #2A1C3B 100%);
}

.abertura-frase {
  position: relative;
  z-index: 2;
  margin: 0;
  padding: 0 24px;
  text-align: center;
  color: #FFFFFF;
  font-family: "Fraunces", Georgia, "Times New Roman", serif;
  /* 23/10 (Rodada 6): "Você não está sozinha." quebrava em duas linhas no
     iPhone 15 (três no total). Duas linhas sempre: a segunda não quebra, e a
     letra diminui um pouco nas telas estreitas para caber. */
  font-size: min(23px, 6.4vw);
  line-height: 1.35;
  font-weight: 400;
  text-shadow: 0 1px 10px rgba(50, 25, 85, 0.22);
  opacity: 0;
  transition: opacity 0.6s ease-out;
}
html.abertura-fonte .abertura-frase { opacity: 1; }
.abertura-frase > span {
  display: inline-block;
  animation: abertura-frase 5.6s ease-in-out 0.6s infinite;
}
@keyframes abertura-frase {
  0%, 100% { opacity: 0.86; }
  43% { opacity: 1; }
}

/* O halo: centro na borda de baixo; cresce para cima ao inspirar. */
.halo-base {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(150vw, 640px);
  aspect-ratio: 1;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.46) 0%, rgba(255, 255, 255, 0.2) 38%, rgba(255, 255, 255, 0) 66%);
  transform: translate(-50%, 50%) scale(0.62);
  animation: abertura-respira 5.6s ease-in-out infinite;
  will-change: transform, opacity;
}
html.abertura-noite #abertura .halo-base {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.12) 38%, rgba(255, 255, 255, 0) 66%);
}
@keyframes abertura-respira {
  0% { transform: translate(-50%, 50%) scale(0.62); opacity: 0.5; }
  43% { transform: translate(-50%, 50%) scale(1.06); opacity: 1; }
  100% { transform: translate(-50%, 50%) scale(0.62); opacity: 0.5; }
}
@keyframes abertura-luz {
  0%, 100% { opacity: 0.35; }
  43% { opacity: 0.9; }
}

/* Revelação: um círculo que cresce da base (raio em --r, animado pelo app). */
#abertura.revelando {
  pointer-events: none;
  -webkit-mask-image: radial-gradient(circle at 50% 100%, transparent 0, transparent var(--r, 0px), #000 calc(var(--r, 0px) + 60px));
  mask-image: radial-gradient(circle at 50% 100%, transparent 0, transparent var(--r, 0px), #000 calc(var(--r, 0px) + 60px));
}
#abertura.revelando .abertura-frase { transition: opacity 0.25s ease-out; opacity: 0; }
#abertura.saindo { pointer-events: none; opacity: 0; transition: opacity 0.45s ease; }

/* A mesma respiração, mais discreta, sobre a paisagem (Splash do app). */
.abertura-surge {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  animation: abertura-surge 0.6s ease-out both;
}
@keyframes abertura-surge { from { opacity: 0; } to { opacity: 1; } }
.halo-base.na-paisagem {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.34) 0%, rgba(255, 255, 255, 0.12) 40%, rgba(255, 255, 255, 0) 66%);
}
.halo-base.na-paisagem.sobre-claro {
  background: radial-gradient(circle, rgba(107, 79, 160, 0.22) 0%, rgba(107, 79, 160, 0.08) 40%, rgba(107, 79, 160, 0) 66%);
}

@media (prefers-reduced-motion: reduce) {
  .halo-base { animation-name: abertura-luz; }
  .abertura-frase > span { animation: none; }
}
