/* ==========================================================================
   Motion effects (driven by motion.js via data attributes).
   Every diagonal is parallel to the V: a reveal edge's horizontal offset is
   --cut = element height × --v-slope (set per element by motion.js).

   Attributes:
     data-reveal="mask"   diagonal mask reveal (headings, images)
     data-reveal="rise"   fade + rise (paragraphs, lists)
     data-reveal-group    children with data-reveal stagger together
     data-wipe            red/white/navy stripe band crosses the element and reveals it
     data-count="25"      number counts up once (put the final value in the markup)
     .sweep               white light sweep on hover/focus (cards, images) — CSS only
   Hidden start states apply only once motion.js has run (html.motion), and never
   under reduced motion, so content is always visible without JS.
   ========================================================================== */

/* ------------------------------------------------- Diagonal clip (shared) */
.motion [data-reveal="mask"],
.motion [data-wipe] > .wipe__target {
  --r: 0;
  --cut: 2rem;
  clip-path: polygon(
    -1% -10%,
    calc(var(--r) * (102% + var(--cut))) -10%,
    calc(var(--r) * (102% + var(--cut)) - var(--cut)) 110%,
    -1% 110%
  );
}
.motion [data-reveal="mask"].is-revealed,
.motion [data-wipe].is-revealed > .wipe__target { clip-path: none; }

.motion [data-reveal="rise"] { opacity: 0; transform: translateY(1.5rem); }
.motion [data-reveal="rise"].is-revealed { opacity: 1; transform: none; }

/* ------------------------------------------------------------ Stripe wipe */
[data-wipe] { position: relative; }
.wipe__stripes {
  --unit: clamp(0.35rem, 0.8vw, 0.6rem);
  position: absolute;
  z-index: 2;
  top: -1px;
  bottom: -1px;
  left: 0;
  translate: var(--x, 0px) 0;               /* set by motion.js to ride the reveal edge (not `left`: that's a layout shift every frame) */
  display: flex;
  transform: skewX(calc(-1 * var(--v-lean)));
  pointer-events: none;
  opacity: 0;
}
.wipe__stripes span { display: block; height: 100%; }
.wipe__stripes span:nth-child(1) { width: calc(var(--unit) * var(--v-ratio-red)); background: var(--v-red); }
.wipe__stripes span:nth-child(2) { width: calc(var(--unit) * var(--v-ratio-white)); background: var(--v-white); }
.wipe__stripes span:nth-child(3) { width: calc(var(--unit) * var(--v-ratio-navy)); background: var(--v-navy); }

/* ------------------------------------------------------------ Light sweep */
.sweep { position: relative; overflow: hidden; isolation: isolate; }
.sweep::after {
  content: "";
  position: absolute;
  z-index: 3;
  inset: -20% auto -20% 0;
  width: 35%;
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.18) 45%, rgb(255 255 255 / 0.28) 50%, rgb(255 255 255 / 0.18) 55%, transparent);
  transform: translateX(-150%) skewX(calc(-1 * var(--v-lean)));
  pointer-events: none;
}
.sweep:hover::after,
.sweep:focus-within::after,
a.sweep:focus-visible::after {
  transform: translateX(400%) skewX(calc(-1 * var(--v-lean)));
  transition: transform var(--duration-sweep) var(--easing-out);
}
.sweep img { transition: transform var(--duration-slower) var(--easing-out); }
.sweep:hover img, .sweep:focus-within img { transform: scale(1.03); }

/* ---------------------------------------------------------------- Counter */
[data-count] { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  .sweep::after { display: none; }
  .sweep:hover img, .sweep:focus-within img { transform: none; }
}

/* ------------------------------------------------------------------ Print
   Scroll reveals that haven't fired yet would print as blank space (and so
   would Save as PDF). Show everything; !important beats GSAP's inline styles. */
@media print {
  .motion [data-reveal],
  .motion [data-wipe] > .wipe__target {
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
  }
  .wipe__stripes,
  .sweep::after { display: none !important; }
}
