/* Cobweb site motion. Only transform and opacity animate, so everything stays on the compositor.
   Nothing is hidden unless the runtime is running (html.cw-motion), so pages work without JS. */

:root {
  --cw-reveal-distance: 28px;
  --cw-reveal-duration: 760ms;
  --cw-reveal-ease: cubic-bezier(0.2, 0.7, 0.15, 1);
  --cw-reveal-stagger: 80ms;
}
html.cw-motion-subtle { --cw-reveal-distance: 14px; --cw-reveal-duration: 600ms; }
html.cw-motion-rich { --cw-reveal-distance: 48px; --cw-reveal-duration: 950ms; --cw-reveal-stagger: 110ms; }

/* ───────── reveal on scroll ───────── */
html.cw-motion [data-reveal]:not(.is-revealed) { opacity: 0; }
html.cw-motion [data-reveal] {
  transition:
    opacity var(--cw-reveal-duration) var(--cw-reveal-ease),
    transform var(--cw-reveal-duration) var(--cw-reveal-ease);
  transition-delay: calc(var(--cw-reveal-i, 0) * var(--cw-reveal-stagger));
}
html.cw-motion [data-reveal='up']:not(.is-revealed) { transform: translate3d(0, var(--cw-reveal-distance), 0); }
html.cw-motion [data-reveal='down']:not(.is-revealed) { transform: translate3d(0, calc(var(--cw-reveal-distance) * -1), 0); }
html.cw-motion [data-reveal='left']:not(.is-revealed) { transform: translate3d(var(--cw-reveal-distance), 0, 0); }
html.cw-motion [data-reveal='right']:not(.is-revealed) { transform: translate3d(calc(var(--cw-reveal-distance) * -1), 0, 0); }
html.cw-motion [data-reveal='scale']:not(.is-revealed) { transform: scale(0.96); }
/* After the reveal the element is static again: no lingering layers. */
html.cw-motion [data-reveal].is-done { transition: none; }

/* ───────── parallax ───────── */
[data-parallax] { --cw-shift: 0px; }
/* Compositor path: CSS scroll-driven animation, no JavaScript per frame. */
html.cw-parallax-css [data-parallax] {
  animation: cw-parallax linear both;
  animation-timeline: view();
  animation-range: cover 0% cover 100%;
}
@keyframes cw-parallax {
  from { transform: translate3d(0, calc(var(--cw-shift) * -1), 0); }
  to { transform: translate3d(0, var(--cw-shift), 0); }
}
/* JS fallback writes transform directly; will-change only while the element is on screen. */
html.cw-parallax-js [data-parallax].is-visible { will-change: transform; }

/* A clipping frame for parallax images: the image is taller than the frame so edges never show. */
.cw-parallax-frame { position: relative; overflow: hidden; contain: paint; }
.cw-parallax-frame > [data-parallax] { position: absolute; inset: calc(var(--cw-frame-bleed, 12%) * -1) 0; }
.cw-parallax-frame > [data-parallax] img,
.cw-parallax-frame > [data-parallax] picture { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Long pages: skip rendering work for sections far below the fold. */
.cw-defer { content-visibility: auto; contain-intrinsic-size: auto 900px; }

@media (prefers-reduced-motion: reduce) {
  html.cw-motion [data-reveal] { opacity: 1 !important; transform: none !important; transition: none !important; }
  [data-parallax] { animation: none !important; transform: none !important; }
}
