/* Garden visitors (bee, butterflies, blue jay, hummingbird) and ground crawlers: on the front page (.splash, at the
   basket) and on the member Home: at the top as it opens and on the wildflower meadow at its foot (.v-stage, made by
   js/visitors/top.js and meadow.js).
   Shared rules first, then one section per creature, each scoped to its own class (.v-bee, .v-bfly, .v-jay, .v-hb,
   .v-crawl) so each creature can be worked on separately. Behaviour lives in js/visitors/.
   Wing motion follows the real 3-D stroke as it reads in our 2-D view: no in-plane angling where the real motion is
   out of the picture plane. */

/* ---------- shared ---------- */
.splash .hero { position: relative; }
.splash { overflow-x: clip; }
.splash .hero-art { position: relative; z-index: 2; }   /* crawlers walk in front of the basket, the flying visitor above them */
/* The meadow stage: a strip over the wildflowers at the foot of a member page and the space just above them, clipped
   (so nothing leaves it: never over the tab bar, no sideways scroll) and never in the way. */
.shell-main.has-v-stage { position: relative; }
.v-stage { position: absolute; z-index: 3; overflow: hidden; pointer-events: none; transition: opacity .5s ease-out; }
.v-stage.is-leaving { opacity: 0; }
/* The top of the member Home (js/visitors/top.js): a strip fixed over the top of the window, above the header bar. */
.v-stage.v-top { position: fixed; top: 0; left: 0; right: 0; z-index: 21; }
@media print { .v-stage { display: none !important; } }
:is(.splash, .v-stage) .visitor { position: absolute; left: 0; top: 0; z-index: 4; pointer-events: none; will-change: transform;
  filter: drop-shadow(0 6px 6px rgba(60, 50, 20, .14)); }
:is(.splash, .v-stage) .visitor .v-art { position: absolute; inset: 0; display: block; }
:is(.splash, .v-stage) .visitor svg { display: block; width: 100%; height: 100%; overflow: visible; }
:is(.splash, .v-stage) .visitor .v-wing { transform-box: fill-box; }
:is(.splash, .v-stage) .visitor .v-left { transform-origin: 100% 60%; }
:is(.splash, .v-stage) .visitor .v-right { transform-origin: 0% 60%; }
:is(.splash, .v-stage) .visitor .v-near, :is(.splash, .v-stage) .visitor .v-far { transform-origin: 30% 85%; }
:is(.splash, .v-stage) .visitor .v-perched { opacity: 0; }
:is(.splash, .v-stage) .visitor.is-perched .v-art:not(.v-perched) { opacity: 0; }
:is(.splash, .v-stage) .visitor.is-perched .v-perched { opacity: 1; }
/* In flight the sitting painting is never shown, whatever opacity the script last left on it (the blue jay's perched
   turns set it inline): otherwise it shows under the flying bird as it takes off, two birds at once. */
:is(.splash, .v-stage) .visitor:not(.is-perched) .v-art.v-perched { opacity: 0 !important; }
@media (prefers-reduced-motion: reduce) { :is(.splash, .v-stage) .visitor .v-wing { animation: none !important; } }

/* ---------- bee (.v-bee) ----------
   Spec: scratchpad motion-bee.md. ~150–200 beats/s only reads as a blur: in flight each wing is a translucent fan —
   the painted wing at mid-stroke plus two faint copies (.v-ghost, made by bee.js) at the stroke's forward and back
   ends — shimmering on 21–27 ms step cycles. Landed, the wings fold back over the abdomen and the copies vanish.
   The bee has a turnaround (.v-side, .v-y45, .v-y90, .v-y135, .v-top), cross-faded by bee.js when it turns; each view
   folds and fans its wings its own way (face-on and from above the stroke is mirrored for the right-hand wing). */
:is(.splash, .v-stage) .v-bee .v-art { transform-origin: 50% 72%; }
:is(.splash, .v-stage) .v-bee .v-view { transition: opacity .075s linear; }
:is(.splash, .v-stage) .v-bee .v-ghost { opacity: 0; }
:is(.splash, .v-stage) .v-bee .v-wing { transition: transform .22s cubic-bezier(.3, .7, .4, 1), opacity .22s; }
:is(.splash, .v-stage) .v-bee.v-flap .v-wing { transition: none; animation: v-bee-mid .021s steps(1, end) infinite; }
:is(.splash, .v-stage) .v-bee.v-flap .v-ghost { filter: blur(.7px); }
:is(.splash, .v-stage) .v-bee.v-flap .v-ghost.g1 { transform: rotate(-26deg) scale(.9); animation: v-bee-end .027s steps(1, end) infinite; }
:is(.splash, .v-stage) .v-bee.v-flap .v-ghost.g2 { transform: rotate(20deg) scale(.84); animation: v-bee-end .023s steps(1, end) infinite reverse; }
:is(.splash, .v-stage) .v-bee.v-flap .v-y90 .v-ghost.g1.v-left { transform: rotate(-14deg) scale(.85); }
:is(.splash, .v-stage) .v-bee.v-flap .v-y90 .v-ghost.g2.v-left { transform: rotate(18deg) scale(.6); }
:is(.splash, .v-stage) .v-bee.v-flap .v-y90 .v-ghost.g1.v-right { transform: rotate(14deg) scale(.85); }
:is(.splash, .v-stage) .v-bee.v-flap .v-y90 .v-ghost.g2.v-right { transform: rotate(-18deg) scale(.6); }
:is(.splash, .v-stage) .v-bee.v-flap .v-top .v-ghost.g1.v-left { transform: rotate(-34deg); }
:is(.splash, .v-stage) .v-bee.v-flap .v-top .v-ghost.g2.v-left { transform: rotate(14deg); }
:is(.splash, .v-stage) .v-bee.v-flap .v-top .v-ghost.g1.v-right { transform: rotate(34deg); }
:is(.splash, .v-stage) .v-bee.v-flap .v-top .v-ghost.g2.v-right { transform: rotate(-14deg); }
@keyframes v-bee-mid { 0% { opacity: .34; transform: rotate(-4deg) scale(.86); } 50% { opacity: .24; transform: rotate(5deg) scale(.8); } }
@keyframes v-bee-end { 0% { opacity: .2; } 50% { opacity: .1; } }
/* folded: flat back over the abdomen (side-type views); face-on they fold away from us behind the body (short);
   from above they close in over the abdomen */
:is(.splash, .v-stage) .v-bee.v-rest .v-side .v-left, :is(.splash, .v-stage) .v-bee.v-still .v-side .v-left { transform: rotate(58deg) scaleY(.62); }
:is(.splash, .v-stage) .v-bee.v-rest .v-side .v-right, :is(.splash, .v-stage) .v-bee.v-still .v-side .v-right { transform: rotate(44deg) scaleY(.7); }
:is(.splash, .v-stage) .v-bee.v-rest .v-y45 .v-left { transform: rotate(54deg) scaleY(.62); }
:is(.splash, .v-stage) .v-bee.v-rest .v-y45 .v-right { transform: rotate(42deg) scaleY(.7); }
:is(.splash, .v-stage) .v-bee.v-rest .v-y135 .v-left { transform: rotate(50deg) scaleY(.62); }
:is(.splash, .v-stage) .v-bee.v-rest .v-y135 .v-right { transform: rotate(38deg) scaleY(.7); }
:is(.splash, .v-stage) .v-bee.v-rest .v-y90 .v-left { transform: rotate(25deg) scale(.38); }
:is(.splash, .v-stage) .v-bee.v-rest .v-y90 .v-right { transform: rotate(-25deg) scale(.38); }
:is(.splash, .v-stage) .v-bee.v-rest .v-top .v-left { transform: rotate(14deg); }
:is(.splash, .v-stage) .v-bee.v-rest .v-top .v-right { transform: rotate(-14deg); }
:is(.splash, .v-stage) .v-bee.v-still .v-ghost { display: none; }

/* ---------- butterflies (.v-bfly) ----------
   All wing motion is driven per frame by js/visitors/butterfly.js (spec: motion-butterfly.md): in flight each wing
   is scaleX(cos stroke angle) about its hinge on the body line (the stroke is out of the picture plane — never an
   in-plane rotation); perched, the closed wings open as scaleY(cos opening angle) about the wing root with a slight
   skew. A perched turn swaps painted views (side → y45 → y90, mirrored back) — never a squash. CSS only cross-fades. */
:is(.splash, .v-stage) .v-bfly .v-wing, :is(.splash, .v-stage) .v-bfly .v-pwings { animation: none; transition: none; }
:is(.splash, .v-stage) .v-bfly .v-art { transition: opacity .16s ease-out; }
/* perched turnaround views (y45, y90): hidden until the script swaps one in (inline opacity, 60–90 ms cross-fade) */
:is(.splash, .v-stage) .v-bfly .v-bview { opacity: 0; }
@media (prefers-reduced-motion: reduce) { :is(.splash, .v-stage) .v-bfly .v-art { transition: none; } }

/* ---------- blue jay (.v-jay) ----------
   Side view, the stroke mostly out of the picture plane (Muybridge pl. 755): bluejay.js drives each wing frame by frame
   from its shoulder — vertical foreshortening (scaleY through zero to below the body), a narrower flexed upstroke
   (scaleX) and a small in-plane sweep — plus the perched jay's head, crest, tail and stance. No CSS keyframes here, so
   nothing fights the script; the far wing sits a little dimmer behind the body. */
:is(.splash, .v-stage) .v-jay .v-wing { will-change: transform; }
:is(.splash, .v-stage) .v-jay .v-far { opacity: .9; }
/* turnaround views (yaw 45–180) of the perched jay: only while perched, and only the one(s) the script shows */
:is(.splash, .v-stage) .v-jay .v-view { opacity: 0; }
:is(.splash, .v-stage) .v-jay:not(.is-perched) .v-view { visibility: hidden; }

/* ---------- hummingbird (.v-hb) ----------
   ~50 beats/s can't be animated literally, so fake the blur: while flying or hovering the painting's blur fan
   shimmers (three slightly different angles/opacities on a 54ms step cycle), the near wing flips between its two
   extremes every frame as a faint ghost, and the far wing is hidden. Perched, the folded pose shows. */
:is(.splash, .v-stage) .v-hb .v-blur { display: none !important; }
:is(.splash, .v-stage) .v-hb.v-flap .v-blur { display: inline !important; animation: v-hb-shimmer .054s steps(1, end) infinite; }
:is(.splash, .v-stage) .v-hb.v-flap .v-far { opacity: 0; }
:is(.splash, .v-stage) .v-hb.v-flap .v-near { opacity: .32; animation: v-hb-beat .03s steps(1, end) infinite; }
:is(.splash, .v-stage) .v-hb.v-flap:not(:has(.v-blur)) .v-near { opacity: .7; }
/* In fast flight the stroke plane tilts with the body: the fan sweeps back (JS sets --hb-sweep, 0 to -10deg); the
   individual `rotate` property composes with the shimmer's transform. Tail fan and perched parts move by SVG attribute. */
:is(.splash, .v-stage) .v-hb.v-flap .v-blur, :is(.splash, .v-stage) .v-hb.v-flap .v-near { rotate: var(--hb-sweep, 0deg); }
@keyframes v-hb-shimmer { 0% { opacity: .95; transform: rotate(0deg); } 33% { opacity: .7; transform: rotate(-5deg) scaleY(.94); } 66% { opacity: .85; transform: rotate(4deg); } }
@keyframes v-hb-beat { 0% { transform: rotate(0deg); } 50% { transform: rotate(70deg) scaleY(.85); } }
/* Turnaround views (inlined by the module as .v-hb-alt .hb-v45 / .hb-v90; the module drives their opacity). Facing
   us (y90) the near wing is on the LEFT, so its ghost flips the other way; the blur fan there covers both wings. */
:is(.splash, .v-stage) .v-hb.v-flap .hb-v90 .v-near { animation-name: v-hb-beat-left; }
@keyframes v-hb-beat-left { 0% { transform: rotate(0deg); } 50% { transform: rotate(-70deg) scaleY(.85); } }
:is(.splash, .v-stage) .v-hb .v-hb-alt { will-change: opacity, transform; }

/* ---------- ground crawlers (.v-crawl: snail, caterpillar, inchworm) ---------- */
/* Every pose is computed per frame in js/visitors/crawlers.js (no CSS keyframes); the inchworm's body is redrawn
   along its spine, so only #inch-flat is shown. A crawler that starts on screen fades in; the snail's slime trail is
   a thin wet sheen that fades out with distance behind its tail. */
:is(.splash, .v-stage) .v-crawl { position: absolute; left: 0; z-index: 3; pointer-events: none; will-change: transform; transform-origin: 50% 50%;
  transition: opacity 1.4s ease-out; }
:is(.splash, .v-stage) .v-crawl svg { display: block; overflow: visible; }
:is(.splash, .v-stage) .v-crawl.c-inchworm #inch-loop { display: none; }
/* turnaround (three-quarter) art for turns in depth; cross-faded with the side view by crawlers.js */
:is(.splash, .v-stage) .v-crawl .v-y45 { position: absolute; left: 0; top: 0; opacity: 0; transform-origin: 50% 90%; }
:is(.splash, .v-stage) .v-crawl > svg { position: relative; }
:is(.splash, .v-stage) .v-crawl-trail { position: absolute; left: 0; z-index: 3; height: 1.6px; border-radius: 1px; pointer-events: none;
  background: linear-gradient(90deg, rgba(214, 228, 232, 0), rgba(214, 228, 232, .45) 70%, rgba(236, 246, 250, .75));
  box-shadow: 0 .5px 0 rgba(120, 140, 150, .12); transition: opacity 4s ease-out; }
:is(.splash, .v-stage) .v-crawl-trail.is-left { background: linear-gradient(270deg, rgba(214, 228, 232, 0), rgba(214, 228, 232, .45) 70%, rgba(236, 246, 250, .75)); }
@media (prefers-reduced-motion: reduce) { :is(.splash, .v-stage) .v-crawl { transition: none; } }
