/* ==========================================================================
   AIBuy Canonical Apple-Style Text & Numeric Morph Engine (v4)
   --------------------------------------------------------------------------
   DESIGN SPEC (Permanent Reference — Do NOT replace with instant text swaps):
   1. Vertical stacked Gaussian-blur slide inspired by Apple SwiftUI
      `.contentTransition(.numericText())` & Apple.com:
      - Increase / tier upgrade: old glides UP & blurs out, new glides UP from
        below (`blur(4.2px–5.2px) -> 0px`, `cubic-bezier(0.22, 1, 0.36, 1)`).
      - Decrease / tier downgrade: old glides DOWN, new glides DOWN from above.
   2. Smooth Width-Glide FLIP Continuity (Prefix/Suffix & Pill Box Morph):
      - When digits change length (e.g. `$179.00` <-> `$89.50`, `90 天` <->
        `180 天`, `5 席` <-> `10 席`, `19.92 USDT` <-> `133.62 USDT`),
        appearing/vanishing `.am-char-slot` nodes animate `width: 0px <-> charW`
        on the exact same Apple spring curve so left `$`, right `USD`/`USDT`,
        and outer rounded pill borders glide smoothly with zero snap/jump.
      - `.am-char-static` MUST keep `white-space: pre` so spaces never collapse.
   3. Strict CSP & React Safety:
      - Loaded as external stylesheet on all 5 AIBuy domains + Admin Console
        (zero inline `<style>` injection under `style-src 'self'`).
      - React/periodic dashboards use `#aibuy-morph-portal` floating ghosts +
        WAAPI width glide without mutating React child DOM trees.
   4. Respects `prefers-reduced-motion: reduce`.
   ========================================================================== */

#aibuy-morph-portal {
  position: fixed !important;
  inset: 0 !important;
  width: 0 !important;
  height: 0 !important;
  overflow: visible !important;
  pointer-events: none !important;
  z-index: 99990 !important;
}

.aibuy-morph-ghost {
  position: fixed !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  pointer-events: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  white-space: nowrap !important;
  will-change: transform, opacity, filter !important;
  transform-origin: 50% 50% !important;
  box-sizing: border-box !important;
}

/* Inline per-character numeric roller (explicit DOM mode) */
.am-num-host {
  display: inline-flex;
  align-items: baseline;
  vertical-align: baseline;
  font-variant-numeric: tabular-nums;
  overflow: visible;
}

.am-char-static {
  flex: 0 0 auto;
  white-space: pre;
}

.am-char-slot {
  position: relative;
  flex: 0 0 auto;
  min-width: 0;
  display: inline-grid;
  place-items: baseline center;
  justify-content: center;
  vertical-align: baseline;
  white-space: pre;
  overflow: visible;
}

.am-char-strut {
  grid-area: 1 / 1;
  display: inline-block;
  width: 0;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.am-char-cur {
  grid-area: 1 / 1;
  display: inline-block;
  white-space: pre;
  will-change: transform, opacity, filter;
}

.am-char-old {
  grid-area: 1 / 1;
  display: inline-block;
  white-space: pre;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  will-change: transform, opacity, filter;
}

/* Out-of-flow exiting char so collapsing slot smoothly glides 100% -> 0px with zero jump */
.am-char-old.is-abs {
  position: absolute;
  left: 50%;
  top: 0;
  grid-area: auto;
}

/* Whole-label vertical stacked blur-slide host (explicit DOM mode) */
.am-text-host {
  position: relative;
  display: inline-grid;
  align-items: baseline;
  vertical-align: baseline;
  min-width: 0;
  overflow: visible;
}

.am-text-cur {
  grid-area: 1 / 1;
  display: inline-block;
  white-space: nowrap;
  will-change: transform, opacity, filter;
}

.am-text-old {
  position: absolute;
  top: 0;
  left: 0;
  display: inline-block;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  will-change: transform, opacity, filter;
}

.am-text-old.is-right {
  left: auto;
  right: 0;
}

.am-text-old.is-center {
  left: 50%;
}

/* Prevent mid-glide line-wrapping inside animated pills/badges across all 5 sites */
.am-gliding-box,
.am-gliding-box > *,
#last-update,
.update-meta,
.service-current,
.uptime-value,
.ao-nav-badge,
.expiry-value {
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .aibuy-morph-ghost {
    display: none !important;
  }
}
