/* ==========================================================================
   LDS page transitions (cross-document View Transitions, no framework)
   1. Default: slide-over with parallax (modeled on yodezeen.com). The new page
      slides in from the right over the old one, which drifts left at half speed.
      The Back button reverses the direction.
   2. Project photo: clicking a project image on Home or Projects grows that
      photo into the project hero. Going back shrinks it into its card.
   3. Phones, tablets and touch screens: a short crossfade only (no morph, no slide).
   Chrome/Edge 126+, Safari 18.2+. Other browsers navigate normally.
   Loaded on every page (EN + /es/) together with /lds-transitions.js.
   ========================================================================== */

@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}

:root {
  --lds-vt-dur: 1.1s;
  --lds-vt-ease: cubic-bezier(0.77, 0, 0.175, 1);   /* strong ease-in-out */
  --lds-vt-photo-dur: 1.25s;
  --lds-vt-photo-ease: cubic-bezier(0.65, 0, 0.35, 1);
}

/* The menu bar travels with its own page (each page's menu has its own colors),
   so it never shows twice. The cookie bar stays in place. */
.lds-cc { view-transition-name: lds-cc; }
::view-transition-group(lds-cc) { animation: none; }

/* ---------- 1. Slide-over with parallax ---------- */
::view-transition-old(root),
::view-transition-new(root) { mix-blend-mode: normal; }
::view-transition-old(root) { animation: lds-vt-out var(--lds-vt-dur) var(--lds-vt-ease) both; }
::view-transition-new(root) { animation: lds-vt-in  var(--lds-vt-dur) var(--lds-vt-ease) both; }

/* Back button: the current page slides off to the right, the previous one returns from the left */
html.lds-vt-back::view-transition-old(root) { animation-name: lds-vt-out-back; z-index: 2; }
html.lds-vt-back::view-transition-new(root) { animation-name: lds-vt-in-back;  z-index: 1; }

@keyframes lds-vt-in       { from { transform: translateX(100%); } }
@keyframes lds-vt-out      { to   { transform: translateX(-50%); } }
@keyframes lds-vt-in-back  { from { transform: translateX(-50%); } }
@keyframes lds-vt-out-back { to   { transform: translateX(100%); } }

/* ---------- 2. Project photo grows / shrinks ---------- */
html.lds-vt-photo::view-transition-old(root) { animation: none; }
html.lds-vt-photo::view-transition-new(root) { animation: lds-vt-fade-in .7s .25s cubic-bezier(.4,0,.2,1) both; }

::view-transition-group(lds-hero),
::view-transition-group(lds-hero-shade),
::view-transition-group(lds-hero-text) {
  animation-duration: var(--lds-vt-photo-dur);
  animation-timing-function: var(--lds-vt-photo-ease);
}
::view-transition-image-pair(lds-hero) { isolation: auto; }
::view-transition-old(lds-hero),
::view-transition-new(lds-hero) {
  animation: none;
  width: 100%; height: 100%;
  object-fit: cover; object-position: center;
  mix-blend-mode: normal;
}
/* Opening a project: the full photo takes over from the card crop right away */
html.lds-vt-photo-in::view-transition-new(lds-hero) { animation: lds-vt-fade-in .3s cubic-bezier(.4,0,.2,1) both; }
/* Returning: keep the full photo while it shrinks; the card takes over when it lands.
   The page underneath switches early and quickly, so no empty space shows behind the photo. */
html.lds-vt-photo-out::view-transition-new(lds-hero) { opacity: 0; }
html.lds-vt-photo-out::view-transition-new(root) { animation: lds-vt-fade-in .4s cubic-bezier(.33,0,.2,1) both; }
html.lds-vt-photo-out::view-transition-group(lds-hero) { animation-duration: 1.05s; animation-timing-function: cubic-bezier(.45,0,.2,1); }
/* Returning to a page without that card: let the photo fade */
html.lds-vt-photo-lost::view-transition-old(lds-hero) { animation: lds-vt-fade-out .45s ease both; }

/* Hero shade and title: fade in once the photo is nearly full screen, fade out first when leaving */
::view-transition-new(lds-hero-shade),
::view-transition-new(lds-hero-text) { animation: lds-vt-fade-in .55s .8s cubic-bezier(.4,0,.2,1) both; }
::view-transition-old(lds-hero-shade),
::view-transition-old(lds-hero-text) { animation: lds-vt-fade-out .3s cubic-bezier(.4,0,.2,1) both; }

@keyframes lds-vt-fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes lds-vt-fade-out { from { opacity: 1; } to { opacity: 0; } }

/* ---------- 3. Phones, tablets, touch screens: a short, stable crossfade ----------
   The script adds html.lds-vt-calm and names nothing, so no element morphs.
   Page snapshots are drawn at their natural size (object-fit: none, pinned to the
   top), so a change of viewport height between pages can never scale them. */
html.lds-vt-calm::view-transition-group(root) { animation-duration: .38s; }
html.lds-vt-calm::view-transition-old(root),
html.lds-vt-calm::view-transition-new(root) {
  width: 100%; height: 100%;
  object-fit: none; object-position: 50% 0;
}
html.lds-vt-calm::view-transition-old(root) { animation: none; }
html.lds-vt-calm::view-transition-new(root) { animation: lds-vt-fade-in .38s cubic-bezier(.4,0,.2,1) both; }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}
