/* =====================================================================
   SUNLEAF motion system
   One set of durations and curves for the whole site, so every movement
   feels related. Each kind of element has its own entrance: headlines rise
   word by word behind a mask, photos unveil from the bottom while settling,
   lists arrive in sequence, text eases up. Nothing bounces, nothing spins.
   Only transform, opacity and clip-path animate (smooth on cheap phones).
   ===================================================================== */
:root {
  --m-fast: 180ms;
  --m-base: 420ms;
  --m-slow: 900ms;
  --m-page: 520ms;
  --m-out: cubic-bezier(.22, 1, .36, 1);        /* settles gently: entrances */
  --m-in: cubic-bezier(.55, 0, 1, .45);         /* leaves quickly: exits */
  --m-inout: cubic-bezier(.65, 0, .35, 1);      /* moves across: page parts */
  --m-step: 70ms;                               /* gap between items in a sequence */
}

/* ---------------------------------------------------------------- page to page
   The header and the order buttons stay put; the page underneath changes. */
@view-transition { navigation: auto; }
.site-header { view-transition-name: site-header; }
.wa-float { view-transition-name: wa-float; }
.mbar { view-transition-name: mbar; }
::view-transition-group(site-header), ::view-transition-group(wa-float), ::view-transition-group(mbar) { animation: none; }
::view-transition-old(root) { animation: vt-out 240ms var(--m-in) both; }
::view-transition-new(root) { animation: vt-in var(--m-page) var(--m-out) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-14px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(22px); } }

/* Fallback for browsers without view transitions */
.js-motion body.is-leaving main, .js-motion body.is-leaving .site-footer { opacity: 0; transform: translateY(-12px); transition: opacity 220ms var(--m-in), transform 220ms var(--m-in); }
.js-motion.no-vt main { animation: page-in var(--m-page) var(--m-out) both; }
@keyframes page-in { from { opacity: 0; transform: translateY(18px); } }

/* ---------------------------------------------------------------- entrances
   Hidden only when JavaScript runs (.js-motion), and always shown after 3s
   as a safety net (.motion-done), so content can never get stuck invisible. */
.js-motion:not(.motion-done) [data-reveal="up"]:not(.in),
.js-motion:not(.motion-done) [data-reveal="hero"]:not(.in) > * { opacity: 0; transform: translateY(26px); }
[data-reveal="up"], [data-reveal="hero"] > * { transition: opacity var(--m-slow) var(--m-out), transform var(--m-slow) var(--m-out); }
[data-reveal="hero"] > *:nth-child(2) { transition-delay: 60ms; }
[data-reveal="hero"] > *:nth-child(3) { transition-delay: 120ms; }
[data-reveal="hero"] > *:nth-child(4) { transition-delay: 260ms; }
[data-reveal="hero"] > *:nth-child(5) { transition-delay: 340ms; }

/* Photos: unveil upward from the bottom edge while the picture settles from a slight zoom.
   The clip sits on the picture, never on the observed frame (a clipped frame counts as unseen). */
[data-reveal="image"] :is(img, video, iframe) { clip-path: inset(0 0 0 0); transition: clip-path 1.1s var(--m-inout), transform 1.6s var(--m-out); }
.js-motion:not(.motion-done) [data-reveal="image"]:not(.in) :is(img, video, iframe) { clip-path: inset(100% 0 0 0); transform: scale(1.12); }
[data-reveal="image"] .welcome__portrait { transition-delay: 250ms; }

/* Sequences: children arrive one after another */
.js-motion:not(.motion-done) [data-reveal="stagger"]:not(.in) > * { opacity: 0; transform: translateY(30px); }
[data-reveal="stagger"] > * { transition: opacity var(--m-slow) var(--m-out), transform var(--m-slow) var(--m-out); transition-delay: calc(var(--i, 0) * var(--m-step)); }

/* Headlines: words rise from behind a mask */
.w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .12em; margin-bottom: -.12em; }
.w > .wi { display: inline-block; transition: transform 1s var(--m-out); transition-delay: calc(var(--i, 0) * 45ms); }
.js-motion:not(.motion-done) [data-split]:not(.in) .wi { transform: translateY(108%); }
/* the home headline rises line by line */
.hero__title[data-split="lines"] > span { overflow: hidden; padding-bottom: .1em; margin-bottom: -.1em; }
.hero__title[data-split="lines"] > span > .li { display: inline-block; transition: transform 1.1s var(--m-out); transition-delay: calc(var(--i, 0) * 110ms + 80ms); }
.js-motion:not(.motion-done) .hero__title[data-split="lines"]:not(.in) .li { transform: translateY(110%); }
/* the home intro, photo and facts follow the headline */
.hero .hero__aside[data-reveal] { transition-delay: 420ms; }
.hero .hero__media[data-reveal] { transition-delay: 300ms; }
.hero .facts-rail[data-reveal] > * { transition-delay: calc(700ms + var(--i, 0) * 80ms); }

/* ---------------------------------------------------------------- scroll linked depth
   The big photos drift slightly slower than the page (supported browsers only). */
@supports (animation-timeline: view()) {
  .hero__media img, .commitment__img img, .farm-grid .f1 img {
    animation: drift linear both; animation-timeline: view(); animation-range: entry 0% exit 100%;
  }
  @keyframes drift { from { transform: translateY(-4%) scale(1.08); } to { transform: translateY(4%) scale(1.08); } }
  .js-motion:not(.motion-done) .hero__media:not(.in) img { animation: none; }
  .hero__media.in img { transition: clip-path 1.1s var(--m-inout); }
}

/* ---------------------------------------------------------------- small interactions */
.btn { transition: background var(--m-fast) ease, border-color var(--m-fast) ease, color var(--m-fast) ease, transform var(--m-fast) var(--m-out), box-shadow var(--m-base) var(--m-out); }
.btn:hover { box-shadow: 0 8px 22px rgba(0, 59, 122, .18); }
.btn:active { transform: translateY(1px) scale(.985); box-shadow: none; }
.btn svg { transition: transform var(--m-base) var(--m-out); }
.btn:hover svg use[href="#i-wa"] { transform-origin: center; }
.btn:hover svg { transform: rotate(-10deg) scale(1.08); }
.link-arrow { background: linear-gradient(currentColor, currentColor) 0 100% / 0 2px no-repeat; border-bottom-color: color-mix(in srgb, currentColor 25%, transparent);
              transition: background-size var(--m-base) var(--m-out), color var(--m-fast); }
.link-arrow:hover { background-size: 100% 2px; }
.nav__links a { transition: color var(--m-fast); }

/* eggs wobble in turn when a tray is hovered */
.tray__art svg ellipse:not([fill="#fff"]) { transform-box: fill-box; transform-origin: 50% 90%; }
.tray:hover .tray__art svg ellipse:not([fill="#fff"]) { animation: egg-wobble .7s var(--m-out) both; }
.tray:hover .tray__art svg ellipse:nth-of-type(4n+1) { animation-delay: 0ms; }
.tray:hover .tray__art svg ellipse:nth-of-type(4n+2) { animation-delay: 60ms; }
.tray:hover .tray__art svg ellipse:nth-of-type(4n+3) { animation-delay: 120ms; }
.tray:hover .tray__art svg ellipse:nth-of-type(4n) { animation-delay: 180ms; }
@keyframes egg-wobble { 30% { transform: rotate(-9deg); } 60% { transform: rotate(6deg); } 100% { transform: rotate(0); } }

/* photos breathe on hover where they are links or galleries */
.gallery__item img, .photo-row img, .proof img, .cert__doc img { transition: transform var(--m-slow) var(--m-out); }
.gallery__item:hover img, .photo-row figure:hover img, .proof figure:hover img { transform: scale(1.04); }
.gallery__item { overflow: hidden; }
.gallery__item img { border-radius: var(--r); }

/* order builder: the message updates with a soft crossfade */
.bubble.is-updating { animation: bubble .32s var(--m-out); }
@keyframes bubble { from { opacity: .35; transform: translateY(4px); } }
.sizes label { transition: border-color var(--m-fast), background var(--m-fast), transform var(--m-fast) var(--m-out); }
.sizes label:active { transform: scale(.97); }

/* header tucks away when reading down, returns when scrolling up */
.site-header { transition: transform var(--m-base) var(--m-inout), border-color .2s, box-shadow .2s; }
.header-hidden .site-header { transform: translateY(-100%); }
.jump { transition: top var(--m-base) var(--m-inout); }
.header-hidden .jump { top: 0; }

/* phone menu: links arrive in sequence */
@media (max-width: 980px) {
  .nav__menu .nav__links li, .nav__menu .nav__contact, .nav__menu > .btn { opacity: 0; transform: translateY(14px); transition: opacity var(--m-base) var(--m-out), transform var(--m-base) var(--m-out); }
  .nav__menu.is-open .nav__links li, .nav__menu.is-open .nav__contact, .nav__menu.is-open > .btn { opacity: 1; transform: none; }
  .nav__menu.is-open .nav__links li { transition-delay: calc(var(--i, 0) * 40ms + 60ms); }
  .nav__menu.is-open .nav__contact { transition-delay: 420ms; }
  .nav__menu.is-open > .btn { transition-delay: 480ms; }
}

/* lightbox opens with a gentle zoom */
.lightbox.is-open { animation: lb-in var(--m-base) var(--m-out) both; }
.lightbox.is-open img { animation: lb-img .6s var(--m-out) both; }
@keyframes lb-in { from { opacity: 0; } }
@keyframes lb-img { from { opacity: 0; transform: scale(.94); } }

/* forms: a sent message replaces the form smoothly */
.form__done { animation: done-in .7s var(--m-out) both; }
@keyframes done-in { from { opacity: 0; transform: translateY(16px); } }

/* ---------------------------------------------------------------- reduced motion */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  [data-reveal], [data-reveal] *, .w > .wi, .li { transition: none !important; animation: none !important; transform: none !important; clip-path: none !important; opacity: 1 !important; }
  .header-hidden .site-header { transform: none; }
  .tray:hover .tray__art svg ellipse { animation: none; }
}
