/* ═══════════════════════════════════════════════════════════════════════
   KIT NAPOLEÃO · movimento
   O vocabulário de movimento do Consulado II. Só aparência e comportamento
   visual — nada aqui fala com /api/... nem depende de nome de função.

   Carregar DEPOIS de base.css e layout.css:
     <link rel="stylesheet" href="/kit/css/movimento.css">
     <script src="/kit/js/movimento.js"></script>

   Os nomes (para a gente falar a mesma língua):
     painel deslizante  = slide-over / drawer   → .n-painel
     modal com desfoque = scale-fade + blur     → .n-modal
     esqueleto          = skeleton + shimmer    → .n-esq
     barra de progresso = top loading bar       → #n-progresso
     cascata            = stagger               → .n-cascata > *
     resposta ao clique = press state + ripple  → [data-onda], :active
     avisos empilhados  = toasts                → #n-avisos
   ═══════════════════════════════════════════════════════════════════════ */

/* ── 1. Barra de progresso no topo ─────────────────────────────────────── */
#n-progresso {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 9999;
  background: transparent; pointer-events: none; opacity: 0;
  transition: opacity var(--mov-medio) var(--mov-curva);
}
#n-progresso.ativo { opacity: 1; }
#n-progresso > i {
  display: block; height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--verde-medio), var(--dourado));
  transform: translateX(-100%);
  transition: transform var(--mov-lento) var(--mov-curva);
}

/* ── 2. Esqueleto (no lugar do spinner) ────────────────────────────────── */
.n-esq {
  border-radius: 7px; height: 14px;
  background: linear-gradient(90deg, var(--cinza-borda) 25%, var(--hover) 50%, var(--cinza-borda) 75%);
  background-size: 320px 100%;
  animation: n-brilho 1.1s linear infinite;
}
.n-esq + .n-esq { margin-top: 12px; }
.n-esq.curto { width: 64%; }
.n-esq.medio { width: 86%; }
.n-esq.alto  { height: 46px; border-radius: var(--raio-sm); }
@keyframes n-brilho { from { background-position: -220px 0; } to { background-position: 320px 0; } }

/* ── 3. Cascata nas linhas de tabela e cards ───────────────────────────── */
.n-cascata > * { opacity: 0; animation: n-linha .42s var(--mov-curva) forwards; }
.n-cascata > *:nth-child(1)  { animation-delay: calc(var(--mov-cascata) * 0); }
.n-cascata > *:nth-child(2)  { animation-delay: calc(var(--mov-cascata) * 1); }
.n-cascata > *:nth-child(3)  { animation-delay: calc(var(--mov-cascata) * 2); }
.n-cascata > *:nth-child(4)  { animation-delay: calc(var(--mov-cascata) * 3); }
.n-cascata > *:nth-child(5)  { animation-delay: calc(var(--mov-cascata) * 4); }
.n-cascata > *:nth-child(6)  { animation-delay: calc(var(--mov-cascata) * 5); }
.n-cascata > *:nth-child(7)  { animation-delay: calc(var(--mov-cascata) * 6); }
.n-cascata > *:nth-child(8)  { animation-delay: calc(var(--mov-cascata) * 7); }
.n-cascata > *:nth-child(9)  { animation-delay: calc(var(--mov-cascata) * 8); }
.n-cascata > *:nth-child(10) { animation-delay: calc(var(--mov-cascata) * 9); }
.n-cascata > *:nth-child(11) { animation-delay: calc(var(--mov-cascata) * 10); }
.n-cascata > *:nth-child(12) { animation-delay: calc(var(--mov-cascata) * 11); }
/* Da 13ª linha em diante entra sem defasagem: em lista longa, cascata vira espera. */
.n-cascata > *:nth-child(n+13) { animation-delay: calc(var(--mov-cascata) * 12); }
@keyframes n-linha { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── 4. Resposta ao clique ─────────────────────────────────────────────── */
button, .btn, .card-clicavel, .sidebar a, .conta-chip, [data-onda] {
  transition: background var(--mov-rapido) var(--mov-curva),
              border-color var(--mov-rapido) var(--mov-curva),
              box-shadow var(--mov-medio) var(--mov-curva),
              transform var(--mov-rapido) var(--mov-curva);
}
button:active, .btn:active, .card-clicavel:active, [data-onda]:active { transform: scale(.975); }
.card-clicavel:hover { transform: translateY(-2px); box-shadow: var(--sombra-md); }

/* Onda (ripple) — só na ação principal. O <span> é criado pelo movimento.js. */
[data-onda] { position: relative; overflow: hidden; }
.n-onda {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: currentColor; opacity: .28; transform: scale(0);
  animation: n-onda .55s var(--mov-curva-saida) forwards;
}
@keyframes n-onda { to { transform: scale(2.6); opacity: 0; } }

/* ── 5. Painel deslizante (substitui o modal em formulário) ────────────── */
.n-fundo {
  position: fixed; inset: 0; z-index: 900; background: rgba(8, 24, 42, .44);
  opacity: 0; animation: n-surge var(--mov-medio) var(--mov-curva) forwards;
}
.n-fundo.desfoque { backdrop-filter: blur(var(--desfoque-fundo)); }
@keyframes n-surge { to { opacity: 1; } }

.n-painel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 901;
  width: min(420px, 92vw); display: flex; flex-direction: column;
  background: var(--branco); box-shadow: -24px 0 60px -20px rgba(8, 24, 42, .45);
  transform: translateX(100%);
  animation: n-entra-lado var(--mov-lento) var(--mov-curva) forwards;
}
.n-painel.saindo { animation: n-sai-lado var(--mov-medio) var(--mov-curva-saida) forwards; }
@keyframes n-entra-lado { to { transform: none; } }
@keyframes n-sai-lado { to { transform: translateX(100%); } }

.n-painel > header,
.n-modal > header { display: flex; align-items: center; gap: 10px; padding: 18px 22px; border-bottom: 1px solid var(--cinza-borda); }
.n-painel > header h2,
.n-modal > header h2 { font-family: var(--fonte-titulo); font-size: 16px; font-weight: 800; margin: 0; color: var(--verde-escuro); }
.n-painel > .corpo { padding: 20px 22px; overflow: auto; flex: 1; }
.n-painel > footer { display: flex; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--cinza-borda); }

/* No celular (Arco do Triunfo) o painel sobe de baixo — polegar alcança. */
@media (max-width: 640px) {
  .n-painel {
    top: auto; left: 0; width: auto; max-height: 88vh;
    border-radius: var(--raio-lg) var(--raio-lg) 0 0;
    transform: translateY(100%); animation-name: n-entra-baixo;
  }
  .n-painel.saindo { animation-name: n-sai-baixo; }
  @keyframes n-entra-baixo { to { transform: none; } }
  @keyframes n-sai-baixo { to { transform: translateY(100%); } }
}

/* ── 6. Modal com escala e desfoque (só decisão irreversível) ──────────── */
.n-modal {
  position: fixed; z-index: 901; top: 50%; left: 50%;
  width: min(420px, 92vw); background: var(--branco);
  border-radius: var(--raio-lg); box-shadow: var(--sombra-lg);
  transform: translate(-50%, -50%) scale(.94); opacity: 0;
  animation: n-entra-modal var(--mov-medio) var(--mov-curva) forwards;
}
.n-modal.saindo { animation: n-sai-modal var(--mov-rapido) var(--mov-curva-saida) forwards; }
.n-modal > .corpo { padding: 22px 24px; }
.n-modal > footer { display: flex; gap: 10px; padding: 0 24px 22px; }
.n-modal .n-selo {
  width: 42px; height: 42px; border-radius: 11px; background: var(--dourado-fundo);
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.n-modal .n-selo img { width: 26px; height: 26px; }
@keyframes n-entra-modal { to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
@keyframes n-sai-modal { to { transform: translate(-50%, -50%) scale(.96); opacity: 0; } }

/* ── 7. Avisos empilhados (no lugar do alert()) ────────────────────────── */
#n-avisos {
  position: fixed; right: 18px; bottom: 18px; z-index: 950;
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
  pointer-events: none;
}
.n-aviso {
  display: flex; align-items: center; gap: 10px; min-width: 220px; max-width: 380px;
  padding: 11px 15px; border-radius: 11px; pointer-events: auto;
  background: var(--marinho); color: #F4F7FA; box-shadow: var(--sombra-lg);
  font-size: 13px; font-weight: 500;
  animation: n-entra-aviso var(--mov-medio) var(--mov-curva) forwards;
}
.n-aviso.saindo { animation: n-sai-aviso var(--mov-medio) var(--mov-curva-saida) forwards; }
.n-aviso > .ponto { width: 8px; height: 8px; border-radius: 50%; background: var(--verde-medio); flex: none; }
.n-aviso.erro > .ponto { background: var(--vermelho-alerta); }
.n-aviso.prazo > .ponto { background: var(--dourado); }
.n-aviso > button { margin-left: auto; background: none; border: none; color: #A9C0D6; cursor: pointer; font-size: 15px; line-height: 1; }
@keyframes n-entra-aviso { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes n-sai-aviso { to { opacity: 0; transform: translateY(8px) scale(.98); } }
@media (max-width: 640px) { #n-avisos { left: 12px; right: 12px; bottom: 12px; align-items: stretch; } }

/* ── 8. Transição entre telas (troca de #/rota) ────────────────────────── */
.n-troca { animation: n-troca-tela var(--mov-medio) var(--mov-curva); }
@keyframes n-troca-tela { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── 9. Respeito à preferência do sistema ──────────────────────────────── */
/* Quem pediu menos movimento recebe as MESMAS telas, sem deslizamento. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .n-painel, .n-modal { transform: none !important; opacity: 1 !important; }
  .n-modal { transform: translate(-50%, -50%) !important; }
  .n-cascata > * { opacity: 1 !important; }
  .n-esq { animation: none !important; }
}

/* ── 10. Impressão: nada de movimento nem sobreposição ─────────────────── */
@media print {
  #n-progresso, #n-avisos, .n-fundo { display: none !important; }
  .n-painel, .n-modal { position: static; box-shadow: none; animation: none; transform: none; width: auto; }
  .n-cascata > * { opacity: 1; animation: none; }
}
