/* Ofrenda marketing site: motion layer (site addition, not in the design file).

   One vocabulary, taken from the sticker-book look of the design system: things are pressed onto the
   page (hard shadows grow as a card lifts), slapped on (stickers), or drawn with a marker (the lilac
   highlight sweeps in). Nothing here changes layout: every effect uses opacity, box-shadow,
   background-size, object-position or the individual translate/rotate/scale properties, so the
   design's own `transform` rotations keep working.

   Three layers:
     1. Feedback  : hover, press and focus. Always on (unless reduced motion).
     2. Page load : CSS-only, keyed on <html class="motion"> (set by the inline script in
                    partials/head.html), so it never waits for or depends on motion.js.
     3. Scroll    : motion.js tags below-the-fold blocks with .mv and reveals them once.
   With JavaScript off, or with reduced motion on, the site is exactly the static design. */

:root{
  --mv-out: cubic-bezier(0.22, 0.8, 0.24, 1);
  --mv-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}
@supports (animation-timing-function: linear(0, 1)){
  :root{--mv-spring: linear(0, 0.009, 0.035 2.1%, 0.141, 0.281 6.7%, 0.723 12.9%, 0.938 16.7%, 1.017, 1.077, 1.121, 1.149 24.3%, 1.159, 1.163, 1.161, 1.154 29.9%, 1.129 32.8%, 1.051 39.6%, 1.017 43.1%, 0.991, 0.977 51%, 0.974 53.8%, 0.975 57.1%, 0.997 69.8%, 1.003 76.9%, 1.004 83.8%, 1);}
}

@keyframes mv-rise{from{opacity: 0; translate: 0 20px;}}
@keyframes mv-fade{from{opacity: 0;}}
@keyframes mv-land{from{opacity: 0; translate: 8px 8px; box-shadow: 0 0 0 0 transparent;}}
@keyframes mv-slap{from{opacity: 0; scale: 1.45; rotate: -16deg;}}
@keyframes mv-pop{from{opacity: 0; scale: 0.4;}}
@keyframes mv-sweep{from{background-size: 0% 100%;}to{background-size: 100% 100%;}}
@keyframes mv-swing{0%{rotate: 0deg;}30%{rotate: -7deg;}60%{rotate: 4deg;}80%{rotate: -2deg;}100%{rotate: 0deg;}}
@keyframes mv-spin{to{rotate: 360deg;}}
@keyframes mv-shake{0%, 100%{translate: 0 0;}25%{translate: -5px 0;}50%{translate: 4px 0;}75%{translate: -2px 0;}}
@keyframes mv-settle{from{opacity: 0; scale: 0.96; translate: 0 6px;}}
@keyframes mv-drift{from{object-position: 50% 36%;}to{object-position: 50% 64%;}}

@media (prefers-reduced-motion: no-preference){

/* ---- 1. Feedback ------------------------------------------------------------------ */

/* Buttons travel into their own shadow: hover half-presses, a click lands flat. */
.btn{transition: box-shadow 0.12s var(--mv-out), translate 0.12s var(--mv-out), background 0.15s, border-color 0.15s, color 0.15s;}
@media (hover: hover){
  .btn.btn--primary:hover, .btn.btn--accent:hover, .btn.btn--outline:hover{translate: 3px 3px;}
  .btn--sm.btn--primary:hover, .btn--sm.btn--accent:hover, .btn--sm.btn--outline:hover{translate: 2px 2px;}
}
.btn.btn--primary:active, .btn.btn--accent:active, .btn.btn--outline:active{translate: 5px 5px; box-shadow: 0 0 0 var(--ink) !important;}
.btn--sm.btn--primary:active, .btn--sm.btn--accent:active, .btn--sm.btn--outline:active{translate: 4px 4px;}
.btn.btn--solid, .btn.btn--ghost{transition: background 0.15s, border-color 0.15s, color 0.15s, scale 0.12s var(--mv-out);}
.btn.btn--solid:active, .btn.btn--ghost:active{scale: 0.97;}

/* Linked cards press the same way (the design already shrinks their shadow on hover). */
.tile, .scard{transition: box-shadow 0.14s var(--mv-out), translate 0.14s var(--mv-out);}
@media (hover: hover){
  .tile:hover{translate: 4px 4px;}
  .scard:hover{translate: 3px 3px;}
}
.tile:active, .scard:active{translate: 5px 5px; box-shadow: 0 0 0 var(--shadow-cream) !important;}

/* Arrows on links lean the way they point. motion.js wraps a trailing arrow in .arr. */
.arr{display: inline-block; transition: translate 0.2s var(--mv-out);}
@media (hover: hover){
  a:hover > .arr, button:hover > .arr{translate: 4px 0;}
  a:hover > .arr--out, button:hover > .arr--out{translate: 2px -2px;}
}

/* Header: the marker underlines the link you are about to follow, and the mark turns. */
.logo > img{transition: rotate 0.7s var(--mv-spring);}
@media (hover: hover){
  .logo:hover > img{rotate: 72deg;}
}
@container frame (width >= 560px){
  .site-nav__link{background: linear-gradient(to top, var(--lilac) 42%, transparent 42%) no-repeat 0 100% / 0% 100%; transition: background-size 0.25s var(--mv-out), color 0.15s; padding: 0 3px; margin: 0 -3px;}
  .site-nav__link:hover, .site-nav__link:focus-visible{background-size: 100% 100%; color: var(--ink);}
}

/* Colour changes ease instead of snapping. */
.text-link, .site-footer__link, .crumbs__link, .chip, .filter, .cat-chip, .store-pill{transition: color 0.15s, background-color 0.15s, border-color 0.15s;}

/* Fields lift toward you on focus, onto the lilac shadow the design gives them. */
.field{transition: box-shadow 0.16s var(--mv-out), translate 0.16s var(--mv-out);}
.field:focus{translate: -2px -2px;}

/* The verb icons give a small wave when you reach their card. */
@media (hover: hover){
  .way:hover .verb-icon, .door:hover .verb-icon, .tile:hover .verb-icon{animation: mv-swing 0.6s var(--mv-out);}
}

/* Forms answer: success settles in, an error shakes its head once. */
[data-form-success]:not([hidden]){animation: mv-settle 0.5s var(--mv-spring) backwards;}
[data-form-error]:not([hidden]){animation: mv-shake 0.36s var(--mv-out);}

/* Directory rows fade in whenever a search or filter brings them back. */
[data-row]:not([hidden]){animation: mv-fade 0.3s var(--mv-out) backwards;}
[data-dir-empty]:not([hidden]){animation: mv-settle 0.4s var(--mv-out) backwards;}

/* Reviews band: scroll snapping is off only while motion.js is drifting the track. */
.reviews__track.is-drifting{scroll-snap-type: none !important;}

/* ---- 2. Page load (CSS only) -------------------------------------------------------- */

/* The page title rises first, then whatever follows it, one beat apart. `backwards` (not `both`)
   so the finished animation lets go of translate and hover feedback still works. */
.motion main :is(.hero__icons, .notice__marks, .crumbs, .of-logo-stack){animation: mv-fade 0.5s var(--mv-out) backwards;}
.motion main h1.h{animation: mv-rise 0.7s var(--mv-out) 0.05s backwards;}
.motion main :is(h1.h, .of-title-row) ~ *{animation: mv-rise 0.7s var(--mv-out) 0.4s backwards;}
.motion main :is(h1.h, .of-title-row) + *{animation-delay: 0.15s;}
.motion main :is(h1.h, .of-title-row) + * + *{animation-delay: 0.24s;}
.motion main :is(h1.h, .of-title-row) + * + * + *{animation-delay: 0.32s;}

/* The marker draws the highlight once the words are in place. */
.motion main :is(h1.h, h1.h + p) .highlight{background-repeat: no-repeat; animation: mv-sweep 0.65s var(--mv-out) 0.5s backwards;}

/* Icons pop, the Coming Soon tag swings as if just pinned up. */
.motion main .hero__icons .verb-icon{animation: mv-pop 0.6s var(--mv-spring) 0.1s backwards;}
.motion main .hero__icons .badge{animation: mv-swing 0.8s var(--mv-out) 0.45s backwards;}

/* Framed pictures and first-screen cards lift off the page as their hard shadow grows. */
.motion main :is(.hero__photo.photo--framed, .hero__frame, .of-photo){animation: mv-land 0.8s var(--mv-out) 0.18s backwards;}
.motion :is(.page--join .panel, .page--act .register, .page--get .browser__card){animation: mv-land 0.8s var(--mv-out) 0.3s backwards;}

/* Stickers are slapped on last, then turn very slowly for as long as you stay. */
.motion .hero__sticker{animation: mv-slap 0.75s var(--mv-spring) 0.75s backwards;}
.motion .sticker__shape{transform-origin: 50% 50%; animation: mv-spin 70s linear infinite;}

/* ---- 3. Scroll reveals (classes set by motion.js) ----------------------------------- */

.mv{opacity: 0; translate: 0 22px;}
.mv[data-mv="land"]{translate: 7px 7px; box-shadow: 0 0 0 0 transparent !important;}
.mv[data-mv="slap"]{translate: none; scale: 1.4; rotate: -14deg;}
.mv-run{transition: opacity 0.55s var(--mv-out) var(--mv-d, 0ms), translate 0.7s var(--mv-out) var(--mv-d, 0ms), box-shadow 0.7s var(--mv-out) var(--mv-d, 0ms), scale 0.65s var(--mv-spring) var(--mv-d, 0ms), rotate 0.65s var(--mv-spring) var(--mv-d, 0ms) !important;}
/* Highlights inside a revealed block are drawn a moment after it arrives. */
.mv-hl{background-repeat: no-repeat !important; background-size: 0% 100% !important;}
.mv-hl-run{background-repeat: no-repeat; background-size: 100% 100%; transition: background-size 0.7s var(--mv-out) calc(var(--mv-d, 0ms) + 280ms);}
.mv-swing{animation: mv-swing 0.8s var(--mv-out) calc(var(--mv-d, 0ms) + 350ms) backwards;}

/* ---- Photos drift inside their frames as the page scrolls --------------------------- */
@supports (animation-timeline: view()){
  /* overflow-x: hidden makes .page a scroll container, which would capture view() timelines;
     clip keeps the same visual result without doing that. */
  .page{overflow-x: clip;}
  .motion img.photo{animation: mv-drift linear both; animation-timeline: view(); animation-range: cover;}
  .motion main .hero__photo.photo--framed{animation: mv-land 0.8s var(--mv-out) 0.18s backwards, mv-drift linear both; animation-timeline: auto, view(); animation-range: normal, cover;}
}

/* ---- Page to page: a short cross-fade, with the header held steady ------------------- */
@view-transition{navigation: auto;}
.site-header{view-transition-name: site-header;}
::view-transition-old(root){animation-duration: 0.16s;}
::view-transition-new(root){animation-duration: 0.26s;}

}

@media print{
  .mv{opacity: 1 !important; translate: none !important; scale: none !important; rotate: none !important;}
  .mv-hl{background-size: 100% 100% !important;}
}
