/* ==========================================================================
   Water Treatment Market — Motion Layer (design fix #3, Patrick Yang audit)
   File: motion.css · Added 2026-12-01 · NEW FILE — changes no existing CSS.

   A system, not decoration:
     1. Scroll-triggered fade/rise reveals (paired with motion.js +
        IntersectionObserver; elements carry .reveal / [data-reveal]).
     2. Animated counters for [data-count] elements (motion.js drives the
        numbers; this file only keeps them from jittering while counting).
     3. Intentional hover / focus states for cards, doors and buttons.

   Settled-rule compliance:
     - B7: no auto-advance anything, no carousel behaviour, no scroll-jacking.
       Nothing here moves the page, hijacks scroll, or animates on a timer.
     - B2: does not touch the Market view modes (Regular / Big & Easy /
       Quick List) or view.js in any way.
     - M15: card anatomy and ordering are untouched — motion only, no layout.
     - prefers-reduced-motion: every effect below is fully disabled for
       visitors who ask their device for reduced motion.

   Safety design: reveal start-states apply ONLY when motion.js has run and
   added .motion-on to <html>. If the script is blocked, missing, or errors,
   every element stays fully visible — content can never be hidden by CSS
   alone.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Scroll reveals
   -------------------------------------------------------------------------- */

/* Start state — only reachable when JS is live (html.motion-on). */
html.motion-on .reveal,
html.motion-on [data-reveal] {
  opacity: 0;
  transform: translateY(16px);
  will-change: opacity, transform;
}

/* Fade-only variant: .reveal-fade */
html.motion-on .reveal-fade {
  transform: none;
}

/* Gentler, smaller rise for dense card grids: .reveal-soft */
html.motion-on .reveal-soft {
  transform: translateY(8px);
}

/* Slight scale-in for stat blocks / feature moments: .reveal-pop */
html.motion-on .reveal-pop {
  transform: translateY(10px) scale(0.98);
}

/* End state — motion.js adds .is-in when the element enters the viewport.
   Per-element stagger is available via style="--reveal-delay:.1s" or
   data-reveal-delay="120" (milliseconds, set by motion.js as the var). */
html.motion-on .reveal.is-in,
html.motion-on [data-reveal].is-in {
  opacity: 1;
  transform: none;
  transition:
    opacity 0.6s ease-out var(--reveal-delay, 0s),
    transform 0.6s cubic-bezier(0.22, 0.61, 0.36, 1) var(--reveal-delay, 0s);
}

/* --------------------------------------------------------------------------
   2. Animated counters
   -------------------------------------------------------------------------- */

/* Numbers count up via motion.js. Tabular figures stop the width jitter;
   the final value is always the element's real data-count value, and if JS
   never runs the authored text in the HTML is what the visitor sees. */
[data-count] {
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   3. Hover & focus intent — cards, doors, buttons
   Applied only on devices that can truly hover, so touch users never get
   stuck in a hover state. Uses the site's existing tokens with fallbacks.
   -------------------------------------------------------------------------- */

@media (hover: hover) and (pointer: fine) {
  .card,
  .door {
    transition:
      transform 0.22s ease-out,
      box-shadow 0.22s ease-out,
      border-color 0.22s ease-out;
  }

  .card:hover,
  .door:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow, 0 14px 34px rgba(6, 40, 61, 0.16));
    border-color: var(--gold, #b98a2f);
  }

  .mkt-stat {
    transition: transform 0.22s ease-out, box-shadow 0.22s ease-out;
  }

  .mkt-stat:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm, 0 8px 20px rgba(6, 40, 61, 0.12));
  }

  .btn,
  .btn-xl {
    transition:
      transform 0.18s ease-out,
      box-shadow 0.18s ease-out,
      background-color 0.18s ease-out,
      border-color 0.18s ease-out;
  }

  .btn:hover,
  .btn-xl:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm, 0 8px 20px rgba(6, 40, 61, 0.14));
  }

  .btn:active,
  .btn-xl:active {
    transform: translateY(0);
    box-shadow: none;
  }
}

/* Keyboard focus gets the same intent as hover — visible, gold, offset. */
.card:focus-visible,
.door:focus-visible,
.btn:focus-visible,
.btn-xl:focus-visible,
a.card:focus-visible,
a.door:focus-visible {
  outline: 2px solid var(--gold, #b98a2f);
  outline-offset: 3px;
}

/* --------------------------------------------------------------------------
   4. Reduced motion — everything off, everything visible, instantly.
   motion.js also checks this and never hides or counts; this block is the
   CSS half of the same promise (e.g. if the OS setting changes mid-visit).
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html.motion-on .reveal,
  html.motion-on [data-reveal],
  html.motion-on .reveal.is-in,
  html.motion-on [data-reveal].is-in {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .card,
  .door,
  .mkt-stat,
  .btn,
  .btn-xl {
    transition: none !important;
  }

  .card:hover,
  .door:hover,
  .mkt-stat:hover,
  .btn:hover,
  .btn-xl:hover {
    transform: none !important;
  }
}
