/* Airfront landing – gentle motion ("paint soaks into paper").
 * One motif, as in the app: a wash appears and spreads a little (opacity 0→1, scale 0.88→1, 420 ms).
 * No loops, no parallax. Everything turns off with prefers-reduced-motion.
 * Elements start hidden only when JS has run (html.af-motion), so the page is fine without JS.
 */

:root {
  --af-ease: cubic-bezier(0.22, 0.61, 0.36, 1); /* soft ease-out */
  --af-soak: 420ms;   /* washes */
  --af-rise: 520ms;   /* phones, cards */
  --af-fade: 300ms;   /* text, calm sections */
  --af-step: 60ms;    /* stagger step for lists */
}

/* 1. Watercolour washes soak in (hero, section art, card art). */
.af-motion .af-soak {
  opacity: 0;
  transform: scale(0.88);
  transition: opacity var(--af-soak) var(--af-ease), transform var(--af-soak) var(--af-ease);
  transition-delay: var(--af-delay, 0ms);
}
.af-motion .af-soak.is-in { opacity: var(--af-opacity, 1); transform: none; }
/* Washes have their own opacity (about 0.3, sky 0.55–0.6): set --af-opacity on the element. */

/* 2. Phones and cards rise a little and fade in. Use --af-delay for the second phone (120 ms). */
.af-motion .af-rise {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity var(--af-rise) var(--af-ease), transform var(--af-rise) var(--af-ease);
  transition-delay: var(--af-delay, 0ms);
}
.af-motion .af-rise.is-in { opacity: 1; transform: none; }

/* 3. Lists: items (watercolour dots + text) appear one after another. Set style="--i: 0, 1, 2…" on items. */
.af-motion .af-stagger > * {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--af-fade) var(--af-ease), transform var(--af-fade) var(--af-ease);
  transition-delay: calc(var(--i, 0) * var(--af-step));
}
.af-motion .af-stagger.is-in > * { opacity: 1; transform: none; }

/* 4. Calm: the asthma section and anything about emergencies only fades, no movement. */
.af-motion .af-calm {
  opacity: 0;
  transition: opacity var(--af-fade) linear;
}
.af-motion .af-calm.is-in { opacity: 1; }

/* 5. Hover on blog cards: the wash behind the plate grows a touch. */
.af-card .af-card-wash { transition: transform 300ms var(--af-ease); }
.af-card:hover .af-card-wash,
.af-card:focus-within .af-card-wash { transform: scale(1.04); }

/* 6. Links: the underline is painted from the left. */
.af-link {
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 250ms var(--af-ease);
}
.af-link:hover,
.af-link:focus-visible { background-size: 100% 1px; }

/* 7. Wind in the hero background (the one looping motion, kept slow and faint).
 * Gusts: a short, pale sky-blue brush stroke travels along each curve and fades, then rests. Pollen grains,
 * leaves and seeds drift across on it; grains bob, leaves sway and turn over. The birch twig sways around the point where it is cut. motion.js shows the layer
 * (.is-live) and pauses everything while the hero is out of view (.is-paused on [data-af-hero]). */
.af-motion .af-wind.is-live { display: block; animation: af-wind-in 1.6s var(--af-ease) .6s both; }
@keyframes af-wind-in { from { opacity: 0; } }

.af-wind .gust { opacity: 0; animation: af-gust-fade var(--gt) linear var(--gd) infinite; }
.af-wind .g-bleed { stroke-dasharray: 20 300; stroke-dashoffset: 26; animation: af-gust-bleed var(--gt) cubic-bezier(.45, .05, .55, .95) var(--gd) infinite; }
.af-wind .g-wash { stroke-dasharray: 24 300; stroke-dashoffset: 24; animation: af-gust-wash var(--gt) cubic-bezier(.45, .05, .55, .95) var(--gd) infinite; }
@keyframes af-gust-fade { 0% { opacity: 0; } 14%, 50% { opacity: 1; } 70%, 100% { opacity: 0; } }
@keyframes af-gust-bleed { 0% { stroke-dashoffset: 26; } 70%, 100% { stroke-dashoffset: -96; } }
@keyframes af-gust-wash { 0% { stroke-dashoffset: 24; } 70%, 100% { stroke-dashoffset: -100; } }

.af-wind .grain, .af-wind .leaf { transform: translateX(-60px); animation: af-drift var(--gt) linear var(--gd) infinite; }
.af-wind .grain i { animation: af-bob calc(var(--gt) / 6) ease-in-out var(--gd) infinite alternate; }
/* Leaves and seeds: drift like the grains, sway wider and turn over now and then (scaleX flutter). */
.af-wind .leaf i { animation: af-leaf calc(var(--gt) / 5) ease-in-out var(--gd) infinite alternate; }
.af-wind .leaf img { animation: af-flutter calc(var(--gt) / 9) ease-in-out var(--gd) infinite alternate; }
@keyframes af-drift { to { transform: translateX(calc(100vw + 60px)); } }
@keyframes af-leaf { from { transform: translateY(calc(var(--ga) * -1)) rotate(-35deg); } to { transform: translateY(var(--ga)) rotate(55deg); } }
@keyframes af-flutter { from { transform: scaleX(1); } 60% { transform: scaleX(.85); } to { transform: scaleX(.3); } }
@keyframes af-bob { from { transform: translateY(calc(var(--ga) * -1)) rotate(-20deg); } to { transform: translateY(var(--ga)) rotate(25deg); } }

.af-sway { transform-origin: 4% 6%; }
.af-motion .af-sway.is-in { animation: af-sway 6.5s ease-in-out 1s infinite alternate; }
@keyframes af-sway { from { rotate: -.6deg; } to { rotate: 1.3deg; } }

.is-paused .af-wind *, .is-paused .af-sway { animation-play-state: paused !important; }

/* Reduced motion: show everything at once, keep only instant state changes. */
@media (prefers-reduced-motion: reduce) {
  .af-motion .af-soak,
  .af-motion .af-rise,
  .af-motion .af-stagger > *,
  .af-motion .af-calm {
    opacity: var(--af-opacity, 1);
    transform: none;
    transition: none;
  }
  .af-card .af-card-wash,
  .af-link { transition: none; }
  .af-wind { display: none !important; }
  .af-sway { animation: none !important; }
}
