/* ==========================================================================
   Cross-document view transitions
   The photo on a recipe card morphs into the recipe page's hero image (and
   back). Same-origin page loads only; browsers without support, and users who
   ask for reduced motion, get a normal page load.
   Element naming lives in include/view_transitions_script.php: names are set
   on the clicked card only, so duplicate cards on a page never collide.
   ========================================================================== */

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

/* The recipe page owns the name statically; the script clears it when this
   page is the one being left for another recipe's card. */
html.legendary .lrd-hero__media img {
    view-transition-name: recipe-photo;
}

::view-transition-group(recipe-photo) {
    animation-duration: var(--motion-slow, 400ms);
    animation-timing-function: var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
}

/* Card (3:2) and hero (wide) differ in aspect ratio: crop instead of stretch. */
::view-transition-old(recipe-photo),
::view-transition-new(recipe-photo) {
    height: 100%;
    object-fit: cover;
    overflow: clip;
}

/* Everything else: a short cross-fade instead of a white flash. */
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: var(--motion-base, 250ms);
}
