/* =============================================================
   Motion — page changes and tab switches.

   Page to page: the browser's own cross-document View Transitions API
   (Chrome and Edge 126+, Safari 18.2+). The page content slides a short
   way in the direction of travel (page-transitions.css), while the sidebar
   (and the top bar on phones) stays put instead of flashing. In-app
   navigation inside the persistent shell plays the same slide on its
   content frame (js/shell-navigation.js). Browsers without the
   API simply load the next page as before; nothing else depends on it.
   The head script in _Layout.cshtml opts in and skips the transition when
   the in-app "reduce motion" preference is on.

   Tab switches: the panel that comes into view eases in with the same
   short rise. Bootstrap tab panes keep their own opacity fade and only add
   the rise; other tab systems (role="tabpanel" toggled with [hidden], the
   profile tabs) take the fade and the rise together.

   Everything here is off under prefers-reduced-motion and the in-app
   preference ([data-reduce-animations="true"] on <html>, .reduce-motion on
   <body>).
   ============================================================= */

:root {
    --app-motion-ease-out: cubic-bezier(.2, .8, .2, 1);
    --app-motion-tab-in: 200ms;
}

@media (prefers-reduced-motion: no-preference) {
    /* The opt-in itself, @view-transition { navigation: auto }, is an inline
       <style> in the <head> of _Layout.cshtml. Chrome checks it when the next
       page is first shown; with the layout's full stylesheet list and body
       scripts, an opt-in in this external sheet was missed at that point and
       the transition silently dropped, while the inline one always holds. */

    /* The shell stays still: from lg up the sidebar column, below lg the top bar. */
    @media (min-width: 992px) {
        .synx-sidebar { view-transition-name: synx-sidebar; }
    }

    @media (max-width: 991.98px) {
        .synx-topbar { view-transition-name: synx-topbar; }
    }

    ::view-transition-group(synx-sidebar),
    ::view-transition-group(synx-topbar) {
        animation-duration: 0s;
    }

    ::view-transition-old(synx-sidebar),
    ::view-transition-old(synx-topbar) {
        display: none;
    }

    ::view-transition-new(synx-sidebar),
    ::view-transition-new(synx-topbar) {
        animation: none;
    }

    /* The content slides the way the public pages do (page-transitions.css),
       at the workspace's shorter distance and pace: forwards by default,
       mirrored when the browser goes back. */
    ::view-transition-old(root),
    ::view-transition-new(root) {
        --wa-vt-shift: var(--app-vt-shift);
    }

    ::view-transition-old(root) {
        animation: wa-vt-out-fwd var(--app-vt-out) var(--wa-vt-ease-out) both;
    }

    ::view-transition-new(root) {
        animation: wa-vt-in-fwd var(--app-vt-in) var(--wa-vt-ease-in) both;
    }

    html:active-view-transition-type(wa-back)::view-transition-old(root) {
        animation-name: wa-vt-out-back;
    }

    html:active-view-transition-type(wa-back)::view-transition-new(root) {
        animation-name: wa-vt-in-back;
    }

    /* Tab panels. */
    .tab-content > .tab-pane.active {
        animation: app-tab-rise var(--app-motion-tab-in) var(--app-motion-ease-out);
    }

    [role="tabpanel"]:not(.tab-pane):not([hidden]),
    .figma-tab-panel.active {
        animation: app-tab-in var(--app-motion-tab-in) var(--app-motion-ease-out);
    }

    :is([data-reduce-animations="true"], .reduce-motion) :is(.tab-content > .tab-pane.active, [role="tabpanel"], .figma-tab-panel) {
        animation: none;
    }
}

@keyframes app-tab-rise {
    from { transform: translateY(6px); }
}

@keyframes app-tab-in {
    from { opacity: 0; transform: translateY(6px); }
}
