/*
 * Cinema and Photography: motion tied to the scroll (CSS scroll-driven animations, no JavaScript).
 * Each effect plays with the scroll position, forwards and backwards, and only where the browser
 * supports view timelines and the visitor has not asked for reduced motion; elsewhere the page is
 * exactly as before. Transforms only (no layout), so scrolling stays smooth. Added 20 Nov 2026.
 *
 * Served as is from public/: the build's CSS minifier folds `animation-timeline: view()` into the
 * `animation` shorthand, where browsers reject it and the whole effect silently disappears.
 */
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    /* Section titles come into focus as they rise: blur and fade, no hard edge. */
    [data-world='cinema'] main :is(.section, .photo, .work) h2 {
      animation: sc-title linear both;
      animation-timeline: view();
      animation-range: entry 10% entry 90%;
    }
    @keyframes sc-title {
      from { opacity: 0; transform: translateY(0.35em); filter: blur(10px); }
      to { opacity: 1; transform: none; filter: blur(0); }
    }

    /* Home: the row of posters is uncovered left to right by a wide feathered edge, slightly out
       of focus at first, like a light sweeping across them. Fully open once the row is on screen. */
    [data-world='cinema'] .posters {
      -webkit-mask-image: linear-gradient(90deg, #000 40%, transparent 60%);
      mask-image: linear-gradient(90deg, #000 40%, transparent 60%);
      -webkit-mask-size: 300% 100%;
      mask-size: 300% 100%;
      -webkit-mask-repeat: no-repeat;
      mask-repeat: no-repeat;
      animation: sc-sweep linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 100%;
    }
    @keyframes sc-sweep {
      from { -webkit-mask-position: 100% 0; mask-position: 100% 0; filter: blur(8px); opacity: 0.5; }
      to { -webkit-mask-position: 0% 0; mask-position: 0% 0; filter: blur(0); opacity: 1; }
    }

    /* Home: the photo tiles come up one after another, and the picture drifts inside its frame. */
    [data-world='cinema'] .photo-cats li {
      animation: sc-rise linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 70%;
    }
    [data-world='cinema'] .photo-cat img {
      animation: sc-drift linear both;
      animation-timeline: view();
      animation-range: cover 0% cover 100%;
    }

    /* Photo pages: each photo rises and settles as it enters. */
    [data-world='cinema'] :is(.masonry, .even) li {
      animation: sc-rise linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 55%;
    }

    /* Work pages: the frames drift slowly inside their rounded windows, the still too. */
    [data-world='cinema'] .work :is(.gallery li, .still) img {
      animation: sc-drift linear both;
      animation-timeline: view();
      animation-range: cover 0% cover 100%;
    }

    @keyframes sc-rise {
      from { opacity: 0; transform: translateY(48px) scale(0.97); }
      to { opacity: 1; transform: none; }
    }
    @keyframes sc-drift {
      from { transform: scale(1.12) translateY(-4%); }
      to { transform: scale(1.12) translateY(4%); }
    }
  }
}
