/* Cannabionics v4 ambient motion (package M1), driven by js/v4-fx.js. Loaded after css/v4.css.
   M1 hero depth parallax, M3 plate draw-on, M5 counters, M6 tilt and glow, M7 leaf burst.
   Moves only transform, translate, rotate, opacity and clip-path. Every effect is static and final under reduced motion. */

/* ---------- M1: hero depth. Leaves (front) follow the pointer, the plate (back) drifts against it ---------- */
@media (prefers-reduced-motion: no-preference) {
  .v3-leaf { translate: var(--cb-px, 0px) calc(var(--cb-py, 0px) + var(--cb-pxy, 0px)); }
  .fx-par :is(.v4-plate, .v4-404-leaf) { translate: var(--fx-px, 0px) var(--fx-py, 0px); rotate: var(--fx-rot, 0deg); }
  .fx-par .v4-plate--kohler:not(.v4-plate--hero-kohler) { translate: var(--fx-px, 0px) calc(-50% + var(--fx-py, 0px)); }
  .fx-par.is-animating :is(.v4-plate, .v4-404-leaf, .v3-hero-split__photo, .v3-leaf) { will-change: translate, rotate, transform; }
}
/* the hero plate reads as a botanical engraving behind the photo, not as a watermark nobody sees */
.v3-hero-split .v4-plate { opacity: .24; }
/* spec 1.3: never behind the h1/lead box. From 960 the plate sits over the photo column; below it, behind the photo at the bottom */
@media (min-width: 960px) {
  .v3-hero-split .v4-plate { left: auto; bottom: auto; right: -6%; top: -4%; width: clamp(420px, 48vw, 760px); transform: none; } /* upright: a rotated box would reach back over the h1 */
  .v3-hero-split .v4-plate--plant { top: -2%; width: clamp(360px, 34vw, 540px); }
}
@media (max-width: 959.98px) { .v3-hero-split .v4-plate { left: auto; top: auto; right: -14%; bottom: -2%; } }
.v3-hero-paper .v4-plate { opacity: .16; }
.v4-404-leaf { opacity: .2; }
@media (max-width: 767px) { .v3-hero-split .v4-plate, .v3-hero-paper .v4-plate { opacity: .12; } }

/* ---------- M3: draw-on. A slanted wipe rises from the stem end (bottom of every art file) ---------- */
.v3-js [data-v4-draw] {
  clip-path: polygon(0 130%, 100% 100%, 100% 130%, 0 130%);
  transition: clip-path var(--t-draw) var(--ease-out);
}
.v3-js [data-v4-draw].is-in { clip-path: polygon(0 0, 100% -30%, 100% 130%, 0 130%); }
.v3-js .fx-par [data-v4-draw] { transition-duration: var(--t-grow); }

/* ---------- M5: counters keep their final width while they run ---------- */
.fx-num { white-space: nowrap; }

/* ---------- M6: card tilt with a moving highlight ---------- */
.fx-shine { position: absolute; left: 0; top: 0; pointer-events: none; border-radius: 50%; opacity: 0; }
.fx-shine {
  z-index: 1; width: 520px; height: 520px; margin: -260px 0 0 -260px;
  background: radial-gradient(closest-side, rgba(255,255,255,.2), rgba(255,255,255,0));
  transition: opacity var(--t-base) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  html.v3-js .fx-tilt.is-tilt {
    transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(-3px);
    transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-slow) var(--ease-out);
    will-change: transform;
  }
  .fx-tilt.is-tilt > .fx-shine { opacity: 1; }
}

/* ---------- M7: leaf burst out of the success check ---------- */
.v3-success { position: relative; }
.fx-burst { position: absolute; left: 50%; top: 50%; z-index: 2; width: 0; height: 0; pointer-events: none; color: var(--cb-green); }
.v3-bg-dark .fx-burst, .v3-on-dark .fx-burst, .v3-footer .fx-burst, .v3-tool__result .fx-burst { color: var(--cb-yellow); }
.fx-burst__leaf {
  position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; max-width: none; fill: currentColor; overflow: visible; opacity: 0;
  animation: fx-burst 900ms var(--ease-out) both; will-change: transform, opacity;
}
/* spec: no filled silhouette over 24px, so the long leaflets stay 5 x 24 and the large burst caps at 24 */
.fx-burst--lg .fx-burst__leaf { left: -12px; top: -12px; width: 24px; height: 24px; }
.fx-burst__leaf--long, .fx-burst--lg .fx-burst__leaf--long { left: -2.5px; top: -12px; width: 5px; height: 24px; }
@keyframes fx-burst {
  0%   { opacity: 1; transform: translate(0, 0) rotate(var(--a, 0deg)) scale(.4); }
  55%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--tx), var(--ty)) rotate(calc(var(--a, 0deg) + var(--r, 0deg))) scale(1); }
}
.v3-success.fx-pop::before { animation: fx-pop 320ms var(--ease-out); }
@keyframes fx-pop { 50% { transform: scale(1.15); } }

/* ---------- reduced motion: final states ---------- */
@media (prefers-reduced-motion: reduce) {
  .v3-js [data-v4-draw], .v3-js [data-v4-draw].is-in { clip-path: none; }
  .fx-burst, .fx-shine { display: none; }
}
