/* ==========================================================================
   NEXUS SCIENTIFIC CLUB — PAGE TRANSITIONS
   A subtle fade + 8px slide on navigation. Progressive enhancement only:
   nothing here can block, intercept or delay a navigation.

   Two paths, one design:

   1. NATIVE VIEW TRANSITIONS (multi-page documents)
      `@view-transition { navigation: auto }` opts this multi-page site into
      cross-document view transitions. The browser snapshots the outgoing page
      and animates the incoming one. No JavaScript, and crucially no click
      interception — the browser applies it only to same-origin navigations it
      performs itself, so external links, target="_blank", downloads,
      same-page anchors, browser back/forward, OAuth callbacks, forms and
      JS-driven navigation all keep working exactly as before.

   2. FALLBACK (browsers without cross-document view transitions)
      A plain CSS entrance animation on the page content. It is gated on
      @supports so it never double-animates alongside a real view transition.

   Both paths are disabled entirely under prefers-reduced-motion: reduce.
   ========================================================================== */

:root {
  --pt-in-duration: 220ms;
  --pt-out-duration: 120ms;
  --pt-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --pt-offset: 8px;
}

@keyframes nexusPageIn {
  from {
    opacity: 0;
    transform: translateY(var(--pt-offset));
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes nexusPageOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(calc(var(--pt-offset) / -2));
  }
}

/* --------------------------------------------------------------------------
   1. NATIVE CROSS-DOCUMENT VIEW TRANSITIONS
   Only the root snapshot is animated (no per-element names), so no page needs
   markup changes and no layout is recalculated for the transition.
   -------------------------------------------------------------------------- */

@view-transition {
  navigation: auto;
}

::view-transition-group(root) {
  animation-duration: var(--pt-in-duration);
}

/* Outgoing page: a short, motion-free fade — never delays the navigation. */
::view-transition-old(root) {
  animation: nexusPageOut var(--pt-out-duration) var(--pt-ease) both;
}

/* Incoming page: fade in from 8px below its natural position. */
::view-transition-new(root) {
  animation: nexusPageIn var(--pt-in-duration) var(--pt-ease) both;
}

/* --------------------------------------------------------------------------
   2. FALLBACK — no cross-document view transition support
   Animates the content container only, never <body>: a transform on <body>
   would turn it into the containing block for fixed-position chrome (header,
   sandbox banner, toasts). `backwards` fill (not `both`) guarantees the
   transform is gone once the animation finishes.
   -------------------------------------------------------------------------- */

@supports not (view-transition-name: root) {
  @media (prefers-reduced-motion: no-preference) {

    main,
    .page-shell {
      animation: nexusPageIn var(--pt-in-duration) var(--pt-ease) backwards;
    }
  }
}

/* --------------------------------------------------------------------------
   3. ACCESSIBILITY — reduced motion
   Navigation becomes instant: no view transition, no entrance animation.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none !important;
  }

  main,
  .page-shell {
    animation: none !important;
  }
}
