/* ============================================================
   Page transitions (js/page-transitions.js, templates/core/base.html)

   .app is a 100dvh grid that never scrolls: the header sits in the
   top row and stays mounted between pages; #swup fills the rest and
   is the page's scroll container — except on the home page, whose #swup
   spans the header row too so the hero runs under the transparent
   navbar (Figma Navbar / Overlay). During a visit the parallel plugin
   puts the incoming #swup in front of the outgoing one, in the same
   grid cell, and both crossfade and blur at once.
   ============================================================ */

:root {
  /* Height of the header row (navbar.css .nav__inner). */
  --header-h: 86px;
}

@media (max-width: 768px) {
  :root { --header-h: 64px; }
}

html,
body {
  height: 100%;
}

body {
  overflow: hidden;  /* the page scrolls inside #swup, never the window */
}

.app {
  display: grid;
  grid-template-areas:
    "header"
    "main";
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;   /* fallback for browsers without dvh */
  height: 100dvh;
  overflow: hidden;
}

.app > header {
  grid-area: header;
  position: relative;  /* was fixed to the window; now a row of the shell */
  z-index: 1000;       /* its dropdowns and search open over #swup */
}

#swup {
  grid-area: main;
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scroll-behavior: smooth;
  z-index: calc(2 - var(--swup-parallel-container, 0));
  /* Old and new pages overlap while they blur: each must be opaque. */
  background: var(--color-page, var(--color-bg, #f8faf8));
}

/* Home: under the header. Placement is per container, so during a visit
   the outgoing and incoming pages each keep theirs — nothing jumps. */
#swup.page-home {
  grid-area: 1 / 1 / 3 / 2;
  scroll-padding-top: var(--header-h);
}

#swup.is-previous-container {
  z-index: 1;
  pointer-events: none;
}

/* ---- the transition ---- */

html.is-changing .transition-fade {
  transition:
    opacity 1s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    filter 1s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.transition-fade.is-previous-container {
  opacity: 0;
  filter: blur(5px);
}

.transition-fade.is-next-container {
  opacity: 0;
  filter: blur(5px);
}

/* No crossfade for visitors who ask for reduced motion: Swup sees no
   transition and swaps the pages at once. */
@media (prefers-reduced-motion: reduce) {
  html.is-changing .transition-fade { transition: none; }
  #swup { scroll-behavior: auto; }
}

/* The full-screen mobile menu (navbar.css) locks page scrolling. */
body.nav-menu-open #swup {
  overflow: hidden;
}
