/* ══════════════════════════════════════════════════════════════════
   Motion do sistema: painel, Área da Noiva, portal, aprovação.

   Quem liga é o motion.js, carregado no <head>: ele põe .has-motion no
   <html> antes de o corpo pintar (e .mo-primeira na 1ª página da sessão).
   Sem o script, nenhuma regra daqui vale — nada fica escondido. Com
   prefers-reduced-motion o script nem liga a classe.

   A abertura é CSS puro, pela posição no HTML (nth-child): não depende de
   o script marcar nada depois de pintar, então não pisca. Só transform e
   opacity, com fill "backwards": terminada a entrada não sobra transform
   no elemento (transform retido viraria bloco de contenção dos position:fixed
   de dentro, e os modais iriam parar no lugar errado). Navegar entre telas é ação repetida: da 2ª página em diante a
   abertura é curta (≈ 0,3 s).
   ══════════════════════════════════════════════════════════════════ */
:root {
  --mo-dur-1: 120ms;
  --mo-dur-2: 240ms;
  --mo-dur-3: 480ms;
  --mo-dur-4: 800ms;
  --mo-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --mo-ease-in: cubic-bezier(0.7, 0, 0.84, 0);
  --mo-shift: 14px;
  --mo-passo: 35ms;          /* intervalo entre blocos (páginas seguintes) */
  --mo-dur-entra: var(--mo-dur-2);
}
.mo-primeira { --mo-shift: 22px; --mo-passo: 70ms; --mo-dur-entra: var(--mo-dur-3); }

@keyframes mo-sobe   { from { opacity: 0; transform: translate3d(0, var(--mo-shift), 0); } }
@keyframes mo-surge  { from { opacity: 0; transform: translate3d(0, -6px, 0) scale(.985); } }
@keyframes mo-lado   { from { opacity: 0; transform: translate3d(-14px, 0, 0); } }
@keyframes mo-logo   { 0% { opacity: 0; transform: scale(.8) rotate(-8deg); } 60% { opacity: 1; transform: scale(1.05) rotate(1deg); } 100% { opacity: 1; transform: none; } }
@keyframes mo-brilho { from { transform: translateX(-130%) skewX(-18deg); } to { transform: translateX(330%) skewX(-18deg); } }
@keyframes mo-pulso  { 0% { transform: scale(1); } 40% { transform: scale(1.07); } 100% { transform: scale(1); } }

/* ── Abertura: blocos do conteúdo sobem em sequência ──────────────── */
.has-motion :is(main.flex-1, .nv-main) > * {
  animation: mo-sobe var(--mo-dur-entra) var(--mo-ease-out) backwards;
}
.has-motion :is(main.flex-1, .nv-main) > :nth-child(2) { animation-delay: calc(1 * var(--mo-passo)); }
.has-motion :is(main.flex-1, .nv-main) > :nth-child(3) { animation-delay: calc(2 * var(--mo-passo)); }
.has-motion :is(main.flex-1, .nv-main) > :nth-child(4) { animation-delay: calc(3 * var(--mo-passo)); }
.has-motion :is(main.flex-1, .nv-main) > :nth-child(5) { animation-delay: calc(4 * var(--mo-passo)); }
.has-motion :is(main.flex-1, .nv-main) > :nth-child(6) { animation-delay: calc(5 * var(--mo-passo)); }
.has-motion :is(main.flex-1, .nv-main) > :nth-child(n+7) { animation-delay: calc(6 * var(--mo-passo)); }

/* Cartões lado a lado (grades de KPI, de cartões) entram um a um. */
.has-motion :is(.grid, .nv-cartoes, .stats-grid) > :is(.card, .stat-card, a, article, div) {
  animation: mo-sobe var(--mo-dur-entra) var(--mo-ease-out) backwards;
}
.has-motion :is(.grid, .nv-cartoes, .stats-grid) > :nth-child(2) { animation-delay: calc(1 * var(--mo-passo) + 60ms); }
.has-motion :is(.grid, .nv-cartoes, .stats-grid) > :nth-child(3) { animation-delay: calc(2 * var(--mo-passo) + 60ms); }
.has-motion :is(.grid, .nv-cartoes, .stats-grid) > :nth-child(4) { animation-delay: calc(3 * var(--mo-passo) + 60ms); }
.has-motion :is(.grid, .nv-cartoes, .stats-grid) > :nth-child(n+5) { animation-delay: calc(4 * var(--mo-passo) + 60ms); }

/* Linhas de tabela: as 12 primeiras, em cascata curta. */
.has-motion .table-hz tbody tr:nth-child(-n+12) {
  --mo-shift: 6px;
  animation: mo-sobe var(--mo-dur-entra) var(--mo-ease-out) backwards;
  animation-delay: calc(100ms + var(--mo-i, 0) * 25ms);
}
.has-motion .table-hz tbody tr:nth-child(2)  { --mo-i: 1; }  .has-motion .table-hz tbody tr:nth-child(3)  { --mo-i: 2; }
.has-motion .table-hz tbody tr:nth-child(4)  { --mo-i: 3; }  .has-motion .table-hz tbody tr:nth-child(5)  { --mo-i: 4; }
.has-motion .table-hz tbody tr:nth-child(6)  { --mo-i: 5; }  .has-motion .table-hz tbody tr:nth-child(7)  { --mo-i: 6; }
.has-motion .table-hz tbody tr:nth-child(8)  { --mo-i: 7; }  .has-motion .table-hz tbody tr:nth-child(9)  { --mo-i: 8; }
.has-motion .table-hz tbody tr:nth-child(10) { --mo-i: 9; }  .has-motion .table-hz tbody tr:nth-child(11) { --mo-i: 10; }
.has-motion .table-hz tbody tr:nth-child(12) { --mo-i: 11; }

/* ── Abaixo da dobra: o script marca e revela ao rolar ────────────── */
.has-motion [data-mo="rola"] { opacity: 0; transform: translate3d(0, 22px, 0); animation: none; }
.has-motion [data-mo="rola"].mo-on {
  opacity: 1; transform: none;
  transition: opacity var(--mo-dur-3) var(--mo-ease-out), transform var(--mo-dur-3) var(--mo-ease-out);
}

/* ── Menu lateral e logo: só na 1ª página da sessão ───────────────── */
.has-motion.mo-primeira :is(.hz-side .nav-link, .hz-side .nav-group > summary, .nv-nav__link) {
  animation: mo-lado var(--mo-dur-3) var(--mo-ease-out) backwards;
  animation-delay: calc(120ms + var(--mo-i, 0) * 30ms);
}
.has-motion.mo-primeira :is(.hz-side-brand > :first-child, .nv-marca) {
  animation: mo-logo var(--mo-dur-4) var(--mo-ease-out) backwards;
}
/* Brilho que atravessa a logo (1ª página) e inclinação no hover (sempre). */
:is(.hz-side-brand > :first-child, .nv-marca) { position: relative; }
.has-motion :is(.hz-side-brand > :first-child, .nv-marca) { transition: transform var(--mo-dur-2) var(--mo-ease-out); }
.has-motion .mo-brilho {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none; border-radius: inherit;
}
.has-motion .mo-brilho::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 35%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent);
  transform: translateX(-130%) skewX(-18deg);
}
.has-motion.mo-primeira .mo-brilho::after { animation: mo-brilho 1100ms var(--mo-ease-out) 650ms both; }
@media (hover: hover) {
  .has-motion :is(.hz-side-brand > :first-child, .nv-marca):hover { transform: rotate(-2deg) scale(1.04); }
  .has-motion :is(.hz-side-brand > :first-child, .nv-marca):hover .mo-brilho::after { animation: mo-brilho 900ms var(--mo-ease-out) both; }
}

/* ── O que acabou de aparecer (hidden removido, campo do briefing) ── */
.mo-surge, .brf-surge { animation: mo-surge var(--mo-dur-2) var(--mo-ease-out) backwards; }

/* ── Número que acabou de contar ──────────────────────────────────── */
.mo-contou { animation: mo-pulso var(--mo-dur-3) var(--mo-ease-out); }

/* ── Cartões e botões: resposta ao mouse e ao toque ───────────────── */
@media (hover: hover) {
  .has-motion :is(a.card, .stat-card, a.nv-cartao) { transition: transform var(--mo-dur-2) var(--mo-ease-out), border-color var(--mo-dur-2), box-shadow var(--mo-dur-2); }
  .has-motion :is(a.card, .stat-card, a.nv-cartao):hover { transform: translate3d(0, -3px, 0); }
  .has-motion :is(.nav-link, .nv-nav__link) > svg { transition: transform var(--mo-dur-2) var(--mo-ease-out); }
  .has-motion :is(.nav-link, .nv-nav__link):hover > svg { transform: translate3d(2px, 0, 0) scale(1.1); }
}
.has-motion :is(.btn, .nv-btn):active:not(:disabled) { transform: scale(.97); transition-duration: var(--mo-dur-1); }

/* ── <details> abrindo (grupos do menu, "Anexar", "Sugerir") ──────── */
.has-motion details[open] > :not(summary) { animation: mo-surge var(--mo-dur-2) var(--mo-ease-out) backwards; }

/* ── Troca de página (Chrome, Edge, Safari 18.2+; os outros navegam seco).
   Curta de propósito: navegar é o gesto mais repetido do painel. ────── */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root) { animation: var(--mo-dur-1) var(--mo-ease-in) both mo-vt-sai; }
  ::view-transition-new(root) { animation: var(--mo-dur-2) var(--mo-ease-out) both mo-vt-entra; }
}
@keyframes mo-vt-sai   { to   { opacity: 0; } }
@keyframes mo-vt-entra { from { opacity: 0; } }

/* ── Movimento reduzido: tudo inteiro e parado ────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .has-motion *, .mo-surge, .brf-surge, .mo-contou { animation: none !important; }
  .has-motion [data-mo="rola"] { opacity: 1 !important; transform: none !important; transition: none !important; }
  .has-motion .mo-brilho { display: none; }
}
@media print {
  .has-motion * { animation: none !important; }
  .has-motion [data-mo="rola"] { opacity: 1 !important; transform: none !important; }
}
