/* =============================================================================
   Visual novo (card 978926) — movimento

   Piloto nas telas de projetos (revisão do José, 25/09) aprovado e estendido a todas as
   telas no mesmo dia. Age sob <html data-motion="on">, que os layouts fixam. O comportamento (abas, título que viaja, botão
   enviando, exclusão) vem de resources/js/app/air/air-motion.init.js e
   resources/js/components/air/motion.js; a linha de carregamento, de air-progress.init.js.

   Regras (skills do Emil Kowalski): só transform e opacity; entrada com ease-out forte,
   movimento na tela com ease-in-out; menos de 300 ms no que se repete; a exclusão,
   rara, pode passar disso. Com "reduzir movimento" fica só o que é opacidade.
   ============================================================================= */

/* ── 1. Transição entre páginas (View Transitions entre documentos) ─────────
   Topo e menu ficam parados; só o conteúdo troca. O nome do projeto clicado na lista
   viaja até o título da edição (air-record-title, nome posto pelo JS no clique). */
@view-transition {
    navigation: auto;
}

html[data-motion="on"] #page-topbar {
    view-transition-name: air-topbar;
}

html[data-motion="on"] .vertical-menu {
    view-transition-name: air-sidebar;
}

html[data-motion="on"] .form-page .form-subtitle {
    view-transition-name: air-record-title;
    width: fit-content;
}

::view-transition-group(air-topbar),
::view-transition-group(air-sidebar) {
    animation: none;
}

/* Fica a imagem da página que sai: a primeira pintura da página nova ainda tem o menu com
   todos os grupos abertos (o metisMenu só os recolhe quando o script roda). */
::view-transition-old(air-topbar),
::view-transition-old(air-sidebar) {
    animation: none;
}

::view-transition-new(air-topbar),
::view-transition-new(air-sidebar) {
    display: none;
}

@keyframes air-vt-out {
    to { opacity: 0; }
}

@keyframes air-vt-in {
    from { opacity: 0; }
}

::view-transition-old(root) {
    animation: air-vt-out 120ms cubic-bezier(0.23, 1, 0.32, 1) both;
}

::view-transition-new(root) {
    animation: air-vt-in 200ms cubic-bezier(0.23, 1, 0.32, 1) 40ms both;
}

::view-transition-group(air-record-title) {
    animation-duration: 320ms;
    animation-timing-function: cubic-bezier(0.77, 0, 0.175, 1);
}

::view-transition-old(air-record-title),
::view-transition-new(air-record-title) {
    height: 100%;
    animation-duration: 320ms;
}

/* ── 2. Entrada da página: os blocos sobem em cascata; as linhas da lista seguem ──
   Só na abertura: depois dela o JS põe .air-motion-settled no <html>, e reordenar linhas
   (ordenação no cliente move os <tr>) ou o Vue remontar um bloco não refaz a cascata. */
@keyframes air-rise-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

@keyframes air-row-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

/* A abertura genérica (air-page-in) dá lugar à cascata. */
html[data-motion="on"] body[data-theme="air"] .page-content > .container-fluid {
    animation: none;
}

html[data-motion="on"]:not(.air-motion-settled) .page-content > .container-fluid > div:not(.jump-loading-overlay) > * {
    animation: air-rise-in 280ms cubic-bezier(0.23, 1, 0.32, 1) backwards;
}

html[data-motion="on"]:not(.air-motion-settled) .page-content > .container-fluid > div:not(.jump-loading-overlay) > :nth-child(2) { animation-delay: 40ms; }
html[data-motion="on"]:not(.air-motion-settled) .page-content > .container-fluid > div:not(.jump-loading-overlay) > :nth-child(3) { animation-delay: 80ms; }
html[data-motion="on"]:not(.air-motion-settled) .page-content > .container-fluid > div:not(.jump-loading-overlay) > :nth-child(4) { animation-delay: 120ms; }
html[data-motion="on"]:not(.air-motion-settled) .page-content > .container-fluid > div:not(.jump-loading-overlay) > :nth-child(n+5) { animation-delay: 160ms; }

html[data-motion="on"]:not(.air-motion-settled) .listing-page table.table > tbody > tr {
    animation: air-row-in 220ms cubic-bezier(0.23, 1, 0.32, 1) backwards;
    animation-delay: 300ms;
}

html[data-motion="on"]:not(.air-motion-settled) .listing-page table.table > tbody > tr:nth-child(1) { animation-delay: 120ms; }
html[data-motion="on"]:not(.air-motion-settled) .listing-page table.table > tbody > tr:nth-child(2) { animation-delay: 135ms; }
html[data-motion="on"]:not(.air-motion-settled) .listing-page table.table > tbody > tr:nth-child(3) { animation-delay: 150ms; }
html[data-motion="on"]:not(.air-motion-settled) .listing-page table.table > tbody > tr:nth-child(4) { animation-delay: 165ms; }
html[data-motion="on"]:not(.air-motion-settled) .listing-page table.table > tbody > tr:nth-child(5) { animation-delay: 180ms; }
html[data-motion="on"]:not(.air-motion-settled) .listing-page table.table > tbody > tr:nth-child(6) { animation-delay: 195ms; }
html[data-motion="on"]:not(.air-motion-settled) .listing-page table.table > tbody > tr:nth-child(7) { animation-delay: 210ms; }
html[data-motion="on"]:not(.air-motion-settled) .listing-page table.table > tbody > tr:nth-child(8) { animation-delay: 225ms; }
html[data-motion="on"]:not(.air-motion-settled) .listing-page table.table > tbody > tr:nth-child(9) { animation-delay: 240ms; }
html[data-motion="on"]:not(.air-motion-settled) .listing-page table.table > tbody > tr:nth-child(10) { animation-delay: 255ms; }
html[data-motion="on"]:not(.air-motion-settled) .listing-page table.table > tbody > tr:nth-child(11) { animation-delay: 270ms; }
html[data-motion="on"]:not(.air-motion-settled) .listing-page table.table > tbody > tr:nth-child(12) { animation-delay: 285ms; }

html[data-motion="on"]:not(.air-motion-settled) .listing-page .projects-overview-card {
    animation: air-rise-in 260ms cubic-bezier(0.23, 1, 0.32, 1) 140ms backwards;
}

/* ── 3. Abas do formulário: um sublinhado só, que corre até a aba escolhida ── */
html[data-motion="on"] body[data-theme="air"] .form-tabs.has-air-indicator {
    position: relative;
}

html[data-motion="on"] body[data-theme="air"] .form-tabs.has-air-indicator .nav-link.active:not(.has-errors) {
    border-bottom-color: transparent;
}

html[data-motion="on"] body[data-theme="air"] .form-tabs.has-air-indicator::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100px;
    height: 2px;
    border-radius: 2px;
    background: var(--air-ink-strong);
    transform-origin: left center;
    /* x e y: com muitas abas a lista quebra linha, e o sublinhado desce até a linha da aba. */
    transform: translate(var(--air-tab-x, 0), var(--air-tab-y, 0)) scaleX(var(--air-tab-scale, 0));
    transition: transform 260ms cubic-bezier(0.77, 0, 0.175, 1);
    pointer-events: none;
}

html[data-motion="on"] body[data-theme="air"] .form-tabs.has-air-indicator.is-instant::after {
    transition: none;
}

/* O painel novo entra pelo lado da aba escolhida (JS); o fade do Bootstrap sai do caminho. */
html[data-motion="on"] .form-tab-content > .tab-pane.fade {
    transition: none;
}

html[data-motion="on"] .form-tab-content > .tab-pane.fade.active {
    opacity: 1;
}

/* ── Reduzir movimento: fica só a opacidade ─────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    @view-transition {
        navigation: none;
    }

    html[data-motion="on"]:not(.air-motion-settled) .page-content > .container-fluid > div:not(.jump-loading-overlay) > *,
    html[data-motion="on"]:not(.air-motion-settled) .listing-page table.table > tbody > tr,
    html[data-motion="on"]:not(.air-motion-settled) .listing-page .projects-overview-card {
        animation: none;
    }

    html[data-motion="on"] body[data-theme="air"] .form-tabs.has-air-indicator::after {
        transition: none;
    }
}
