/* ============================================================
   CLART — Abertura do app (logo → "Acessar conta" → PIN → perfil)
   Tema escuro/champanhe definido pelo mockup da abertura.
   Grid de 8px, raio 24px e microinterações 200ms ease-out do
   design system continuam valendo.
   ============================================================ */

.ab-tela {
  --ab-fundo:      #120E0B;
  --ab-folha:      #18130F;
  --ab-texto:      #F5EFE6;
  --ab-sec:        rgba(245,239,230,0.60);
  --ab-champ:      #E9C69A;
  --ab-champ-grad: linear-gradient(90deg, #ECCA9F 0%, #E6C091 100%);
  --ab-borda:      rgba(233,198,154,0.22);
  --ab-tecla:      rgba(245,239,230,0.06);
  --ab-escuro:     #1A1512;
}

body.ab-tela {
  background: var(--ab-fundo); color: var(--ab-texto);
  height: 100%; overflow: hidden; overscroll-behavior: none;
}

/* ---- Fundo: foto (assets/abertura.jpg) com brilho champanhe de reserva ---- */
.ab-fundo {
  position: fixed; inset: 0;
  background:
    linear-gradient(180deg, rgba(18,14,11,0.35) 0%, rgba(18,14,11,0) 25%, rgba(18,14,11,0) 60%, rgba(18,14,11,0.85) 90%),
    url('../assets/abertura.jpg?v=1') center top / cover no-repeat,
    radial-gradient(60% 40% at 100% 20%, rgba(233,198,154,0.28), transparent 70%),
    radial-gradient(50% 35% at 0% 45%, rgba(233,198,154,0.18), transparent 70%),
    var(--ab-fundo);
  opacity: 0;
  transition: opacity 200ms var(--ease);
}
body.ab-inicio-aberto .ab-fundo { opacity: 1; }

/* ---- Marca: centralizada na abertura, depois vai para o topo à esquerda ---- */
.ab-marca {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  animation: ab-fade 200ms var(--ease) 80ms forwards;
  transition: top 200ms var(--ease), left 200ms var(--ease), transform 200ms var(--ease), opacity 200ms var(--ease);
}
body.ab-inicio-aberto .ab-marca {
  top: calc(env(safe-area-inset-top) + 88px); left: 32px;
  transform: translate(0, 0);
}
.ab-marca img { display: block; width: 152px; height: auto; }
.ab-marca .tagline {
  margin-top: 16px; padding-left: 4px;
  font-size: 11px; font-weight: 500; line-height: 16px;
  letter-spacing: 0.32em; text-transform: uppercase;
  color: var(--ab-champ);
}
/* Com uma folha aberta, a marca recua */
body.ab-folha-aberta .ab-marca { opacity: 0.3; }

@keyframes ab-fade { to { opacity: 1; } }

/* ---- Card inicial ---- */
.ab-inicio {
  position: fixed; left: 16px; right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 448px; margin: 0 auto;
  background: rgba(24,19,15,0.72);
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
  border: 1px solid var(--ab-borda);
  border-radius: var(--radius-card);
  padding: 32px 16px 24px;
  opacity: 0; transform: translateY(16px);
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
  pointer-events: none;
}
body.ab-inicio-aberto .ab-inicio { opacity: 1; transform: translateY(0); pointer-events: auto; }
body.ab-folha-aberta .ab-inicio { opacity: 0; pointer-events: none; }

.ab-ola {
  display: inline-flex; align-items: center; gap: 16px;
  margin-left: 16px;
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-size: 24px; font-weight: 400; letter-spacing: -0.01em; color: var(--ab-texto);
}
.ab-ola i { font-size: 20px; color: var(--ab-texto); }

.ab-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; min-height: 56px; margin-top: 32px;
  padding: 8px 8px 8px 40px;
  border: 0; border-radius: 999px;
  background: var(--ab-champ-grad); color: #171717;
  font: inherit; font-size: 16px; font-weight: 500; text-align: left; text-decoration: none;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
}
.ab-btn:active { transform: scale(0.99); opacity: 0.9; }
.ab-btn .seta {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--ab-escuro); color: var(--ab-texto);
}
.ab-btn .seta i { font-size: 20px; }

.ab-btn.sec {
  margin-top: 16px; min-height: 56px;
  padding: 8px 24px 8px 40px;
  background: none; border: 1px solid var(--ab-borda); color: var(--ab-texto);
  font-size: 15px; font-weight: 400;
}
.ab-btn.sec .seta { width: auto; height: auto; background: none; }

/* ---- Folhas inferiores (conta, PIN, perfis) ---- */
.ab-veu {
  position: fixed; inset: 0; background: rgba(0,0,0,0.48);
  opacity: 0; pointer-events: none; transition: opacity 200ms var(--ease);
}
body.ab-folha-aberta .ab-veu { opacity: 1; pointer-events: auto; }

.ab-folha {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-width: 480px; margin: 0 auto;
  max-height: 88vh; overflow-y: auto;
  background: var(--ab-folha); color: var(--ab-texto);
  border: 1px solid var(--ab-borda); border-bottom: 0;
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  padding: 32px 24px calc(32px + env(safe-area-inset-bottom));
  transform: translateY(105%);
  transition: transform 200ms var(--ease);
}
.ab-folha.aberta { transform: translateY(0); }

.ab-titulo { font-size: 24px; font-weight: 400; letter-spacing: -0.01em; color: var(--ab-texto); line-height: 1.25; }
.ab-sub    { font-size: 16px; color: var(--ab-sec); margin-top: 8px; }

.ab-fechar {
  position: absolute; top: 24px; right: 16px;
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--ab-tecla); border: 0; color: var(--ab-texto); cursor: pointer;
}
.ab-fechar i { font-size: 20px; }
.ab-voltar {
  position: absolute; top: 24px; left: 16px;
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 0; color: var(--ab-texto); cursor: pointer;
}
.ab-voltar i { font-size: 24px; }

.ab-link {
  display: block; width: 100%; margin-top: 32px;
  background: none; border: 0; font: inherit; font-size: 15px; font-weight: 500;
  color: var(--ab-champ); text-align: center; text-decoration: none; cursor: pointer;
}
.ab-link:active { opacity: 0.6; }

/* ---- Lista de perfis ---- */
.ab-grupo { margin-top: 32px; }
.ab-grupo-titulo {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; color: var(--ab-sec); margin-bottom: 16px;
}
.ab-grupo-titulo i { font-size: 24px; color: var(--ab-texto); }

.ab-perfil {
  width: 100%;
  display: flex; align-items: center; gap: 16px;
  padding: 16px;
  background: var(--ab-tecla);
  border: 1px solid var(--ab-borda);
  border-radius: var(--radius-card);
  font: inherit; color: inherit; text-align: left; cursor: pointer;
  transition: background 200ms var(--ease), transform 200ms var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.ab-perfil + .ab-perfil { margin-top: 16px; }
.ab-perfil:active { background: rgba(233,198,154,0.10); transform: scale(0.99); }

.ab-avatar {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(245,239,230,0.08); color: var(--ab-texto);
  font-size: 15px; font-weight: 500; letter-spacing: 0.02em;
}
.ab-perfil-info { flex: 1; min-width: 0; }
.ab-perfil-nome { font-size: 15px; font-weight: 500; color: var(--ab-texto); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-perfil-sub  { font-size: 13px; color: var(--ab-sec); }
.ab-perfil-nome, .ab-perfil-sub { display: block; }
.ab-perfil > i  { font-size: 24px; color: var(--ab-sec); }

/* ---- PIN ---- */
.ab-pin { text-align: center; }
.ab-pin .ab-titulo { margin-top: 32px; }

.ab-pontos { display: flex; justify-content: center; gap: 24px; margin-top: 32px; }
.ab-ponto {
  width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid var(--ab-texto);
  transition: background 200ms var(--ease), border-color 200ms var(--ease);
}
.ab-ponto.cheio { background: var(--ab-texto); }
.ab-pontos.erro .ab-ponto { border-color: var(--vermelho); }
.ab-pontos.erro { animation: ab-tremer 320ms var(--ease); }
.ab-pontos.ok .ab-ponto { background: var(--ab-champ); border-color: var(--ab-champ); }

@keyframes ab-tremer {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.ab-msg { min-height: 24px; margin-top: 16px; font-size: 13px; color: #FF8A80; }
.ab-msg.aviso { color: var(--ab-sec); }

.ab-teclado {
  display: grid; grid-template-columns: repeat(3, 72px);
  justify-content: center; gap: 16px 32px;
  margin-top: 16px;
}
.ab-tecla {
  width: 72px; height: 72px; border-radius: 50%;
  border: 0; background: var(--ab-tecla); color: var(--ab-texto);
  font: inherit; font-size: 28px; font-weight: 400;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 200ms var(--ease), transform 200ms var(--ease);
}
.ab-tecla:active { background: rgba(233,198,154,0.22); transform: scale(0.96); }
.ab-tecla.vazia { visibility: hidden; }
.ab-tecla.apagar { background: none; }
.ab-tecla.apagar i { font-size: 24px; }
.ab-teclado.travado { pointer-events: none; opacity: 0.5; }

.ab-pin .ab-link { margin-top: 24px; }

/* ---- Abertura sobre a tela de login (index.php): cobre tudo e some ---- */
.ab-splash {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: var(--ab-fundo);
  transition: opacity 200ms var(--ease);
}
.ab-splash .ab-marca { position: static; transform: none; }
.ab-splash.saindo { opacity: 0; pointer-events: none; }

@media (max-height: 700px) {
  .ab-teclado { grid-template-columns: repeat(3, 64px); gap: 8px 32px; }
  .ab-tecla { width: 64px; height: 64px; }
  .ab-pontos { margin-top: 24px; }
  body.ab-inicio-aberto .ab-marca { top: calc(env(safe-area-inset-top) + 48px); }
}

@media (prefers-reduced-motion: reduce) {
  .ab-marca, .ab-folha, .ab-inicio, .ab-fundo, .ab-pontos.erro { animation: none; transition: none; }
  .ab-marca { opacity: 1; }
}

.ab-tela [hidden] { display: none !important; }
