/* Motion for getmuscleonglp.com (linked after styles.css, next to motion.js).
   Everything here enhances content that is already fully visible. motion.js
   sets data-m-armed only when it can animate, and every rule that moves
   anything sits inside prefers-reduced-motion: no-preference, so reduced-motion
   and no-JS visitors get the final state. One curve throughout: ease-out
   exponential. Animated properties: transform (and translate/scale/rotate),
   opacity, clip-path. The two exceptions are the FAQ height, which has to
   change to open, and the hover shadows styles.css already transitions. */

:root { --ease: cubic-bezier(0.16, 1, 0.3, 1); }

/* Scroll reveal ---------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  [data-m-armed] { opacity: 0; }

  @keyframes m-in {
    from { opacity: 0; translate: 0 16px; }
    to   { opacity: 1; translate: none; }
  }
  [data-m-in] { animation: m-in 0.7s var(--ease) backwards; }

  /* Sibling delay, set by the script per batch and capped at 5. */
  [data-m-i="1"] { animation-delay: 70ms; }
  [data-m-i="2"] { animation-delay: 140ms; }
  [data-m-i="3"] { animation-delay: 210ms; }
  [data-m-i="4"] { animation-delay: 280ms; }
  [data-m-i="5"] { animation-delay: 350ms; }
}

/* Hero entrance (CSS only) ---------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  /* Text never starts at opacity 0: the headline is the largest paint and
     held-back text would delay it. Text rises into place; only buttons,
     badges and the trust row fade. */
  @keyframes m-rise { from { translate: 0 14px; } to { translate: none; } }
  @keyframes m-pop  { from { opacity: 0; scale: 0.92; } to { opacity: 1; scale: 1; } }
  @keyframes m-lift { from { translate: 0 26px; scale: 0.97; } to { translate: none; scale: 1; } }
  @keyframes m-fan  { from { rotate: -9deg; translate: -14px 0; } to { rotate: 0deg; translate: none; } }

  .hero .eyebrow, .hero-stat, .hero h1, .hero .lead,
  .article-hero .wrap > *, .guide-hero .eyebrow, .guide-hero h1, .guide-hero .guide-sub {
    animation: m-rise 0.8s var(--ease) backwards;
  }
  .hero-cta, .hero-trust, .guide-buybox { animation: m-in 0.8s var(--ease) backwards; }

  .hero .eyebrow { animation-delay: 0ms; }
  .hero-stat { animation-delay: 60ms; }
  .hero h1 { animation-delay: 110ms; }
  .hero .lead { animation-delay: 170ms; }
  .hero-cta { animation-delay: 240ms; }
  .hero-trust { animation-delay: 310ms; }

  /* The cover settles, then the pages behind it fan out from under it. */
  .hero-cover, .guide-cover { animation: m-lift 0.95s var(--ease) 80ms backwards; }
  .hero-page-1 { animation: m-fan 1.1s var(--ease) 260ms backwards; }
  .hero-page-2 { animation: m-fan 1.1s var(--ease) 340ms backwards; }
  .hero-badge { animation: m-pop 0.8s var(--ease) 480ms backwards; }

  .article-hero .wrap > :nth-child(2) { animation-delay: 50ms; }
  .article-hero .wrap > :nth-child(3) { animation-delay: 100ms; }
  .article-hero .wrap > :nth-child(4) { animation-delay: 150ms; }
  .article-hero .wrap > :nth-child(n+5) { animation-delay: 200ms; }
  .guide-hero h1 { animation-delay: 60ms; }
  .guide-hero .guide-sub { animation-delay: 120ms; }
  .guide-buybox { animation-delay: 200ms; }
}

/* Scroll-linked touches (CSS only, where the browser supports them) ------ */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    /* Reading progress: a thin bar over the top edge on article pages. */
    @keyframes m-progress { to { transform: scaleX(1); } }
    main:has(.article)::before {
      content: "";
      position: fixed;
      inset: 0 0 auto 0;
      height: 3px;
      z-index: 60;
      background: var(--accent-bright);
      transform: scaleX(0);
      transform-origin: 0 50%;
      pointer-events: none;
      animation: m-progress linear both;
      animation-timeline: scroll(root block);
    }

    /* Screenshots rise and settle as they enter: a slow depth cue. The
       individual translate/scale properties leave transform free for hover. */
    @keyframes m-depth {
      from { translate: 0 34px; scale: 0.965; }
      to   { translate: none; scale: 1; }
    }
    .preview-strip img {
      animation: m-depth var(--ease) backwards;
      animation-timeline: view();
      animation-range: entry 0% entry 80%;
    }
    .preview-strip img:nth-child(2) { animation-range: entry 8% entry 88%; }
    .preview-strip img:nth-child(3) { animation-range: entry 16% entry 96%; }
  }
}

/* Cards, buttons, links -------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  .btn { transition: transform 0.3s var(--ease), box-shadow 0.18s, background 0.18s; }
  .btn:active { transform: translateY(0) scale(0.97); transition-duration: 0.08s; }

  /* Nav links draw an underline in from the left. */
  .nav-links a:not(.btn) { position: relative; }
  .nav-links a:not(.btn)::after {
    content: "";
    position: absolute;
    inset: auto 0 -3px 0;
    height: 2px;
    border-radius: 2px;
    background: var(--accent-bright);
    transform: scaleX(0);
    transform-origin: 0 50%;
    transition: transform 0.35s var(--ease);
  }
  .nav-links a:not(.btn):hover::after,
  .nav-links a:not(.btn):focus-visible::after { transform: scaleX(1); }

  .foot-col a { transition: translate 0.3s var(--ease), color 0.18s; }
  .foot-col a:hover, .foot-col a:focus-visible { translate: 3px 0; }

  .related-reading li::before { transition: translate 0.3s var(--ease); }
  .related-reading li:hover::before { translate: 4px 0; }

  .lc-more, .lr-more, .gc-more { transition: translate 0.3s var(--ease); }
  .learn-card:hover .lc-more, .lr-card:hover .lr-more, .guide-card:hover .gc-more { translate: 4px 0; }

  /* The FAQ plus sign turns on the same curve as everything else. */
  summary::after { transition: transform 0.35s var(--ease); }
}

@media (prefers-reduced-motion: no-preference) and (hover: hover) {
  .feature, .guide-card, .learn-card, .lr-card, .social-card {
    transition: transform 0.4s var(--ease), box-shadow 0.2s, border-color 0.2s;
  }
  .feature:hover, .guide-card:hover, .learn-card:hover, .lr-card:hover, .social-card:hover {
    transform: translateY(-5px);
  }
  .preview-strip img { transition: transform 0.5s var(--ease), box-shadow 0.25s; }
  .hero-cover { transition: transform 0.6s var(--ease); }
}

/* Keyboard focus is visible on the controls this file touches. */
.btn:focus-visible, summary:focus-visible, .m-bar-x:focus-visible {
  outline: 3px solid var(--accent-bright);
  outline-offset: 3px;
}

/* Smooth FAQ open and close, where <details> content can be sized ------- */
@supports (interpolate-size: allow-keywords) {
  @media (prefers-reduced-motion: no-preference) {
    :root { interpolate-size: allow-keywords; }
    details::details-content {
      block-size: 0;
      overflow: clip;
      opacity: 0;
      transition:
        block-size 0.4s var(--ease),
        opacity 0.3s var(--ease),
        content-visibility 0.4s var(--ease) allow-discrete;
    }
    details[open]::details-content { block-size: auto; opacity: 1; }
  }
}

/* Slim buy bar on product pages (built in motion.js) --------------------- */
.m-bar[hidden] { display: none; }
.m-bar {
  position: fixed;
  z-index: 40;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 16px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
  box-shadow: 0 -6px 24px rgba(20, 40, 33, 0.1);
}
.m-bar-t { flex: 1; min-width: 0; font-size: 0.95rem; color: var(--ink-soft); line-height: 1.3; }
.m-bar-t strong { font-family: var(--font-display); font-size: 1.4rem; color: var(--ink); margin-right: 8px; }
.m-bar .btn { flex: none; padding: 11px 20px; font-size: 0.95rem; white-space: nowrap; }
.m-bar-x {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.m-bar-x:hover { background: var(--accent-light); color: var(--ink); }
@media (max-width: 560px) { .m-bar-u { display: none; } .m-bar .btn { padding: 11px 16px; } }
@media (min-width: 761px) {
  .m-bar {
    left: 50%;
    right: auto;
    bottom: 16px;
    width: max-content;
    max-width: min(720px, calc(100vw - 32px));
    translate: -50% 0;
    padding: 8px 8px 8px 24px;
    border: 1px solid var(--line);
    border-radius: 100px;
    box-shadow: 0 10px 30px rgba(20, 40, 33, 0.16);
  }
}
@media (prefers-reduced-motion: no-preference) {
  @keyframes m-bar-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
  .m-bar { animation: m-bar-in 0.45s var(--ease) backwards; }
}
@media print { .m-bar { display: none; } }
