/* One motion system for every layout: staff app, crew app, partner and supplier portals, the
   console, the platform's public site and brands' websites (static/js/motion.js).
   Calm and quick: things rise into place, numbers count up, bars fill, buttons answer the
   press, milestones get a small celebration. Everything stops for people who ask for reduced
   motion. Colours come from each layout's own variables, with fallbacks. */

:root {
  --motion-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --motion-fast: 160ms;
  --motion-base: 420ms;
  --motion-accent: var(--brand, var(--primary, var(--color-brand-600, #7a1e16)));
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }

  /* Rise into place, one after the other (--i is the order, set in templates or by the script). */
  .js-motion .motion-rise:not(.is-in) { opacity: 0; transform: translateY(10px); }
  .js-motion .motion-rise {
    transition: opacity var(--motion-base) var(--motion-ease), transform var(--motion-base) var(--motion-ease);
    transition-delay: calc(min(var(--i, 0), 8) * 60ms);
  }

  /* Cards and buttons answer the pointer. */
  .motion-lift, .bl-card, .sp-plan, .pv-card, .mk-card {
    transition: transform var(--motion-fast) var(--motion-ease), box-shadow var(--motion-fast) var(--motion-ease);
  }
  .motion-lift:hover, .bl-card:hover, .pv-card:hover, .mk-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 30px -18px rgb(15 23 42 / 0.35);
  }
  :where(button, .btn, [class^="btn-"], [class*=" btn-"]):not(:disabled):active { transform: scale(0.97); }
  :where(button, .btn, [class^="btn-"], [class*=" btn-"]) { transition: transform 90ms ease, background-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease; }

  /* A new page arrives softly: opacity only. A transform here would make the page the
     containing block of fixed panels (the site editor's inspector would sit inside it). */
  .js-motion main:not(:has(.se-panel)), .js-motion .main { animation: motion-page 360ms var(--motion-ease) both; }
}

@keyframes motion-page {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* A live dot: something is running right now. */
.motion-live { display: inline-flex; align-items: center; gap: 0.45em; }
.motion-live::before {
  content: ""; width: 0.55em; height: 0.55em; border-radius: 999px; background: #16a34a;
  box-shadow: 0 0 0 0 rgb(22 163 74 / 0.5); animation: motion-pulse 2.2s ease-out infinite;
}
@keyframes motion-pulse {
  0% { box-shadow: 0 0 0 0 rgb(22 163 74 / 0.45); }
  70%, 100% { box-shadow: 0 0 0 0.6em rgb(22 163 74 / 0); }
}

/* Bars that fill to their value (data-meter="used/most"). */
[data-meter] { transition: width 900ms var(--motion-ease); }

/* A small celebration at milestones (data-celebrate): pieces fall from the message. */
.motion-confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 9999; }
.motion-confetti i {
  position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px; opacity: 0.95;
  animation: motion-fall var(--fall, 1600ms) cubic-bezier(0.25, 0.6, 0.4, 1) forwards;
}
@keyframes motion-fall {
  to { transform: translate(var(--dx, 0), 105vh) rotate(var(--spin, 540deg)); opacity: 0; }
}

/* Live "3 minutes ago" times keep their width while they change. */
time[data-relative] { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  .motion-live::before { animation: none; }
  .motion-confetti { display: none; }
  [data-meter] { transition: none; }
}
