/* GAON motion 1.2.3.

   Two layers.

   1. Scroll reveal. Inert until the script adds .g-motion to <html>, so the
      hidden starting state never outlives the thing that undoes it. Only
      opacity and transform, both on the compositor.

   2. Page title and banner. CSS only, no script, so it starts on the first
      frame. The title itself has no delay: on mobile it can be the largest
      element on screen, and any delay there is paid in LCP. Only the line
      under it waits.

   Everything that moves sits behind prefers-reduced-motion: no-preference,
   and nothing runs inside the Elementor editor. */

/* ---------------------------------------------------------------------------
   1. Scroll reveal
   ------------------------------------------------------------------------ */

.g-motion .g-reveal{
  opacity: 0;
  transform: translate3d(0, 14px, 0);
  transition:
    opacity var(--g-motion-duration, 820ms) cubic-bezier(.4, 0, .2, 1),
    transform var(--g-motion-duration, 820ms) cubic-bezier(.16, 1, .3, 1);
}

.g-motion .g-reveal.is-in{
  opacity: 1;
  transform: none;
}

.g-motion .g-reveal.is-immediate{
  transition: none;
}

/* Smaller things - a card in a grid, a chip - travel less. */
.g-motion .g-reveal--soft,
.g-motion .g-reveal--item{
  transform: translate3d(0, 10px, 0);
}

@media (prefers-reduced-motion: reduce){
  .g-motion .g-reveal{
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ---------------------------------------------------------------------------
   2. Page title and banner

   One entrance for every page opening, so the site reads as one voice:
   the title rises out of a mask, the lines around it fade in after it, the
   picture settles and then drifts as the page scrolls.

   Title: every atomic H1 in a page, archive or single document, plus the
   titles of the home hero (490) and the divisions cover (852), which are
   widgets with their own markup. The project hero widget (879) is not in.
   Supporting lines: the line after an atomic H1 (or the H2 subtitle after
   it and the line after that, as on a product), and the eyebrow and body
   of the two widget heroes.
   Picture: the kit's page-banner, the flagship-projects archive hero (local
   classes), the product cover (company cover image at the top of a product), the home hero slides and the divisions cover.
   ------------------------------------------------------------------------ */

@keyframes g-title-rise{
  /* The mask opens from the top down, so a title that wraps to two lines
     is revealed in reading order, first line first. */
  from{
    clip-path: inset(-30% -10% 100% -10%);
    translate: 0 .32em;
  }
  to{
    clip-path: inset(-30% -10% -30% -10%);
    translate: 0 0;
  }
}

@keyframes g-sub-in{
  from{
    opacity: 0;
    translate: 0 10px;
  }
  to{
    opacity: 1;
    translate: 0 0;
  }
}

@keyframes g-banner-settle{
  from{ scale: 1.06; }
  to{ scale: 1; }
}

@keyframes g-banner-drift{
  from{ translate: 0 0; }
  to{ translate: 0 16%; }
}

@media (prefers-reduced-motion: no-preference){

  body:not(.elementor-editor-active) :is(
    [data-elementor-type="wp-page"],
    [data-elementor-type="wp-post"],
    [data-elementor-type="single-post"],
    [data-elementor-type="single-page"],
    [data-elementor-type="single"],
    [data-elementor-type="archive"]
  ) h1.e-heading-base,
  body:not(.elementor-editor-active) .ghero .ghero__title,
  body:not(.elementor-editor-active) .gdiv .gdiv__title{
    animation: g-title-rise 1.2s cubic-bezier(.25, 1, .5, 1) backwards;
  }

  body:not(.elementor-editor-active) :is(
    [data-elementor-type="wp-page"],
    [data-elementor-type="wp-post"],
    [data-elementor-type="single-post"],
    [data-elementor-type="single-page"],
    [data-elementor-type="single"],
    [data-elementor-type="archive"]
  ) :is(h1.e-heading-base + p, h1.e-heading-base + h2, h1.e-heading-base + h2 + p),
  body:not(.elementor-editor-active) .ghero .ghero__eyebrow,
  body:not(.elementor-editor-active) .ghero .ghero__body,
  body:not(.elementor-editor-active) .gdiv .gdiv__eyebrow{
    animation: g-sub-in 1s cubic-bezier(.25, 1, .5, 1) .3s backwards;
  }

  body:not(.elementor-editor-active) :is(
    .page-banner__media,
    .elementor-location-archive > :first-child img.e-image-base[fetchpriority="high"],
    .single-gaon_product .elementor-location-single > :first-child > img.e-image-base[fetchpriority="high"],
    .ghero .ghero__slide img,
    .gdiv .gdiv__cover-media img
  ){
    animation: g-banner-settle 1.8s cubic-bezier(.22, .61, .36, 1) backwards;
  }

  /* The image drifts slower than the page as the banner leaves. The browser
     runs this off the main thread; where scroll timelines are not supported
     the banner simply stays put. A separate property (translate) from the
     settle (scale), so the two never fight.

     Tied to the page's own scroll, not view(): the banner's frame has
     overflow hidden, which makes it the image's nearest scroller, and a
     view() timeline would track a box that never scrolls. Banners always
     open the page, so the first 700px of page scroll is the banner leaving. */
  @supports (animation-timeline: scroll(root)){
    body:not(.elementor-editor-active) :is(
      .page-banner__media,
      .elementor-location-archive > :first-child img.e-image-base[fetchpriority="high"],
      .single-gaon_product .elementor-location-single > :first-child > img.e-image-base[fetchpriority="high"],
      .ghero .ghero__slide img,
      .gdiv .gdiv__cover-media img
    ){
      animation:
        g-banner-settle 1.8s cubic-bezier(.22, .61, .36, 1) backwards,
        g-banner-drift linear both;
      animation-timeline: auto, scroll(root);
      animation-range: normal, 0px 700px;
    }
  }
}
