/* Ninja Motion - cross-document View Transitions (spec A.3). @author OCNinja https://ocninja.com
   Linked by catalog/controller/extension/module/ninja_motion.php only while the transitions toggle is
   on (Chrome/Edge 126+, Safari 18.2+; elsewhere nothing happens). The head bootstrap and motion.js
   skip the transition when the kill switch, reduced motion or a popup says no. */
@view-transition { navigation: auto; }

::view-transition-old(root) { animation: nm-vt-out 180ms ease-out both; }
::view-transition-new(root) { animation: nm-vt-in 180ms ease-out both; }

@keyframes nm-vt-out { to { opacity: 0; } }
@keyframes nm-vt-in { from { opacity: 0; translate: 0 8px; } }

/* Header and logo stay anchored instead of cross-fading or sliding */
html.nm-f-vt header { view-transition-name: nm-header; }
html.nm-f-vt #logo { view-transition-name: nm-logo; }

::view-transition-group(nm-header),
::view-transition-group(nm-logo) { animation-duration: 0s; }

/* Shared product image (spec 4.1). Listing side: motion.js sets data-nm-vt on exactly the clicked card's
   image just before navigation. The name is assigned from this stylesheet (never inline on the J3 <img>),
   and only one image per page carries it, so Chromium does not abort the transition. */
html.nm-f-shared-img img[data-nm-vt] { view-transition-name: nm-product-img; }

/* PDP side: the main product image receives the same name so the browser tweens the listing image into it.
   Journal3 (product.twig) wraps the hero in .product-image > .swiper.main-image, with the thumbnail strip in a
   sibling .additional-images; the first main slide is the visible hero before Swiper initialises (pagereveal
   fires then). So target exactly .main-image's first slide image - NOT .swiper-slide-active, which J3 puts on
   the first THUMBNAIL server-side, and NOT a bare :first-of-type that would over-match the additional images.
   This matches exactly one element on the page, keeping the view-transition-name unique. */
html.nm-f-shared-img .product-image .main-image .swiper-slide:first-child img { view-transition-name: nm-product-img; }

/* The product image flies; the root still cross-fades under it. */
::view-transition-group(nm-product-img) { animation-duration: 260ms; animation-timing-function: ease; }
