/**
 * Site-wide micro-motion — premium feel, respects prefers-reduced-motion
 * Requires: html.motion-js (set by js/motion.js)
 */

:root {
  --motion-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --motion-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --motion-duration: 0.55s;
  --motion-duration-fast: 0.28s;
}

@media (prefers-reduced-motion: reduce) {
  html.motion-js .motion-reveal,
  html.motion-js .motion-reveal.is-visible {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
    animation: none !important;
  }

  .motion-hero-stagger > *,
  .motion-nav-pill {
    animation: none !important;
  }
}

/* ---- Scroll / block reveal (JS adds .motion-reveal + .is-visible) ---- */
@media (prefers-reduced-motion: no-preference) {
  html.motion-js .motion-reveal {
    opacity: 0;
    transform: translate3d(0, 1rem, 0);
    transition:
      opacity var(--motion-duration) var(--motion-ease),
      transform var(--motion-duration) var(--motion-ease);
    transition-delay: var(--motion-delay, 0s);
    will-change: opacity, transform;
  }

  html.motion-js .motion-reveal.is-visible {
    opacity: 1;
    transform: translate3d(0, 0, 0);
    will-change: auto;
  }
}

/* ---- Page load: nav pill ---- */
@media (prefers-reduced-motion: no-preference) {
  @keyframes motionNavIn {
    from {
      opacity: 0;
      transform: translate3d(0, -10px, 0);
    }
    to {
      opacity: 1;
      transform: translate3d(0, 0, 0);
    }
  }

  html.motion-js .nav-pill.motion-nav-pill {
    animation: motionNavIn 0.65s var(--motion-ease-out) forwards;
  }
}

/* ---- Home hero: stagger copy + image ---- */
@media (prefers-reduced-motion: no-preference) {
  @keyframes motionFadeUp {
    from {
      opacity: 0;
      transform: translate3d(0, 0.85rem, 0);
    }
    to {
      opacity: 1;
      transform: translate3d(0, 0, 0);
    }
  }

  html.motion-js .hero.hero--wholesale-hero .hero-text > * {
    animation: motionFadeUp 0.65s var(--motion-ease-out) backwards;
  }

  html.motion-js .hero.hero--wholesale-hero .hero-text > *:nth-child(1) {
    animation-delay: 0.06s;
  }
  html.motion-js .hero.hero--wholesale-hero .hero-text > *:nth-child(2) {
    animation-delay: 0.12s;
  }
  html.motion-js .hero.hero--wholesale-hero .hero-text > *:nth-child(3) {
    animation-delay: 0.18s;
  }
  html.motion-js .hero.hero--wholesale-hero .hero-text > *:nth-child(4) {
    animation-delay: 0.24s;
  }

  html.motion-js .hero.hero--wholesale-hero .hero-image {
    animation: motionFadeUp 0.75s var(--motion-ease-out) 0.1s backwards;
  }

  html.motion-js .marquee.marquee--flush {
    animation: motionFadeUp 0.55s var(--motion-ease-out) 0.35s backwards;
  }
}

/* ---- Story page hero ---- */
@media (prefers-reduced-motion: no-preference) {
  html.motion-js .story-hero .story-hero-content > * {
    animation: motionFadeUp 0.6s var(--motion-ease-out) backwards;
  }
  html.motion-js .story-hero .story-hero-content > *:nth-child(1) {
    animation-delay: 0.08s;
  }
  html.motion-js .story-hero .story-hero-content > *:nth-child(2) {
    animation-delay: 0.14s;
  }
  html.motion-js .story-hero .story-hero-content > *:nth-child(3) {
    animation-delay: 0.2s;
  }
}

/* ---- Contact hero ---- */
@media (prefers-reduced-motion: no-preference) {
  html.motion-js .ct-hero .container > * {
    animation: motionFadeUp 0.58s var(--motion-ease-out) backwards;
  }
  html.motion-js .ct-hero .container > *:nth-child(1) {
    animation-delay: 0.05s;
  }
  html.motion-js .ct-hero .container > *:nth-child(2) {
    animation-delay: 0.1s;
  }
  html.motion-js .ct-hero .container > *:nth-child(3) {
    animation-delay: 0.16s;
  }
}

/* ---- Checkout header ---- */
@media (prefers-reduced-motion: no-preference) {
  html.motion-js .ck-header {
    animation: motionNavIn 0.55s var(--motion-ease-out) forwards;
  }
}

/* ---- Wholesale hero ---- */
@media (prefers-reduced-motion: no-preference) {
  html.motion-js .ws-hero .ws-hero-copy > *,
  html.motion-js .ws-hero .ws-hero-visual {
    animation: motionFadeUp 0.62s var(--motion-ease-out) backwards;
  }
  html.motion-js .ws-hero .ws-hero-copy > *:nth-child(1) {
    animation-delay: 0.06s;
  }
  html.motion-js .ws-hero .ws-hero-copy > *:nth-child(2) {
    animation-delay: 0.12s;
  }
  html.motion-js .ws-hero .ws-hero-copy > *:nth-child(3) {
    animation-delay: 0.18s;
  }
  html.motion-js .ws-hero .ws-hero-visual {
    animation-delay: 0.1s;
  }
}

/* ---- Order success ---- */
@media (prefers-reduced-motion: no-preference) {
  html.motion-js .success-wrap .success-box > * {
    animation: motionFadeUp 0.55s var(--motion-ease-out) backwards;
  }
  html.motion-js .success-wrap .success-box > *:nth-child(1) {
    animation-delay: 0.05s;
  }
  html.motion-js .success-wrap .success-box > *:nth-child(2) {
    animation-delay: 0.1s;
  }
  html.motion-js .success-wrap .success-box > *:nth-child(3) {
    animation-delay: 0.15s;
  }
  html.motion-js .success-wrap .success-box > *:nth-child(4) {
    animation-delay: 0.2s;
  }
  html.motion-js .success-wrap .success-box > *:nth-child(5) {
    animation-delay: 0.25s;
  }
}

/* ---- Interactive polish (non-intrusive) ---- */
@media (prefers-reduced-motion: no-preference) {
  html.motion-js .nav-link,
  html.motion-js .nav-logo {
    transition:
      transform var(--motion-duration-fast) var(--motion-ease),
      opacity var(--motion-duration-fast) var(--motion-ease);
  }

  @media (hover: hover) {
    html.motion-js .nav-link:hover {
      transform: translateY(-1px);
    }
    html.motion-js .nav-logo:hover {
      transform: scale(1.02);
    }
  }

  html.motion-js .shop-frame,
  html.motion-js .fbt-card,
  html.motion-js .pack-card {
    transition:
      transform var(--motion-duration-fast) var(--motion-ease),
      box-shadow var(--motion-duration-fast) var(--motion-ease);
  }

  @media (hover: hover) {
    html.motion-js .fbt-card:hover,
    html.motion-js .pack-card:hover {
      transform: translateY(-2px);
    }
  }

  /* product-card: align with shop.css layered shadow + lift */
  html.motion-js .product-card {
    transition:
      box-shadow var(--motion-duration) var(--motion-ease),
      border-color var(--motion-duration) var(--motion-ease),
      transform var(--motion-duration) var(--motion-ease);
  }

  html.motion-js .filter-btn,
  html.motion-js .view-btn,
  html.motion-js .thumb {
    transition:
      transform 0.2s var(--motion-ease),
      border-color 0.2s var(--motion-ease),
      background 0.2s var(--motion-ease);
  }

  @media (hover: hover) {
    html.motion-js .filter-btn:hover:not(.active) {
      transform: translateY(-1px);
    }
  }

  html.motion-js .to-top {
    transition:
      transform 0.3s var(--motion-ease),
      opacity 0.3s var(--motion-ease);
  }

  html.motion-js .to-top:hover {
    transform: translateY(-2px);
  }

  html.motion-js .drawer {
    transition: transform 0.4s var(--motion-ease);
  }

  html.motion-js input,
  html.motion-js textarea,
  html.motion-js select {
    transition:
      border-color 0.2s var(--motion-ease),
      box-shadow 0.2s var(--motion-ease);
  }

  html.motion-js .pdp-thumb {
    transition:
      transform 0.2s var(--motion-ease),
      opacity 0.2s var(--motion-ease);
  }

  @media (hover: hover) {
    html.motion-js .pdp-thumb:hover {
      transform: scale(1.04);
    }
  }
}
