/* LOCALMATE home motion layer (index / en / ph / cn)
 *
 * Rules for every effect in this file:
 * - only transform-family properties (transform, translate, scale) and opacity animate,
 *   so nothing here moves layout;
 * - no hard-coded light/dark colours: currentColor, existing tokens or transparency only,
 *   so the dark-mode stylesheet keeps working;
 * - hover and keyboard focus show the same state;
 * - prefers-reduced-motion: the hidden "before reveal" state is never applied
 *   (localmate-motion.js does not add html.lm-motion), and hover lifts/zooms are off.
 */

/* ---- 1. Reveal once on scroll ---------------------------------------- */
/* localmate-motion.js adds .lm-rv only to elements that start below the fold,
   and .is-in once when they enter. Elements never go back to hidden. */
html.lm-motion .lm-rv {
  opacity: 0;
  translate: 0 28px;
  transition:
    opacity .5s var(--lm-ease, cubic-bezier(.2, .7, .2, 1)) var(--lm-rv-delay, 0ms),
    translate .6s var(--lm-ease, cubic-bezier(.2, .7, .2, 1)) var(--lm-rv-delay, 0ms);
}
html.lm-motion .lm-rv.is-in { opacity: 1; translate: none; }

/* Key numbers: the plan price settles a beat after its card. */
html.lm-motion .sm-package.lm-rv .sm-price {
  opacity: 0;
  translate: 0 12px;
  transition:
    opacity .45s var(--lm-ease, ease) calc(var(--lm-rv-delay, 0ms) + 180ms),
    translate .55s cubic-bezier(.34, 1.4, .64, 1) calc(var(--lm-rv-delay, 0ms) + 180ms);
}
html.lm-motion .sm-package.lm-rv.is-in .sm-price { opacity: 1; translate: none; }

/* The recommended plan's badge pops once when its card arrives. */
html.lm-motion .sm-package.lm-rv .sm-popular {
  display: inline-block;
  opacity: 0;
  scale: .6;
  transition:
    opacity .3s ease calc(var(--lm-rv-delay, 0ms) + 380ms),
    scale .45s cubic-bezier(.34, 1.56, .64, 1) calc(var(--lm-rv-delay, 0ms) + 380ms);
}
html.lm-motion .sm-package.lm-rv.is-in .sm-popular { opacity: 1; scale: 1; }

/* ---- 2. Case cards (#works) ------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  #works .con1_port,
  #works .con1_port_mobile {
    transition:
      opacity .5s var(--lm-ease, ease) var(--lm-rv-delay, 0ms),
      translate .6s var(--lm-ease, ease) var(--lm-rv-delay, 0ms),
      transform .35s var(--lm-ease, ease);
  }
  #works .con1_port .lm_homepage_image,
  #works .lm_card_visual > img {
    transition: transform .6s var(--lm-ease, ease);
    transform-origin: 50% 50%;
  }
  /* PC: lift + slow image zoom. Keyboard focus on the card link shows the same. */
  #works .con1_port:focus-within,
  #works .con1_port_mobile:focus-within { transform: translate3d(0, -6px, 0); }
  #works .con1_port:focus-within .lm_homepage_image,
  #works .con1_port_mobile:focus-within .lm_card_visual > img { transform: scale(1.04); }
  @media (hover: hover) and (pointer: fine) {
    #works .con1_port:hover,
    #works .con1_port_mobile:hover { transform: translate3d(0, -6px, 0); }
    #works .con1_port:hover .lm_homepage_image,
    #works .con1_port_mobile:hover .lm_card_visual > img { transform: scale(1.04); }
  }
  /* Phone: a quick press so a tap feels answered before the new tab opens. */
  @media (hover: none) {
    #works .con1_port_mobile:active { transform: scale(.985); transition-duration: .12s; }
    #works .con1_port_mobile:active .lm_card_visual > img { transform: scale(1.03); }
  }
}

/* ---- 3. Plan cards (#process) ----------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  #process .sm-package {
    transition:
      opacity .5s var(--lm-ease, ease) var(--lm-rv-delay, 0ms),
      translate .6s var(--lm-ease, ease) var(--lm-rv-delay, 0ms),
      transform .3s var(--lm-ease, ease);
  }
  #process .sm-package-example > img { transition: transform .5s var(--lm-ease, ease); }
  #process .sm-package:focus-within { transform: translate3d(0, -4px, 0); }
  #process .sm-package-example:focus-visible > img { transform: scale(1.04); }
  @media (hover: hover) and (pointer: fine) {
    #process .sm-package:hover { transform: translate3d(0, -4px, 0); }
    #process .sm-package-example:hover > img { transform: scale(1.04); }
  }
}

/* ---- 4. Main CTA buttons ---------------------------------------------- */
/* Subtle: a 2px lift and an arrow nudge on hover/focus, plus a single light
   sweep the first time the contact buttons or the sticky submit come into view. */
@media (prefers-reduced-motion: no-preference) {
  #contact .lm_contact_channels .lm-btn,
  #service .lm_cta a,
  #contact .form_submit,
  #process .sm-package-link,
  .lm_quick .lm_quick_submit {
    transition-property: background-color, color, border-color, opacity, transform, translate;
    transition-duration: var(--lm-duration, 200ms), var(--lm-duration, 200ms), var(--lm-duration, 200ms), .5s, .2s, .6s;
    transition-timing-function: var(--lm-ease, ease);
    transition-delay: 0s, 0s, 0s, var(--lm-rv-delay, 0ms), 0s, var(--lm-rv-delay, 0ms);
  }
  #contact .lm_contact_channels .lm-btn > span[aria-hidden="true"] {
    display: inline-block;
    transition: transform .2s var(--lm-ease, ease);
  }
  :is(#contact .lm_contact_channels .lm-btn, #service .lm_cta a, #contact .form_submit, #process .sm-package-link, .lm_quick .lm_quick_submit):focus-visible {
    transform: translate3d(0, -2px, 0);
  }
  #contact .lm_contact_channels .lm-btn:focus-visible > span[aria-hidden="true"] { transform: translate3d(2px, -2px, 0); }
  @media (hover: hover) and (pointer: fine) {
    :is(#contact .lm_contact_channels .lm-btn, #service .lm_cta a, #contact .form_submit, #process .sm-package-link, .lm_quick .lm_quick_submit):hover {
      transform: translate3d(0, -2px, 0);
    }
    #contact .lm_contact_channels .lm-btn:hover > span[aria-hidden="true"] { transform: translate3d(2px, -2px, 0); }
  }

  .lm-sheen { position: relative; overflow: hidden; isolation: isolate; }
  .lm-sheen::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: linear-gradient(105deg, transparent 35%, currentColor 50%, transparent 65%);
    opacity: .14;
    transform: translate3d(-120%, 0, 0);
  }
  .lm-sheen.lm-sheen--go::after { animation: lm-sheen 1.1s var(--lm-ease, ease) forwards; }
}
@keyframes lm-sheen {
  to { transform: translate3d(120%, 0, 0); }
}

/* ---- 5. Calmer background motion ---------------------------------------- */
/* The two vertical CONTACT / LOCALMATE strips ran at 32s and 20s, so they drifted
   against each other. One slower shared pace, and they stop while off screen. */
#contact .main_scry.scrY .scrY_item { animation-duration: 48s !important; }
#contact.lm-offscreen .main_scry.scrY .scrY_item,
#service.lm-offscreen .con2_bottom_scr_1st { animation-play-state: paused; }
