/* ══ motion layer ═════════════════════════════════════════════════════════
   Soft, slow, transform/opacity only. Loaded after every theme file.
   Everything here is additive: no layout, no colour ownership. */

:root {
  --m-ease: cubic-bezier(0.22, 0.61, 0.25, 1);
  --m-soft: cubic-bezier(0.16, 0.84, 0.28, 1);
  --m-fast: 160ms;
  --m-mid: 280ms;
}

html { scroll-behavior: smooth; }

@keyframes m-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes m-rise { from { opacity: 0; translate: 0 18px; } to { opacity: 1; translate: 0 0; } }
@keyframes m-rise-sm { from { opacity: 0; translate: 0 10px; } to { opacity: 1; translate: 0 0; } }
@keyframes m-slide-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes m-sheen {
  from { transform: translateX(-140%) skewX(-12deg); }
  to { transform: translateX(280%) skewX(-12deg); }
}
@keyframes m-breathe { 0%, 100% { opacity: 0.55; } 50% { opacity: 0.95; } }
@keyframes m-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(56, 232, 198, 0); }
  50% { box-shadow: 0 0 14px 1px rgba(56, 232, 198, 0.38); }
}
@keyframes m-drift {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -6px; }
}

/* ── page change: fade out to the canvas, next page fades in ─────────── */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  pointer-events: none;
  background: radial-gradient(circle at 50% 42%, #0b0e15 0%, #06080c 72%);
  opacity: 0;
  transition: opacity var(--m-fast) cubic-bezier(0.4, 0, 0.2, 1);
}
body.m-leaving::after { opacity: 1; }

/* ── primary button sheen ────────────────────────────────────────────── */
.btn-primary { position: relative; overflow: hidden; }
.btn-primary::after {
  content: '';
  position: absolute;
  top: -30%;
  bottom: -30%;
  left: 0;
  width: 38%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transform: translateX(-140%) skewX(-12deg);
  opacity: 0;
  pointer-events: none;
}
.btn-primary:hover::after { animation: m-sheen 0.85s cubic-bezier(0.3, 0.7, 0.2, 1) both; }

/* ── micro hovers ────────────────────────────────────────────────────── */
.side-nav a,
.lmx-steps li,
.lmx-row,
.lmx-plan {
  transition:
    translate 0.24s var(--m-ease),
    background-color 0.24s ease,
    border-color 0.2s ease,
    color 0.18s ease;
}
.side-nav a:hover,
.lmx-steps li:hover,
.lmx-row:hover { translate: 3px 0; }

.card,
.stat-card,
.acard,
.bots-card,
.plugin-card {
  transition:
    translate 0.28s var(--m-ease),
    border-color 0.22s ease,
    box-shadow 0.32s ease;
}
.card:hover,
.stat-card:hover,
.acard:hover,
.bots-card:hover { translate: 0 -2px; }

.ico-btn .ico,
.lm-sfx .ico {
  transition: transform 0.24s var(--m-ease), color 0.18s ease;
}
.ico-btn:hover .ico,
.lm-sfx:hover .ico { transform: scale(1.08); }

tbody tr { transition: background-color 0.2s ease; }

/* nav underline */
.lmx-nav-links button { position: relative; }
.lmx-nav-links button::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -5px;
  height: 1px;
  background: var(--acc);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 0.3s var(--m-ease);
}
.lmx-nav-links button:hover::after,
.lmx-nav-links button:focus-visible::after { transform: scaleX(1); }

/* ── ambient: landing canvas + brand ─────────────────────────────────── */
.lmx-view::before { animation: m-breathe 11s ease-in-out infinite; }
.lm-brand-dot { animation: m-glow 4.6s ease-in-out infinite; }

/* landing pane stagger — replays every time a pane activates */
.lmx-pane.is-on .lmx-wrap > * { animation: m-rise-sm 0.6s var(--m-soft) both; }
.lmx-pane.is-on .lmx-wrap > :nth-child(2) { animation-delay: 0.07s; }
.lmx-pane.is-on .lmx-wrap > :nth-child(3) { animation-delay: 0.14s; }
.lmx-pane.is-on .lmx-wrap > :nth-child(4) { animation-delay: 0.21s; }
.lmx-pane.is-on .lmx-wrap > :nth-child(5) { animation-delay: 0.28s; }
.lmx-pane.is-on .lmx-wrap > :nth-child(6) { animation-delay: 0.35s; }

/* ── dialog, toast, banner ───────────────────────────────────────────── */
dialog[open]::backdrop { animation: m-fade 0.3s ease both; }
.toast { animation: m-slide-up 0.35s var(--m-soft) both; }
.version-banner { animation: m-slide-up 0.4s var(--m-soft) both; }

/* ── scroll reveal — chrome/edge view timeline ───────────────────────── */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .dash-content .card,
    .dash-content .stat-card,
    .dash-content .acard,
    .dash-content .bots-card,
    .dash-content .plugin-card {
      animation: m-rise linear both;
      animation-timeline: view();
      animation-range: entry 5% entry 45%;
    }
  }
}

/* ── counters ────────────────────────────────────────────────────────── */
[data-count] { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body::after { display: none; }
  .btn-primary::after { display: none; }
  .lmx-view::before,
  .lm-brand-dot,
  .lmx-pane.is-on .lmx-wrap > *,
  .toast,
  .version-banner { animation: none; }
  .side-nav a:hover,
  .lmx-steps li:hover,
  .lmx-row:hover,
  .card:hover,
  .stat-card:hover,
  .acard:hover,
  .bots-card:hover { translate: none; }
}
