/* PLAN YOUR VISIT MOTION - the applied motion for plan-your-visit.html:
   desktop from 900px (this part) and the phone below it (PHONE, the last
   section). 100-motion-design/motion-guidance.md explains it.

   DESKTOP, from 900px. The selection work behind
   it is in 100-motion-design/plan-your-visit/combined/, where this file is
   selected-motion.css with preview paths; its README.md records the combining
   rules. The head gate in plan-your-visit.html adds pilot-intro-pending at
   900px and up without reduced motion; plan-your-visit-motion.js adds
   pilot-settle-run, which starts the hero push and the hero settle on one
   clock.

   Hero push (hero-photo, from P11): the photo waits slightly small and
   pushes in to its framing over 2.4s on a curve with a long, slow tail.
   The transform multiplies the library's own zoom (the scale property), so
   the rest state is the approved framing.

   Hero settle (hero-copy, from Home): Home's copy entrance, retimed to the
   push. The rules are copied from the style block in
   120-website/site/index.html (only Home's photo and clip rules are left
   out); scale, blur and the 80ms beats are Home's. The words start early
   (0.6s) and take the push's curve, so they share its long tail, and their
   length is derived so the last beat ends with the push:
   2.4s - 0.6s - 2 x 80ms = 1.64s. On Home, with Home's own curve and
   1.18s, the last beat lands as the clip ends. --pilot-clip-at stays 0s.

   The blur keeps this entrance on the main thread, as on Home: Chrome does
   not composite a filter that spreads pixels. */
:root {
  --hero-push-from: 0.93;
  --hero-push-duration: 2.4s;
  --hero-push-ease: cubic-bezier(0.2, 0.55, 0.4, 0.92);
  --hero-text-start: 0.6s;         /* first beat */
  --hero-text-offset: 0s;          /* last beat's end minus the push's end */
  --hero-text-ease: var(--hero-push-ease);
  --pilot-settle-start: var(--hero-text-start);
  --pilot-settle-stagger: 80ms;    /* gap between beats */
  /* Each beat's length; the last beat ends with the push. */
  --pilot-settle-duration: calc(var(--hero-push-duration) + var(--hero-text-offset) - var(--hero-text-start) - 2 * var(--pilot-settle-stagger));
  --pilot-settle-scale: 1.08;
  --pilot-settle-blur: 8px;
  --pilot-settle-ease: var(--hero-text-ease);
}
/* Hero push: --hero-arrive runs the push as a registered number, so it
   multiplies the library's own zoom. On scroll out the photo stays still
   (hero-scroll). */
@property --hero-arrive {
  syntax: "<number>";
  inherits: false;
  initial-value: 1;
}
.pilot-intro-pending .cc-hero__photo { --hero-arrive: var(--hero-push-from); }
.pilot-intro-pending .cc-hero__photo,
.sel-on .cc-hero__photo {
  transform: scale(var(--hero-arrive));
}
.pilot-settle-run .cc-hero__photo {
  animation: hero-push var(--hero-push-duration) var(--hero-push-ease) both;
}
@keyframes hero-push {
  from { --hero-arrive: var(--hero-push-from); }
  to { --hero-arrive: 1; }
}

.pilot-intro-pending .cc-hero__body > * { opacity: 0; }
.pilot-settle-run .cc-hero__body > * {
  transform-origin: left center;
  animation: pilot-settle var(--pilot-settle-duration) var(--pilot-settle-ease) both;
  animation-delay: calc(var(--pilot-settle-start) + var(--pilot-beat, 0) * var(--pilot-settle-stagger) - var(--pilot-clip-at, 0s));
}
.cc-hero__body > .cc-eyebrow,
.cc-hero__body > .cc-hero__title { --pilot-beat: 0; }
.cc-hero__body > .cc-hero__lead { --pilot-beat: 1; }
.cc-hero__body > .cc-hero__actions { --pilot-beat: 2; }
@keyframes pilot-settle {
  from { opacity: 0; scale: var(--pilot-settle-scale); filter: blur(var(--pilot-settle-blur)); }
  to { opacity: 1; scale: 1; filter: blur(0); }
}

/* ---- Bands, below the hero. plan-your-visit-motion.js plays each band's entrances
   as Web Animations with fill "backwards", so a finished element is the
   library's own rendering. These rules hold only the waiting states and the
   scroll-linked renderings. Every rule needs html.sel-on (the head gate). */
@media (min-width: 900px) {

  /* Waiting to enter, copy and photos alike. plan-your-visit-motion.js adds
     .sel-shown in the frame its animation starts. */
  .sel-on [data-sel]:not(.sel-shown) {
    opacity: 0;
  }

  /* Kids and closing photos (kids-photo, closing-photo, P13's settle): the
     picture waits slightly near. */
  .sel-on [data-sel="settle-photo"]:not(.sel-shown) img {
    transform: scale(1.08);
  }

  /* Hairline draw: waits undrawn. Dormant: the service words and hairline
     are still and carry no data-sel-hair hook. */
  .sel-on [data-sel-hair]:not(.sel-shown)::before {
    transform: scaleY(0);
    transform-origin: center top;
  }

  /* Scroll-linked: the room's doors (service-photo, P13, square corners)
     write clip-path on the frame and transform on the picture; the closing
     drift (P13) writes translate on its picture. */
  .sel-on [data-sel-doors] {
    will-change: clip-path;
  }
  .sel-on [data-sel-doors] img,
  .sel-on [data-sel-drift] img {
    will-change: transform, translate;
  }

  /* ---- Poster fan (watch-posters, Home's): Home's rendering unchanged, the
     same graphic and cut lines (watch-sermons.png, 1280 x 541; front poster
     ends at x 718, middle at x 1046). */
  .sel-on [data-sel-fan].sel-fan {
    position: relative;
    isolation: isolate;
  }
  .sel-on [data-sel-fan].sel-fan .cc-media-frame__img {
    position: relative;
    z-index: 3;
    clip-path: inset(0 calc(100% - 718 / 1280 * 100%) 0 0);
  }
  .sel-on [data-sel-fan].sel-fan::before,
  .sel-on [data-sel-fan].sel-fan::after {
    content: "";
    position: absolute;
    inset: 0;
    background: url("photos/watch-sermons.png") center / 100% 100% no-repeat;
    pointer-events: none;
  }
  .sel-on [data-sel-fan].sel-fan::before {
    z-index: 2;
    clip-path: inset(0 calc(100% - 1046 / 1280 * 100%) 0 calc(718 / 1280 * 100%));
    translate: calc(-3% * (1 - var(--sel-fan, 0))) 0;
  }
  .sel-on [data-sel-fan].sel-fan::after {
    z-index: 1;
    clip-path: inset(0 0 0 calc(1046 / 1280 * 100%));
    translate: calc(-6% * (1 - var(--sel-fan, 0))) 0;
  }
}

/* ============================================================================
   PHONE, below 900px. The selection work behind it is in
   100-motion-design/plan-your-visit/combined-mobile/, where this section is
   selected-motion.css with a preview path (the poster image in the fan
   rule); its README.md records the composition and its combining rules.

   Gating: every rule needs html.pm-on, set by the head gate in
   plan-your-visit.html below 900px without reduced motion and removed by its
   fail-safe if the phone runtime in plan-your-visit-motion.js never starts.
   Every rule also sits below 900px. The desktop rules above (sel-on,
   pilot-) are untouched; their hero keyframes and values are reused here:
   @property --hero-arrive, @keyframes hero-push and the --hero-push-*
   properties on :root.

   Entrances below the hero are Web Animations in plan-your-visit-motion.js;
   this section holds the hero clock, the waiting poses and the
   scroll-linked renderings. A finished element is the library's own
   rendering. The "breathe" and settle-b rules are dormant: the Join us
   Sunday photo and the service words carry no data-pm hooks, so they are
   still.
   ============================================================================ */
@media (max-width: 899.98px) {

  /* ---- Hero push (hero photo): waits slightly small, still, and pushes in
     to its framing on desktop's curve and length, about the library's
     focal origin (74% 0%: the top edge has no overhang, so the hold is
     there; every edge stays filled at the start pose). */
  .pm-on.pm-hero-photo-wait .cc-hero__photo {
    --hero-arrive: var(--hero-push-from);
    transform: scale(var(--hero-arrive));
  }
  .pm-on.pm-hero-photo-run .cc-hero__photo {
    transform: scale(var(--hero-arrive));
    animation: hero-push var(--hero-push-duration) var(--hero-push-ease) both;
  }

  /* ---- Softer title fade (hero title), R1: HA's Title rise
     (proposal 2026-11-03-mobile-hero-a) made quieter at Cheyne's request.
     Only "Plan Your Visit" moves; the lead paragraphs and the two buttons
     are still from first paint. Same still mask at the title's foot and
     the same hero clock as HA; HA's own implementation stays in its
     proposal folder.
       Rise   0.45em (about 16px) on the push's curve over 2s from 0.25s, so
              the title rests as the picture visibly comes to rest. The mask
              window stays fixed on the page: bottom inset = travel - room at
              every frame, because translate and clip-path share one curve.
       Fade   opacity 0 to 1 over 0.7s on the family's light curve, from the
              same start, and only then: a separate animation that ends at
              about 0.95s and holds 1 (fill both). Light leads, travel
              follows. The fade's own animationend does not end the run;
              selected-motion.js waits until no title animation is running. */
  :root {
    --pm-title-start: 0.25s;
    --pm-title-duration: 2s;
    --pm-title-ease: var(--hero-push-ease);
    --pm-title-room: 0.18em;   /* descenders and side bearings */
    --pm-title-travel: 0.45em;
    --pm-title-light-ms: 0.7s;
  }
  .pm-on.pm-hero-words-wait .cc-hero__title,
  .pm-on.pm-hero-words-run .cc-hero__title {
    opacity: 0;
    translate: 0 var(--pm-title-travel);
    clip-path: inset(calc(-1 * var(--pm-title-room)) calc(-1 * var(--pm-title-room)) calc(var(--pm-title-travel) - var(--pm-title-room)) calc(-1 * var(--pm-title-room)));
  }
  .pm-on.pm-hero-words-run .cc-hero__title {
    animation:
      pm-title-rise-soft var(--pm-title-duration) var(--pm-title-ease) var(--pm-title-start) both,
      pm-title-light var(--pm-title-light-ms) cubic-bezier(0.22, 1, 0.36, 1) var(--pm-title-start) both;
  }
  @keyframes pm-title-rise-soft {
    from {
      translate: 0 var(--pm-title-travel);
      clip-path: inset(calc(-1 * var(--pm-title-room)) calc(-1 * var(--pm-title-room)) calc(var(--pm-title-travel) - var(--pm-title-room)) calc(-1 * var(--pm-title-room)));
    }
    to {
      translate: 0 0;
      clip-path: inset(calc(-1 * var(--pm-title-room)) calc(-1 * var(--pm-title-room)) calc(-1 * var(--pm-title-room)) calc(-1 * var(--pm-title-room)));
    }
  }
  @keyframes pm-title-light {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  /* ---- Waiting to enter. The JS adds .pm-shown in the frame its entrance
     starts (photos) or when it has finished (words). */
  .pm-on [data-pm]:not(.pm-shown) {
    opacity: 0;
  }
  /* Framed photo settle (kids, closing): the frame waits at the family's
     waiting light, the picture slightly near. */
  .pm-on [data-pm="settle-photo"]:not(.pm-shown) {
    opacity: 0.35;
  }
  .pm-on [data-pm="settle-photo"]:not(.pm-shown) img {
    transform: scale(1.08);
  }
  /* Welcome breath (Join us Sunday photo): full light, picture slightly near. */
  .pm-on [data-pm="breathe"]:not(.pm-shown) {
    opacity: 1;
  }
  .pm-on [data-pm="breathe"]:not(.pm-shown) img {
    transform: scale(1.06);
  }
  /* A picture shows only once loaded and decoded, so a late or progressive
     load never paints in during a waiting pose or an entrance. Until then
     the frame shows its own dark ground. */
  .pm-on [data-pm-picture]:not(.pm-img-ready) img {
    visibility: hidden;
  }

  /* ---- Room doors and closing drift write clip-path, transform and
     translate from the JS. */
  .pm-on [data-pm-doors] {
    will-change: clip-path;
  }
  .pm-on [data-pm-doors] img,
  .pm-on [data-pm-drift] img {
    will-change: transform, translate;
  }

  /* ---- Poster fan: desktop's rendering and cut lines (watch-sermons.png,
     1280 x 541; front poster ends at x 718, middle at x 1046). The JS keeps
     .pm-fan on the figure only while the fan is not fully open. Preview
     path: on the website this is photos/watch-sermons.png. */
  .pm-on [data-pm-fan].pm-fan {
    position: relative;
    isolation: isolate;
  }
  .pm-on [data-pm-fan].pm-fan .cc-media-frame__img {
    position: relative;
    z-index: 3;
    clip-path: inset(0 calc(100% - 718 / 1280 * 100%) 0 0);
  }
  .pm-on [data-pm-fan].pm-fan::before,
  .pm-on [data-pm-fan].pm-fan::after {
    content: "";
    position: absolute;
    inset: 0;
    background: url("photos/watch-sermons.png") center / 100% 100% no-repeat;
    pointer-events: none;
  }
  .pm-on [data-pm-fan].pm-fan::before {
    z-index: 2;
    clip-path: inset(0 calc(100% - 1046 / 1280 * 100%) 0 calc(718 / 1280 * 100%));
    translate: calc(-3% * (1 - var(--pm-fan, 0))) 0;
  }
  .pm-on [data-pm-fan].pm-fan::after {
    z-index: 1;
    clip-path: inset(0 0 0 calc(1046 / 1280 * 100%));
    translate: calc(-6% * (1 - var(--pm-fan, 0))) 0;
  }
}
