/* CONNECT GROUPS MOTION - the applied motion for connect-groups.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/connect-groups/combined/, where this file is
   selected-motion.css with preview paths; its README.md records the combining
   rules and picker.json lists the selections. Paths below that start with
   ../proposals/ are relative to that folder. Built from proposal
   2026-10-30-a (../proposals/2026-10-30-a/connect-groups-motion.css),
   unchanged, plus proposal 2026-10-30-b's group card response
   (../proposals/2026-10-30-b/connect-groups-motion.css), unchanged. The
   head gate in connect-groups.html adds pilot-intro-pending and sel-on at 900px and
   up without reduced motion; connect-groups-motion.js adds pilot-settle-run
   (hero) and sel-ready (below the hero). Without those classes the page is
   the still baseline.

   Two lead moments, everything else still:
   1. Hero arrival: Hero push and Hero settle, reused. The push is held on
      the laughing woman's face (About's anchoring), so the room closes in
      around her and never pans.
   2. Friendship. Prayer. Growth.: the embrace photograph settles from a
      lead zoom while the copy beside it stays still, then its caption's
      three words come into light in reading order.
   The group cards have no entrance; their graphic answers hover and
   keyboard focus (Linked media response). */

/* ---- Hero push and Hero settle: Plan Your Visit's and About's values,
   unchanged (120-website/site/plan-your-visit-motion.css,
   120-website/site/about-motion.css).

   Anchor: the library frames this photo from -40px 19% (also the scale's
   origin). A bare push would slide her face about 68px right while it grows.
   For a scale s about origin O, translating by (1 - s) times the face's
   rendered offset from O holds the face. At 1440 the face sits about 975px
   right of and 254px below the origin: 68% and 35% of the photo box. The left
   edge opens at most about 71px, inside the left scrim's solid 14%, and the
   top edge about 8px, under the top scrim. */
: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-anchor-x: 68%;
  --hero-anchor-y: 35%;
  --hero-text-start: 0.6s;
  --hero-text-offset: 0s;
  --hero-text-ease: var(--hero-push-ease);
  --pilot-settle-start: var(--hero-text-start);
  --pilot-settle-stagger: 80ms;
  --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);
}
@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));
  translate: calc((1 - var(--hero-arrive)) * var(--hero-anchor-x)) calc((1 - var(--hero-arrive)) * var(--hero-anchor-y));
}
.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); }
}

/* ---- Below the hero. connect-groups-motion.js plays the entrances as Web
   Animations with fill "backwards" and adds .sel-shown in the frame they
   start, so a finished element is the library's own rendering. These rules
   hold only the waiting poses; each matches its first keyframe. */
@media (min-width: 900px) {

  /* Photo light: the embrace waits partly visible, its picture slightly
     near (the lead zoom of the changed Framed photo settle). */
  .sel-on [data-sel="settle-lead"]:not(.sel-shown) {
    opacity: 0.35;
  }
  /* P1 (polish): the picture keeps its slight zoom until its own settle
     starts (sel-settled), after the light. */
  .sel-on [data-sel="settle-lead"]:not(.sel-settled) img {
    transform: scale(1.12);
  }

  /* Caption words: the caption waits faint, at the family's waiting light
     for words (Pathway words, 0.18). While it plays, the runtime splits it
     into its three words; each waits at the same light and lights in turn. */
  .sel-on [data-sel="caption-words"]:not(.sel-shown) {
    opacity: 0.18;
  }

  /* ---- Linked media response on the group cards (proposal B's, with an
     even edge crop; Home's values). On pointer or keyboard focus the graphic
     grows slightly inside its frame. No entrance. It writes the individual
     scale property. The clip waits for the graphic's pixels
     (connect-groups-motion.js adds .sel-clip on load): any clip on the
     still-empty media box can keep Chrome from loading the lazy graphic. */
  .sel-on [data-sel-cards] > .sel-clip .cc-group-card__media {
    overflow: clip;
  }
  /* Even edge crop (Cheyne's refinement of B's 74% 44%, which cropped the
     left edge about three times as much as the top and bottom). Every group
     graphic is 16:9 with a thin light border of its own. Growing about a
     point half the frame's height in from the left, at mid-height, crops
     the left, top and bottom edges by the same amount (9/32 of the width is
     half the height), so the thin border bleeds off evenly on those sides.
     The right edge, beside the card's words, takes the rest. */
  .sel-on [data-sel-cards] .cc-group-card__img {
    transform-origin: 28.125% 50%;
    transition: scale 480ms cubic-bezier(0.22, 0.61, 0.36, 1);
  }
  .sel-on [data-sel-cards] .cc-group-card__link:is(:hover, :focus-visible) .cc-group-card__img {
    scale: 1.035;
  }
}

/* ============================================================================
   PHONE, below 900px. The selection work behind it is in
   100-motion-design/connect-groups/combined-mobile/, where the first block
   below is selected-motion.css and the second is user-picks-motion.css
   (both loaded by its user-picks.html, the composition applied here); its
   README.md records the composition and its combining rules.

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

   ONE PLACE FOR VALUES. Every timing, easing, distance and waiting light
   for the phone treatments is on :root in the two blocks below; the PHONE
   part of connect-groups-motion.js reads the ones it plays from here, so a
   waiting pose and its first keyframe cannot drift apart.

   Few movements, strong leads:
   1. Hero arrival: Hero push + Soft title rise (Plan Your Visit's phone
      hero, the same photograph at the same focal origin).
   2. The embrace: the photo lights and breathes back from a lead zoom
      together as it enters; the caption's three words light in reading
      order once the whole caption is on screen. The core heading and lead
      paragraph above it arrive first (Copy arrival, the second block).
   Everything else is still. The group cards keep the Linked media response
   (feedback only).
   ============================================================================ */
@media (max-width: 899.98px) {

  :root {
    /* Family curves (home-motion.js). */
    --cgma-light-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --cgma-settle-ease: cubic-bezier(0.5, 1, 0.89, 1);

    /* Soft title rise (Plan Your Visit's phone values, unchanged). */
    --cgma-title-start: 0.25s;
    --cgma-title-duration: 2s;
    --cgma-title-ease: var(--hero-push-ease);
    --cgma-title-room: 0.18em;     /* descenders and side bearings */
    --cgma-title-travel: 0.45em;
    --cgma-title-light-ms: 0.7s;

    /* Hero clock (desktop's), in ms. */
    --cgma-hero-photo-wait: 700;   /* longest wait for the hero photo's pixels */
    --cgma-hero-release: 1500;     /* a part in view beside the arriving hero waits this long */

    /* Triggers. */
    --cgma-part-at: 0.92;          /* family phone part line, share of the view */
    --cgma-preload: 2;             /* fetch the embrace this many views ahead */
    --cgma-photo-wait: 8000;       /* longest wait for its pixels, then at rest */
    --cgma-feed-wait: 1500;        /* longest wait for the group cards to fill */

    /* The embrace (Framed photo settle, lead strength: Connect Groups
       desktop's values). It waits at Photo light's 0.35 and its picture at
       the lead zoom; it lights as its top passes the part line and breathes
       back once its foot has passed it too. */
    --cgma-lead-wait: 0.35;
    /* Soft light (fix), half of desktop's: halfway between the family
       light (760, quick ease-out) and desktop's even 1200 light. */
    --cgma-lead-light-ms: 980;
    --cgma-lead-light-ease: cubic-bezier(0.335, 0.5, 0.455, 1);
    --cgma-lead-zoom: 1.12;
    --cgma-lead-settle-ms: 2000;

    /* Caption words (Connect Groups desktop's): from the family's waiting
       light for words, one after another, starting into the breath. */
    --cgma-word-wait: 0.18;
    --cgma-caption-at: 1;          /* own trigger: the caption's foot enters the view (whole caption on screen) */
    --cgma-word-gap: 420;
    --cgma-word-ms: 640;

    /* Loading only: a picture decoded while on screen after its entrance
       fades in, so it never pops into its frame. */
    --cgma-reveal-ms: 450;
  }

  /* ---- 1. Hero push (reused, Plan Your Visit's phone rules): the photo
     waits slightly small and pushes in to its framing 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). */
  .cgma-on.cgma-hero-photo-wait .cc-hero__photo {
    --hero-arrive: var(--hero-push-from);
    transform: scale(var(--hero-arrive));
  }
  .cgma-on.cgma-hero-photo-run .cc-hero__photo {
    transform: scale(var(--hero-arrive));
    animation: hero-push var(--hero-push-duration) var(--hero-push-ease) both;
  }

  /* Soft title rise (reused): only "Connect Groups" moves. It lights
     quickly and rises behind a still mask at its foot on the push's curve,
     resting as the picture rests. The purpose line, the paragraph and the
     Browse button are still from first paint. */
  .cgma-on.cgma-hero-words-wait .cc-hero__title,
  .cgma-on.cgma-hero-words-run .cc-hero__title {
    opacity: 0;
    translate: 0 var(--cgma-title-travel);
    clip-path: inset(calc(-1 * var(--cgma-title-room)) calc(-1 * var(--cgma-title-room)) calc(var(--cgma-title-travel) - var(--cgma-title-room)) calc(-1 * var(--cgma-title-room)));
  }
  .cgma-on.cgma-hero-words-run .cc-hero__title {
    animation:
      cgma-title-rise-soft var(--cgma-title-duration) var(--cgma-title-ease) var(--cgma-title-start) both,
      cgma-title-light var(--cgma-title-light-ms) var(--cgma-light-ease) var(--cgma-title-start) both;
  }
  @keyframes cgma-title-rise-soft {
    from {
      translate: 0 var(--cgma-title-travel);
      clip-path: inset(calc(-1 * var(--cgma-title-room)) calc(-1 * var(--cgma-title-room)) calc(var(--cgma-title-travel) - var(--cgma-title-room)) calc(-1 * var(--cgma-title-room)));
    }
    to {
      translate: 0 0;
      clip-path: inset(calc(-1 * var(--cgma-title-room)) calc(-1 * var(--cgma-title-room)) calc(-1 * var(--cgma-title-room)) calc(-1 * var(--cgma-title-room)));
    }
  }
  @keyframes cgma-title-light {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  /* ---- 2. The embrace. Waiting poses only; each matches its first
     keyframe in connect-groups-motion.js (PHONE). .cgma-shown is added in
     the frame the light starts, .cgma-settled in the frame the breath starts. */
  .cgma-on [data-cgma="lead-photo"]:not(.cgma-shown) {
    opacity: var(--cgma-lead-wait);
  }
  .cgma-on [data-cgma="lead-photo"]:not(.cgma-settled) img {
    transform: scale(var(--cgma-lead-zoom));
  }
  /* The picture shows only once loaded and decoded, so a late or
     progressive load never paints in during the waiting pose. Until then
     the frame shows its own dark ground at the waiting light. */
  .cgma-on [data-cgma-picture]:not(.cgma-img-ready) img {
    visibility: hidden;
  }
  /* Caption words: the caption waits faint; while it plays, the runtime
     splits it into its words and each holds the same light until its turn. */
  .cgma-on [data-cgma="caption-words"]:not(.cgma-shown) {
    opacity: var(--cgma-word-wait);
  }

  /* ---- Linked media response on the group cards (reused, Connect Groups
     desktop's even crop and values; Home's phone rule for hover). Feedback
     only, no entrance: keyboard focus everywhere, hover only where the
     device hovers, so a tap does not leave the graphic grown. The clip waits
     for the graphic's pixels (connect-groups-motion.js adds .cgma-clip on
     load). */
  .cgma-on [data-sel-cards] > .cgma-clip .cc-group-card__media {
    overflow: clip;
  }
  .cgma-on [data-sel-cards] .cc-group-card__img {
    transform-origin: 28.125% 50%;
    transition: scale 480ms cubic-bezier(0.22, 0.61, 0.36, 1);
  }
  .cgma-on [data-sel-cards] .cc-group-card__link:focus-visible .cc-group-card__img {
    scale: 1.035;
  }
  @media (hover: hover) {
    .cgma-on [data-sel-cards] .cc-group-card__link:hover .cc-group-card__img {
      scale: 1.035;
    }
  }
}

/* ---- PHONE, Copy arrival on the core part of life heading and lead
   paragraph (proposal 2026-11-04-mobile-b's values, About's phone copyStep
   values): the heading sharpens and rises with a slight scale; the
   paragraph rises after it; both from nothing. The runtime adds .cgma-shown
   once the words' entrance has finished, or at once when they rest
   unseen. */
@media (max-width: 899.98px) {

  :root {
    /* Copy arrival (B's values): the heading sharpens and rises with a
       slight scale; the paragraph rises after it. Both from nothing. */
    --cgma-copy-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
    --cgma-copy-rise: 14;          /* px */
    --cgma-copy-ms: 820;
    --cgma-copy-blur: 5;           /* px, heading only */
    --cgma-copy-text-after: 130;   /* paragraph after the heading, ms */
  }

  /* Waiting to enter. The runtime adds .cgma-shown once the words'
     entrance has finished, or at once when they rest unseen. */
  .cgma-on [data-cgma="copy-title"]:not(.cgma-shown),
  .cgma-on [data-cgma="copy-text"]:not(.cgma-shown) {
    opacity: 0;
  }
}
