/* ===========================================================================
   HEATER CAP: MOTION

   Every initial state and every hover affordance the motion system needs, in
   one file, loaded by the layout only when Site:EnableMotion is true. Its
   partner is motion.js. Delete those two files and the four lines in
   _Layout.cshtml that load them, and the site is the approved design again.

   THREE RULES HOLD THIS WHOLE FILE TOGETHER.

   1. NOTHING IS HIDDEN EXCEPT UNDER html.motion-ready.

      motion.js adds that class to <html> as its first statement, and only
      after it has confirmed that GSAP is on the page and that the visitor has
      not asked for reduced motion. So a blocked script, a 404 on gsap.min.js,
      a parse error, an old browser, or Site:EnableMotion set to false all
      land in the same place: the class is never added, not one rule below
      matches, and every section is simply visible. The opposite arrangement,
      hiding things in CSS and revealing them in JavaScript, turns a script
      failure into a blank page.

      The class is added synchronously at the top of a deferred script, which
      runs after parsing and before the first paint, so nothing is briefly
      visible before it is hidden.

      THE ONE EXCEPTION IS THE HERO ENTRANCE IN SECTION 3, which is a CSS
      keyframe and is deliberately not gated. A keyframe cannot leave anything
      hidden, because it always runs to its end whether or not any script
      loads, so it sits outside this rule rather than being a hole in it.
      Section 3 explains why it had to be: the thing it was hiding was the home
      page's Largest Contentful Paint.

   2. ONLY transform, opacity AND clip-path ARE ANIMATED.

      No width, height, margin, padding, top or left is ever tweened, so
      nothing here can cause layout shift. There are exactly two static
      exceptions and both are called out where they appear: the parallax bands
      get a taller photograph so there is something to move, and the accordion
      panel gets overflow: hidden so its height tween does not spill. Neither
      is animated, and both are inside the gate.

   3. WHAT MOVES ON A STATE CHANGE STAYS IN site.css.

      A button hover, the chevron on an open accordion, the head going solid,
      the gallery tile's zoom: those are CSS transitions on a real state and
      they work with no JavaScript at all, so they were never candidates for
      moving here. This file adds only what the approved design could not
      express: the underline that draws, the ring that pulses once, and the
      initial states of the timelines in motion.js.

   WHY THERE ARE NO NEW data-* HOOKS IN THE MARKUP. The brief allowed them and
   they turned out to be unnecessary. The design system already names every
   component this motion targets, so `.split__media > img` and `.ba-pair
   figure` are better selectors than a hook copied onto forty elements, and
   the markup of all thirteen pages is untouched: the diff of this experiment
   is two new files, the layout, the tokens and the type rules. The one
   attribute used below, [data-reveal], was already on every section before
   this pass began.

   The selector lists here and the ones at the top of motion.js are
   deliberately the same strings, and each file says where its twin is.
   =========================================================================== */

/* ---------------------------------------------------------------------------
   1. THE MOTION SYSTEM'S OWN NUMBERS

   Declared here rather than in tokens.css because they belong to this file:
   tokens.css holds the approved design's values, and this is an experiment
   that has to be deletable in one move. site.css keeps --ease and
   --hover-duration, which it still uses for its own hover transitions, and
   the radii below are read from the tokens so a mask can never round to a
   different corner from the frame it is opening.
--------------------------------------------------------------------------- */

:root {
  --m-rise: 24px;        /* a scroll reveal's rise */
  --m-rise-hero: 16px;   /* the hero's own, shorter because it is faster */
  --m-mask: 6%;          /* how far open a mask starts */
  --m-underline: 260ms;  /* the line drawn under a nav link */
}

/* ---------------------------------------------------------------------------
   2. SCROLL REVEALS: THE INITIAL STATE

   An eyebrow, a heading, a lead line, the answer a section opens with and the
   paragraph beside a heading, in any section already marked [data-reveal].
   Each rises 24px into place once its own top passes 85% of the viewport, in
   a short stagger, once, and never again.

   The whole section used to fade in as one block. Revealing the type inside
   it instead is the difference between a page that arrives and a page that
   reads: the photograph is already there, and the words settle onto it.

   THE SAME SELECTOR LIST IS AT THE TOP OF motion.js, as REVEAL_ITEMS. Add a
   component here and add it there.
--------------------------------------------------------------------------- */

html.motion-ready [data-reveal] :is(.eyebrow, h2, .lead, .answer, .headrow__note) {
  opacity: 0;
  transform: translate3d(0, var(--m-rise), 0);
}

/* ---------------------------------------------------------------------------
   3. THE HERO ENTRANCE

   Three kinds of hero open this site and all three are a photograph with type
   over it: .hero on the home page, .pagehead on nine inner pages, and
   .band--hero on /become-a-dealer/. The photograph settles from 1.06 to 1
   over 1.8s, the h1 reveals line by line from behind a mask, and the
   breadcrumb, eyebrow, lead line, buttons and panels rise 16px into place. It
   is all over inside 1.3s; only the photograph is still moving.

   THE SUPPORTING TYPE IS A CSS KEYFRAME, NOT A TWEEN, AND IT IS NOT GATED.
   This is the one place the obvious arrangement is measurably wrong.

   Largest Contentful Paint is the moment the biggest piece of content in the
   viewport is first painted, and on the home page that piece is the hero's
   lead paragraph. An element at opacity 0 has not been painted. So hiding the
   lead line until a deferred script has downloaded 126 KB of GSAP, parsed it
   and built a timeline moves LCP from the first paint to whenever that chain
   finishes: measured on Lighthouse's throttled mobile profile, it cost the
   home page LCP 6.2s against 1.7s, and 26 points of Performance. The
   animation was 700ms long and it was holding the metric that decides whether
   the page is judged fast.

   The fix is in two halves.

   FIRST, the eyebrow, breadcrumb and lead line animate TRANSFORM ONLY. No
   opacity, so they are painted on the very first frame and LCP equals first
   contentful paint exactly, and they still rise into place. The buttons and
   the panels do fade, because nothing in them is ever the largest element.

   SECOND, it is a CSS animation rather than a GSAP tween, so it does not wait
   for the script at all, and there is no html.motion-ready on these rules.
   That is safe in a way the hidden states below are not: a keyframe always
   runs to its end, so the worst a blocked script can do here is nothing. It
   also means the hero entrance is the one piece of motion on this site that
   still plays with JavaScript off, which is a better answer than the one the
   brief asked for rather than a worse one.

   THE h1 IS STILL HIDDEN, and still behind the gate, because motion.js cannot
   split it into lines until the webfont has settled: lines measured against
   the fallback break in the wrong places. Opacity 0 covers that wait and the
   split's own masks cover the reveal. It costs nothing: the h1 is not the
   largest element in any of these heroes, which was measured rather than
   assumed. motion.js also gives up waiting after 1.2s, so a font that never
   arrives costs a late entrance and not a missing headline.
--------------------------------------------------------------------------- */

html.motion-ready :is(.hero, .pagehead, .band--hero) h1 {
  opacity: 0;
}

/* Transform only: painted on frame one, so it can hold no metric back. */
@keyframes m-hero-rise {
  from {
    transform: translate3d(0, var(--m-rise-hero), 0);
  }

  to {
    transform: none;
  }
}

/* With the fade, for the things that are never the largest element. */
@keyframes m-hero-fade-rise {
  from {
    opacity: 0;
    transform: translate3d(0, var(--m-rise-hero), 0);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

:is(.hero, .pagehead, .band--hero) :is(.crumbs, .eyebrow, .lead, .hero__lead) {
  animation: m-hero-rise 0.8s var(--ease) both;
}

:is(.hero, .pagehead, .band--hero) .eyebrow { animation-delay: 0.04s; }
:is(.hero, .pagehead, .band--hero) :is(.lead, .hero__lead) { animation-delay: 0.08s; }

:is(.hero, .pagehead, .band--hero) :is(.cta-pair, .path, .tile) {
  animation: m-hero-fade-rise 0.8s var(--ease) 0.24s both;
}

/* The panels in a short stagger, which is the last beat of the entrance. */
:is(.hero, .pagehead, .band--hero) :is(.path, .tile):nth-child(2) { animation-delay: 0.32s; }
:is(.hero, .pagehead, .band--hero) :is(.path, .tile):nth-child(3) { animation-delay: 0.4s; }
:is(.hero, .pagehead, .band--hero) :is(.path, .tile):nth-child(4) { animation-delay: 0.48s; }

/* The hero photograph. will-change is set on these three, on the head and on
   the two parallax bands, and on nothing else: it is a promise to the
   compositor that costs memory, and a page that promises everything has
   promised nothing. */
html.motion-ready :is(.hero__photo, .pagehead__photo, .band--hero .band__photo) {
  will-change: transform;
}

/* SplitText's own line wrappers, named through its linesClass option. It sets
   overflow: clip on them inline; this is the piece it cannot know, which is
   that a line of a 92px headline at -0.035em has descenders and side bearings
   a tight clip would shave. The padding is given straight back as a negative
   margin, so the line box is unchanged and nothing moves. */
html.motion-ready .m-line-mask {
  padding-bottom: 0.14em;
  margin-bottom: -0.14em;
}

/* ---------------------------------------------------------------------------
   4. IMAGE REVEALS: THE INITIAL STATE

   A mask opens from inset(6%) to inset(0), rounded to the frame's own radius,
   over 1.2s.

   TWO SHAPES, BECAUSE THE MARKUP HAS TWO SHAPES. Where a photograph sits
   inside a frame that already clips it, the mask opens on the frame and the
   photograph inside settles from 1.06 to 1, which is the fuller version of
   the effect. Where the photograph IS the frame, carrying its own radius and
   no wrapper, only the mask opens: scaling such an element would scale its
   own clip path with it and the two would cancel out, and giving it a wrapper
   would mean restructuring thirteen pages, which this pass does not do.

   Each radius group is its own rule rather than one list with overrides,
   because :is() takes the specificity of its most specific argument and a
   later single-class override would quietly lose to it.

   THE SAME LISTS ARE AT THE TOP OF motion.js, as MASK_SELF and MASK_FRAME.
--------------------------------------------------------------------------- */

/* The photograph is the frame. A split's picture and a mosaic's lead both
   carry --r-photo. */
html.motion-ready :is(.split__media > img, .split__media > figure > img, .mosaic__lead) {
  clip-path: inset(var(--m-mask) round var(--r-photo));
}

html.motion-ready .mosaic__pair {
  clip-path: inset(var(--m-mask) round var(--r-tile));
}

html.motion-ready .gshot {
  clip-path: inset(var(--m-mask) round var(--r-panel));
}

/* A real frame with a photograph inside it. The before and after pair is the
   one place on the site where both halves of the effect are available, and it
   is also the one place a reader is comparing two pictures, so the settle is
   worth having. */
html.motion-ready .ba-pair figure {
  clip-path: inset(var(--m-mask) round var(--r-lg));
}

html.motion-ready .ba-pair figure > img {
  transform: scale(1.06);
}

/* The gallery's lightbox triggers: the frame's mask opens in a stagger. */
html.motion-ready .shot {
  clip-path: inset(var(--m-mask) round var(--r-panel));
}

/* A GALLERY TILE'S HOVER ZOOM IS NOT PART OF ITS REVEAL, and this is why it
   is switched off and then put back. site.css gives .shot img a 600ms
   transition for the hover, and a CSS transition on a property GSAP is also
   tweening is two animations arguing over one value. So the tile's frame
   carries the reveal, the photograph inside it is left alone, and the hover
   transition is restored the moment the reveal finishes. */
html.motion-ready .shot img {
  transition: none;
}

html.motion-ready .shot.is-revealed img {
  transition: transform 600ms var(--ease);
}

/* ---------------------------------------------------------------------------
   5. THE NAVIGATION

   It hides on the way down the page and comes back on the way up, past the
   hero only. motion.js tweens translateY over 0.35s and refuses to hide the
   bar while the mobile menu is open or while focus is anywhere inside the
   head, which are the two ways a hiding bar becomes a keyboard trap.
--------------------------------------------------------------------------- */

html.motion-ready .sitehead {
  will-change: transform;
}

/* ---------------------------------------------------------------------------
   6. MICRO-INTERACTIONS

   CSS first. Only the accordion's height and the play button's single pulse
   need JavaScript, and both degrade to the behaviour the approved design
   already had.
--------------------------------------------------------------------------- */

/* THE NAV UNDERLINE, drawn left to right on hover and on focus.

   It takes over from the inset box-shadow site.css uses to mark the current
   page, with the same 2px ember line in the same place, so the page marker
   and the hover marker are one thing rather than two that can overlap. The
   current page's line is simply already drawn: scaleX(1) is its initial
   state, not a change to it, so there is no transition to play on load.

   Drawn with a transform on a pseudo-element rather than with background-size
   or a border, because a transform is composited and the others are not. */
html.motion-ready .nav__list a {
  position: relative;
}

html.motion-ready .nav__list a::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  background: var(--ember);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--m-underline) var(--ease);
  pointer-events: none;
}

html.motion-ready .nav__list a:hover::after,
html.motion-ready .nav__list a:focus-visible::after,
html.motion-ready .nav__list a[aria-current='page']::after {
  transform: scaleX(1);
}

html.motion-ready .nav__list a[aria-current='page'] {
  box-shadow: none;
}

/* THE FAQ ACCORDION. <details> and <summary> are kept exactly as they are:
   the browser's own keyboard handling, the browser's own announcement of the
   expanded state, and the panel opening with no JavaScript at all. motion.js
   only borrows the moment of the toggle to tween the panel's height, and
   overflow: hidden is what keeps the text from spilling out of a panel that
   is shorter than its content for 320ms.

   The chevron is site.css's own: 45deg to 225deg on [open], which is exactly
   the 180 degrees the brief asks for, with the transition it already had. */
html.motion-ready .faq__a {
  overflow: hidden;
}

/* THE PLAY BUTTON'S ONE PULSE. A single soft ring when the film first scrolls
   into view, and then it is still: a button that pulses forever stops being
   read as a button and starts being read as an advertisement.

   The ring is a pseudo-element so the markup is untouched, pointer-events is
   none so it cannot eat the click, and the animation runs once on a class
   motion.js adds once. `both` holds the end frame, which is opacity 0, so
   there is nothing left behind. */
@keyframes m-play-pulse {
  from {
    transform: scale(1);
    opacity: 0.5;
  }

  to {
    transform: scale(1.85);
    opacity: 0;
  }
}

html.motion-ready .playbtn::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 50%;
  border: 2px solid var(--ember-soft);
  opacity: 0;
  pointer-events: none;
}

html.motion-ready .playbtn.is-pulsing::after {
  animation: m-play-pulse 1400ms var(--ease) 1 both;
}

/* ---------------------------------------------------------------------------
   7. PARALLAX, AND THE ONE LAYOUT PROPERTY IN THIS FILE

   The two full-bleed photograph bands, the dealer band and the closing call
   to action, drift at most 8% of their own height against the scroll. The
   home hero and /become-a-dealer/'s band are excluded, because a hero that
   drifts is a hero whose headline you are chasing.

   A photograph that fills its band exactly has nothing to move into, so it is
   drawn 116% tall and pulled up 8%, which leaves 8% of slack at each edge for
   a 4% travel each way. height and top are set once and never animated, so
   this costs no layout shift; only yPercent is tweened, with scrub. Both
   bands already clip their overflow.

   Off below 1024px, where the bands are tall relative to the viewport, the
   effect is invisible, and the scrubbed tween would be the most expensive
   thing on the page.
--------------------------------------------------------------------------- */

@media (min-width: 1024px) {
  html.motion-ready :is(.band:not(.band--hero), .cta-final) .band__photo {
    height: 116%;
    top: -8%;
    will-change: transform;
  }
}

/* ---------------------------------------------------------------------------
   8. REDUCED MOTION

   This block is belt and braces and it should never do anything.

   motion.js checks prefers-reduced-motion before it adds .motion-ready, so
   under that setting not one rule above is even selected: nothing is hidden,
   no timeline is built, no ScrollTrigger is created and no mask is applied.
   What this is for is the one case the script cannot catch, a visitor who
   turns the setting on after the page has loaded, and it undoes every initial
   state rather than merely shortening it.
--------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html.motion-ready :is(.hero, .pagehead, .band--hero) h1,
  html.motion-ready [data-reveal] :is(.eyebrow, h2, .lead, .answer, .headrow__note) {
    opacity: 1;
    transform: none;
  }

  /* The hero's keyframes are not gated on the class, so unlike everything
     else in this file they really do need switching off here rather than
     merely never being selected. site.css's own reduced-motion block already
     cuts every animation to 0.01ms, which is enough; this says it plainly. */
  :is(.hero, .pagehead, .band--hero)
    :is(.crumbs, .eyebrow, .lead, .hero__lead, .cta-pair, .path, .tile) {
    animation: none;
    opacity: 1;
    transform: none;
  }

  html.motion-ready :is(.split__media > img, .split__media > figure > img, .mosaic__lead),
  html.motion-ready .mosaic__pair,
  html.motion-ready .gshot,
  html.motion-ready .ba-pair figure,
  html.motion-ready .shot {
    clip-path: none;
  }

  html.motion-ready .ba-pair figure > img,
  html.motion-ready :is(.hero__photo, .pagehead__photo, .band--hero .band__photo) {
    transform: none;
  }

  html.motion-ready .playbtn.is-pulsing::after {
    animation: none;
  }

  html.motion-ready .nav__list a::after {
    transition: none;
  }

  html.motion-ready :is(.band:not(.band--hero), .cta-final) .band__photo {
    height: 100%;
    top: 0;
  }
}
