/* =============================================================
   Page transitions — one motion language for the whole product.

   The directional slide first built for landing -> choose -> sign-in
   (css/workspace-auth.css, Views/Shared/_WorkspaceMotionHead.cshtml) lives
   here so the workspace uses the same tokens and keyframes:

   - Public pages: cross-document View Transitions, tagged wa-forward or
     wa-back by the motion head; workspace-auth.css places the slides.
   - Workspace, full-page loads: the same View Transitions, tagged by the
     layout's motion head (Views/Shared/_Layout.cshtml); motion.css places
     them on the content while the sidebar holds still.
   - Workspace, in-app navigation: the persistent shell swaps a content
     frame rather than the page, so js/shell-navigation.js plays the same
     slides on the frame (below), forwards down the sidebar and for links,
     mirrored going up it and for Back.

   The old content accelerates out while the new decelerates in, so the
   page never blinks. Only transform and opacity animate. Nothing here plays
   under prefers-reduced-motion or the in-app "reduce animations" setting.
   ============================================================= */

:root {
    --wa-vt-out: 300ms;
    --wa-vt-in: 560ms;
    --wa-vt-morph: 640ms;
    --wa-vt-shift: 36px;
    --wa-vt-ease-out: cubic-bezier(.4, 0, 1, 1);
    --wa-vt-ease-in: cubic-bezier(.16, 1, .3, 1);
    --wa-vt-ease-move: cubic-bezier(.32, .72, 0, 1);

    /* The workspace moves less and sooner than the public pages: people
       switch sections all day, so the slide is a hint, not a show. */
    --app-vt-out: 160ms;
    --app-vt-in: 380ms;
    --app-vt-shift: 16px;
}

@keyframes wa-vt-out-fwd {
    to { opacity: 0; transform: translateX(calc(var(--wa-vt-shift) * -.75)); }
}

@keyframes wa-vt-in-fwd {
    from { opacity: 0; transform: translateX(var(--wa-vt-shift)); }
}

@keyframes wa-vt-out-back {
    to { opacity: 0; transform: translateX(calc(var(--wa-vt-shift) * .75)); }
}

@keyframes wa-vt-in-back {
    from { opacity: 0; transform: translateX(calc(var(--wa-vt-shift) * -1)); }
}

/* ---------- Workspace content swaps (persistent shell) ----------
   shell-navigation.js sets data-wa-swap="out" on the content host as a
   navigation starts and "in" once the next page is ready, with
   data-wa-direction="forward|back". The skeleton fades in over the leaving
   page and out over the arriving one, so the two crossfade; the request
   itself is never held back for the animation. */
@media (prefers-reduced-motion: no-preference) {
    html:not([data-reduce-animations="true"]) body:not(.reduce-motion) .app-content-host {
        --wa-vt-shift: var(--app-vt-shift);
    }

    html:not([data-reduce-animations="true"]) body:not(.reduce-motion) .app-content-host[data-wa-swap="out"] > .app-content-frame {
        animation: wa-vt-out-fwd var(--app-vt-out) var(--wa-vt-ease-out) both;
    }

    html:not([data-reduce-animations="true"]) body:not(.reduce-motion) .app-content-host[data-wa-swap="in"] > .app-content-frame {
        animation: wa-vt-in-fwd var(--app-vt-in) var(--wa-vt-ease-in) both;
    }

    html:not([data-reduce-animations="true"]) body:not(.reduce-motion) .app-content-host[data-wa-direction="back"][data-wa-swap="out"] > .app-content-frame {
        animation-name: wa-vt-out-back;
    }

    html:not([data-reduce-animations="true"]) body:not(.reduce-motion) .app-content-host[data-wa-direction="back"][data-wa-swap="in"] > .app-content-frame {
        animation-name: wa-vt-in-back;
    }

    /* The skeleton arrives with a short fade instead of a cut. */
    @starting-style {
        html:not([data-reduce-animations="true"]) body:not(.reduce-motion) .app-content-host[data-wa-swap] > .app-content-loading:not([hidden]) {
            opacity: 0;
        }
    }
}
