/* Living petals · garden day (layer/particles/012), fork of layer/particles/002 for INV-01 v2 · Luxe: the garden layer.
   As pa002, plus: a gust of petals when the gatefold opens, the breeze a fast scroll sends to the sections, the light of
   the day (a morning, pearl and lilac tint behind the page), a rose stem under each heading and the butterfly that
   lands on each one. From pa002,
   forked from layer/particles/001. Petals take the couple's colour. With JS they are moved by one loop in section.js (drift, lift
   with a fast scroll, pushed by a pressed finger or mouse, one more petal for each touched full rose); without it the
   CSS fall below still runs. The two background floral sprays drift with the scroll, as in pa001. */
.pa012 { --pa012-tint: color-mix(in oklab, var(--c-primary) 70%, white); }
.pa012-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.pa012-shape { fill: var(--pa012-c, var(--pa012-tint)); }
.pa012-bg { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.pa012-bg__spray { position: absolute; width: min(64vw, 440px); height: auto; opacity: .3; }
.pa012-bg__spray--1 { top: 24%; right: -24vw; transform: rotate(100deg); }
.pa012-bg__spray--2 { top: 58%; left: -26vw; transform: rotate(-80deg) scaleX(-1); }

/* falling petals: only after opening, never in reduced motion; z-index 0 = behind every section, never over text */
.pa012-petals { position: fixed; inset: 0; z-index: 0; display: none; overflow: hidden; pointer-events: none; }
html.kjy-opened:not(.motion-reduce) .pa012-petals { display: block; }
.pa012-petal { position: absolute; top: -40px; left: var(--pa012-x); width: var(--pa012-size, 16px); opacity: .7; will-change: transform; animation: pa012-fall var(--pa012-d, 20s) linear var(--pa012-delay, 0s) infinite; }
.pa012-petal svg { display: block; width: 100%; height: auto; animation: pa012-sway calc(var(--pa012-d, 20s) / 4) ease-in-out var(--pa012-delay, 0s) infinite alternate; }
.pa012-petal:nth-child(n+8), .pa012-petal--user { display: none; }
html.kjy-lite .pa012-petal:nth-child(n+5) { display: none; }
@keyframes pa012-fall { to { transform: translate3d(0, calc(100vh + 80px), 0) rotate(240deg); } }
@keyframes pa012-sway { from { transform: translateX(-18px) rotate(-12deg); } to { transform: translateX(18px) rotate(14deg); } }

/* moving (is-moving; never .is-live, which marks a Tier-3 live layer for the engine and live-check): section.js moves the petals that carry .is-on */
.pa012.is-moving .pa012-petal, .pa012.is-moving .pa012-petal svg { animation: none; }
.pa012.is-moving .pa012-petal { display: none; top: 0; left: 0; }
.pa012.is-moving .pa012-petal.is-on { display: block; }
.pa012.is-moving .pa012-petal--user { width: 16px; }

/* the gust at the open: its own short-lived layer over the opening panels (removed when the last petal fades) */
.pa012-gust { position: fixed; inset: 0; z-index: 2147483000; overflow: hidden; pointer-events: none;
  --pa012-tint: color-mix(in oklab, var(--c-primary) 70%, white); }
.pa012-gust .pa012-petal { display: block; top: 0; left: 0; animation: none; opacity: 0; }
.pa012-gust .pa012-petal svg { animation: none; }
.pa012-gust .pa012-petal:nth-child(3n+1) { --pa012-c: color-mix(in oklab, var(--c-primary) 85%, white); }
.pa012-gust .pa012-petal:nth-child(3n+2) { --pa012-c: color-mix(in oklab, var(--c-primary) 55%, white); }

/* the light of the day: three tints behind the page; only their opacity changes with the scroll */
.pa012-sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.pa012-sky i { position: absolute; inset: 0; opacity: 0; will-change: opacity; }
.pa012-sky__morning { background: linear-gradient(180deg, rgb(206 186 242 / .42) 0%, rgb(247 244 251 / 0) 70%); }
.pa012-sky__golden { background: linear-gradient(180deg, rgb(232 222 250 / 0) 0%, rgb(232 222 250 / .32) 100%); }
.pa012-sky__dusk { background: linear-gradient(180deg, rgb(214 196 245 / .2) 0%, rgb(190 166 235 / .22) 100%); }

/* a rose stem under each heading (drawn once by section.js) */
.pa012-stem { display: block; width: 132px; height: 22px; margin: 6px auto 0; overflow: visible; }
@media (min-width: 820px) { .pa012-stem { width: 156px; height: 26px; } }
.pa012-stem__line { fill: none; stroke: var(--c-secondary); stroke-width: 1.2; stroke-linecap: round; }
.pa012-stem__leaf { fill: var(--c-secondary); fill-opacity: .85; }
.pa012-stem__bud { fill: var(--c-primary); }
.pa012-stem__calyx { fill: var(--c-secondary); }

/* the butterfly (section.js; on <body>, so not scoped under .pa012): a real one, two photo wings hinged on the body that
   flap in 3D (they fold toward you), a small bob with each beat, a short glide on long flights; perched, wings half open */
.pa012-bf { position: absolute; left: 0; top: 0; z-index: 30; width: 44px; aspect-ratio: 192 / 144; pointer-events: none; opacity: 0; transition: opacity .5s ease;
  filter: drop-shadow(0 3px 2px rgb(52 46 74 / .22)); }
.pa012-bf.is-on { opacity: 1; } .pa012-bf.is-perched { pointer-events: auto; cursor: pointer; }
.pa012-bf__bob { position: absolute; inset: 0; perspective: 220px; }
.pa012-bf__wing { position: absolute; top: 0; width: 50%; height: 100%; background: no-repeat center / 100% 100%; }
.pa012-bf__wing--l { left: 0; transform-origin: 100% 50%; background-image: var(--glk-bf-wing-l); transform: rotateY(30deg); }
.pa012-bf__wing--r { right: 0; transform-origin: 0 50%; background-image: var(--glk-bf-wing-r); transform: rotateY(-30deg); }
.pa012-bf__body { position: absolute; left: 50%; top: 0; width: 9%; height: 100%; translate: -50% 0; background: var(--glk-bf-body) no-repeat center / 100% 100%; }
.pa012-bf.is-flying .pa012-bf__bob { animation: pa012-flap 120ms ease-in-out infinite; }
.pa012-bf.is-flying .pa012-bf__wing--l { animation: pa012-flap-l 120ms ease-in-out infinite; }
.pa012-bf.is-flying .pa012-bf__wing--r { animation: pa012-flap-r 120ms ease-in-out infinite; }
.pa012-bf.is-glide .pa012-bf__bob { animation: none; }
.pa012-bf.is-glide .pa012-bf__wing--l { animation: none; transform: rotateY(22deg); }
.pa012-bf.is-glide .pa012-bf__wing--r { animation: none; transform: rotateY(-22deg); }
.pa012-bf.is-landing .pa012-bf__wing--l { animation: pa012-land-l 600ms ease-in-out 1 both; }
.pa012-bf.is-landing .pa012-bf__wing--r { animation: pa012-land-r 600ms ease-in-out 1 both; }
.pa012-bf.is-rest .pa012-bf__wing--l { animation: pa012-rest-l 900ms ease-in-out 1; }
.pa012-bf.is-rest .pa012-bf__wing--r { animation: pa012-rest-r 900ms ease-in-out 1; }
@keyframes pa012-flap { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes pa012-flap-l { 0%, 100% { transform: rotateY(12deg); } 50% { transform: rotateY(76deg); } }
@keyframes pa012-flap-r { 0%, 100% { transform: rotateY(-12deg); } 50% { transform: rotateY(-76deg); } }
@keyframes pa012-land-l { 0% { transform: rotateY(70deg); } 40% { transform: rotateY(10deg); } 70% { transform: rotateY(50deg); } 100% { transform: rotateY(30deg); } }
@keyframes pa012-land-r { 0% { transform: rotateY(-70deg); } 40% { transform: rotateY(-10deg); } 70% { transform: rotateY(-50deg); } 100% { transform: rotateY(-30deg); } }
@keyframes pa012-rest-l { 0%, 100% { transform: rotateY(30deg); } 50% { transform: rotateY(68deg); } }
@keyframes pa012-rest-r { 0%, 100% { transform: rotateY(-30deg); } 50% { transform: rotateY(-68deg); } }
@media (min-width: 820px) { .pa012-bf { width: 52px; } }
