/* Motion, in the spirit of shopify.com: pages fade into one another, the
   header stays put, a product photo glides from the grid into its page,
   content rises gently into view and buttons answer a press.
   It is all decoration. With "reduce motion" switched on, none of it runs,
   and without JavaScript every page is simply shown as it is. */

:root {
  --glide: cubic-bezier(.16, 1, .3, 1);      /* long, soft landing */
  --spring: cubic-bezier(.34, 1.4, .64, 1);  /* a small overshoot */
}

/* --- buttons and cards answer the pointer (all motion levels: tiny) ----- */
.btn {
  transition: background-color .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease),
              box-shadow .25s var(--ease), transform .3s var(--spring);
}
.btn:active:not(:disabled):not([aria-disabled="true"]) { transform: scale(.965); transition-duration: .08s; }

/* --- the loading line at the top while the next page is on its way ----- */
.mo-bar {
  position: fixed; inset: 0 auto auto 0; z-index: 9999; height: 3px; width: 100%;
  background: linear-gradient(90deg, var(--teal), #19C2AE 60%, var(--gold));
  transform-origin: 0 50%; transform: scaleX(0); opacity: 0; pointer-events: none;
}
.mo-bar.is-going { opacity: 1; transform: scaleX(.85); transition: transform 9s cubic-bezier(.05, .8, .2, 1), opacity .2s; }
.mo-bar.is-done { opacity: 0; transform: scaleX(1); transition: transform .25s var(--ease), opacity .35s .2s; }

@media (prefers-reduced-motion: no-preference) {

  /* --- page to page (Chrome, Edge, Safari 18+; others just load) ------- */
  @view-transition { navigation: auto; }
  ::view-transition-old(root) { animation: mo-fade-out .2s var(--ease) both; }
  ::view-transition-new(root) { animation: mo-page-in .45s var(--glide) both; }
  @keyframes mo-fade-out { to { opacity: 0; } }
  @keyframes mo-page-in { from { opacity: 0; transform: translateY(12px); } }

  /* The headers and the workspace sidebar hold still while the page beneath changes. */
  .mk-head { view-transition-name: mk-head; }
  .sf-head { view-transition-name: sf-head; }
  .ws-side { view-transition-name: ws-side; }
  .ws-top { view-transition-name: ws-top; }
  .ws-tabbar { view-transition-name: ws-tabbar; }
  ::view-transition-group(mk-head), ::view-transition-group(sf-head), ::view-transition-group(ws-side),
  ::view-transition-group(ws-top), ::view-transition-group(ws-tabbar) { animation-duration: .3s; }

  /* A product photo glides from the card to the product page, and back. */
  ::view-transition-group(mo-photo) { animation-duration: .55s; animation-timing-function: var(--glide); }
  ::view-transition-old(mo-photo), ::view-transition-new(mo-photo) { height: 100%; object-fit: cover; }

  /* --- content rising into view (motion.js adds .mo-rise) -------------- */
  .mo-rise { opacity: 0; transform: translateY(28px); }
  .mo-rise.is-seen {
    opacity: 1; transform: none;
    transition: opacity .8s var(--glide), transform 1s var(--glide);
    transition-delay: var(--mo-delay, 0s);
  }

  /* --- first view: the homepage hero and dashboard figures arrive in turn */
  .hm-hero__copy > *, .sf-spot h1, .sf-spot__kicker, .kpis > * {
    animation: mo-arrive .9s var(--glide) both;
  }
  .hm-hero__copy > :nth-child(2), .sf-spot h1, .kpis > :nth-child(2) { animation-delay: .08s; }
  .hm-hero__copy > :nth-child(3), .kpis > :nth-child(3) { animation-delay: .16s; }
  .hm-hero__copy > :nth-child(4), .kpis > :nth-child(4) { animation-delay: .24s; }
  .hm-hero__copy > :nth-child(5), .kpis > :nth-child(5) { animation-delay: .32s; }
  .hm-hero__copy > :nth-child(n+6), .kpis > :nth-child(n+6) { animation-delay: .4s; }
  .hm-show { animation: mo-photo-in 1.2s var(--glide) both .1s; }
  @keyframes mo-arrive { from { opacity: 0; transform: translateY(22px); } }
  @keyframes mo-photo-in { from { opacity: 0; transform: scale(.96); } }

  /* --- cards lift a little under the pointer --------------------------- */
  @media (hover: hover) {
    .pcard, .plan-card, .sf-tile, .ctile, .ptiles > *, .stiles > *, .store-tiles > * {
      transition: transform .45s var(--glide), box-shadow .45s var(--glide);
    }
    .pcard:hover, .plan-card:hover, .sf-tile:hover, .ctile:hover,
    .ptiles > :hover, .stiles > :hover, .store-tiles > :hover { transform: translateY(-4px); }
    .plan-card:hover { box-shadow: var(--shadow-md); }
    .pcard:hover .pcard__media img { transform: scale(1.06); transition-duration: .8s; }
    .btn--primary:hover, .btn--accent:hover, .btn--brand:hover, .btn--gold:hover {
      box-shadow: 0 10px 22px -12px rgba(16, 36, 58, .55);
    }
  }

  /* --- the header tucks away scrolling down and returns scrolling up ---- */
  .mk-head, .sf-head { transition: transform .45s var(--glide), box-shadow .2s var(--ease); }
  .mo-tucked { transform: translateY(-100%); }
}

/* Printed pages show everything, whatever was still waiting to rise into view. */
@media print { .mo-rise { opacity: 1 !important; transform: none !important; } .mo-bar { display: none; } }
