/* =========================================================================
   MOTION LAYER — page-load choreography + scroll reveals
   Loaded after styles.css, so the .fadeFrom* rules here refine the ones there.
   Everything that hides content is gated behind html.js-motion, which is only
   set by the inline boot snippet in metatags-icons-css.php — if JS never runs,
   or the visitor prefers reduced motion, the page renders fully visible.
   Paired with /assets/js/motion.js.
   ========================================================================= */

:root {
  /* Slow, decelerating, no overshoot — the house style for a luxury feel. */
  --ms-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ms-reveal-duration: 1.05s;
  --ms-intro-duration: 1.25s;
  --ms-travel: 2.4rem;
  --ms-travel-sm: 1.4rem;
}

/* ---------- Scroll reveals ---------------------------------------------
   .animate is applied per widget in the admin (Animation settings) and by
   motion.js to un-animated sections. .show is added once, on first entry. */
html.js-motion .animate {
  opacity: 0;
  transition-property: opacity, transform, filter;
  transition-duration: var(--ms-reveal-duration);
  transition-timing-function: var(--ms-ease);
  transition-delay: var(--ms-delay, 0ms);
  will-change: opacity, transform;
}

/* Directional variants — shorter travel than the stock 10rem, which reads as
   drift rather than a slide. */
html.js-motion .fadeFromLeft   { transform: translate3d(calc(var(--ms-travel) * -1), 0, 0); }
html.js-motion .fadeFromRight  { transform: translate3d(var(--ms-travel), 0, 0); }
html.js-motion .fadeFromTop    { transform: translate3d(0, calc(var(--ms-travel) * -1), 0); }
html.js-motion .fadeFromBottom { transform: translate3d(0, var(--ms-travel), 0); }

/* Bare .animate (no direction picked in the admin, e.g. contact list rows) gets
   a quiet rise. motion.js tags those elements, so this stays one class deep and
   the .show rule below can still out-rank it. */
html.js-motion .fadeDefault {
  transform: translate3d(0, var(--ms-travel-sm), 0);
}

html.js-motion .animate.show {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

/* Reveal finished — drop the compositor hint so hover transforms stay crisp,
   and drop the transform entirely: an identity transform still creates a
   containing block, which would break position:fixed/sticky descendants. */
html.js-motion .animate.motion-done,
html.js-motion .motion-section.motion-done {
  will-change: auto;
  transform: none;
  transition-delay: 0ms;
}

/* Whole sections auto-enrolled by motion.js (widgets with no admin animation
   configured). Softer and slower than element-level reveals. */
html.js-motion .motion-section {
  opacity: 0;
  transform: translate3d(0, var(--ms-travel-sm), 0);
  transition: opacity 1.2s var(--ms-ease), transform 1.2s var(--ms-ease);
}
html.js-motion .motion-section.show {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

/* ---------- Page-load choreography -------------------------------------
   Hidden from first paint; released when html gains .motion-ready. */
html.js-motion .full_header,
html.js-motion .mobile_header {
  opacity: 0;
  transform: translate3d(0, -1.2rem, 0);
  /* The scrolled-header transition from styles.css is restated here, spelled
     out: --animate-medium expands to `all 0.48s ease-in-out`, and `all` is
     illegal inside a comma-separated list — using it would invalidate the
     whole declaration and the header would snap instead of fade. */
  transition: opacity var(--ms-intro-duration) var(--ms-ease),
              transform var(--ms-intro-duration) var(--ms-ease),
              background 0.48s ease-in-out,
              border-color 0.48s ease-in-out,
              padding 0.48s ease-in-out;
}
html.js-motion.motion-ready .full_header,
html.js-motion.motion-ready .mobile_header {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

/* Hero: the opening banner slide and the inner-page header.
   Both states are gated on :not(.motion-intro-done) — once the sequence is
   over the rules stop matching entirely, so the banner script owns its slides
   again (it reorders <li>s as it rotates) and nothing here can catch a later
   slide that scrolls into first place. */
html.js-motion:not(.motion-intro-done) .ms-banner-constrained > li:first-child .banner-content > *,
html.js-motion:not(.motion-intro-done) .inner_header .content > * {
  opacity: 0;
  transform: translate3d(0, 2rem, 0);
  filter: blur(6px);
  transition: opacity var(--ms-intro-duration) var(--ms-ease),
              transform var(--ms-intro-duration) var(--ms-ease),
              filter var(--ms-intro-duration) var(--ms-ease);
  transition-delay: var(--ms-delay, 0ms);
}
html.js-motion.motion-ready:not(.motion-intro-done) .ms-banner-constrained > li:first-child .banner-content > *,
html.js-motion.motion-ready:not(.motion-intro-done) .inner_header .content > * {
  opacity: 1;
  transform: translate3d(0, 0, 0);
  filter: blur(0);
}

/* Hero imagery settles in behind the copy. */
html.js-motion:not(.motion-intro-done) .ms-banner-constrained > li:first-child .img-wrapper,
html.js-motion:not(.motion-intro-done) .inner_header {
  opacity: 0;
  transition: opacity 1.4s var(--ms-ease);
}
html.js-motion.motion-ready:not(.motion-intro-done) .ms-banner-constrained > li:first-child .img-wrapper,
html.js-motion.motion-ready:not(.motion-intro-done) .inner_header {
  opacity: 1;
}

/* The hero image drifts fractionally closer while the copy lands — a slow
   settle, not a Ken Burns pan. */
html.js-motion:not(.motion-intro-done) .ms-banner-constrained > li:first-child .img-wrapper img {
  transform: scale(1.06);
  transition: transform 2.4s var(--ms-ease);
}
html.js-motion.motion-ready:not(.motion-intro-done) .ms-banner-constrained > li:first-child .img-wrapper img {
  transform: scale(1);
}

/* ---------- Accessibility ---------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html.js-motion .animate,
  html.js-motion .motion-section,
  html.js-motion .full_header,
  html.js-motion .mobile_header,
  html.js-motion .inner_header,
  html.js-motion .inner_header .content > *,
  html.js-motion .ms-banner-constrained > li:first-child .img-wrapper,
  html.js-motion .ms-banner-constrained > li:first-child .img-wrapper img,
  html.js-motion .ms-banner-constrained > li:first-child .banner-content > * {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    transition: none !important;
  }
}
