/* Motion layer, shared by every page. Loaded right after ui.css.
   Rules: everything starts visible; UI feedback runs 120-320ms on var(--ease) (exponential ease-out);
   transform, opacity, clip-path and shadow only; one authored moment per page lives in the page's own CSS.
   Everything here is switched off by the prefers-reduced-motion block at the end (state changes stay, movement goes). */

:root { --dur-quick: 120ms; --dur-ui: 220ms; --dur-lead: 320ms; }

/* ---------- Shared keyframes ---------- */
@keyframes mp-reveal { from { opacity: 0; transform: translateY(-4px); } }
@keyframes mp-fade { from { opacity: 0; } }
@keyframes mp-pop { 0% { transform: scale(1); } 35% { transform: scale(1.32); } 100% { transform: scale(1); } }
@keyframes mp-bump { 0% { transform: scale(1); } 35% { transform: scale(1.3); } 100% { transform: scale(1); } }
@keyframes mp-ring { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 55%, transparent); } to { box-shadow: 0 0 0 10px transparent; } }
@keyframes mp-draw { to { stroke-dashoffset: 0; } }
@keyframes mp-check-in { from { opacity: 0; transform: scale(.6); } }
@keyframes mp-menu-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
@keyframes mp-menu-out { to { opacity: 0; transform: translateY(-4px) scale(.98); } }
@keyframes mp-sheet-in { from { transform: translateY(100%); } }
@keyframes mp-sheet-out { to { transform: translateY(100%); } }
@keyframes mp-scrim-out { to { opacity: 0; } }
@keyframes mp-toast-in { from { opacity: 0; transform: translateY(-10px) scale(.98); } }
@keyframes mp-tick { from { opacity: .35; transform: translateY(5px); } }
@keyframes mp-bar { from { transform: scaleY(0); } }
@keyframes mp-node { from { transform: scale(.7); opacity: .4; } }
@keyframes mp-node-ring { from { opacity: .55; transform: scale(.9); } to { opacity: 0; transform: scale(1.9); } }
@keyframes mp-wave { 0% { rotate: 0deg; translate: 0 0; } 20% { rotate: -4deg; translate: 0 -3px; } 45% { rotate: 3deg; translate: 0 0; } 70% { rotate: -2deg; translate: 0 -2px; } 100% { rotate: 0deg; translate: 0 0; } }

/* ---------- Buttons: press and hover feedback ---------- */
.btn:not([disabled]):not([aria-disabled="true"]):not(.is-loading):active { transform: scale(.97); transition-duration: 80ms; }
.btn:not(.btn--ghost):not(.btn--danger):not([disabled]):not([aria-disabled="true"]):hover { box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--bd) 85%, transparent); }
.btn--ghost:not([disabled]):hover { box-shadow: 0 6px 14px -10px rgb(13 11 46 / .35); }
.icon-btn, .mast-link, .card-act, .pill, .chip, .pp-icon, .filter-close { transition-property: background, color, border-color, box-shadow, transform; transition-duration: var(--dur-quick); transition-timing-function: var(--ease); }
.icon-btn:active, .mast-link:active, .card-act:not([disabled]):active, .pill:active, .chip:active, .pp-icon:active, .filter-close:active { transform: scale(.93); }
.link-btn { transition: color var(--dur-quick) var(--ease); }

/* ---------- Add to cart: the button morphs to a check, then returns ---------- */
.btn.is-added, .card-act.is-added { position: relative; }
.btn.is-added { --bg: var(--live); --fg: transparent; --bd: var(--live); }
.card-act.is-added { background: var(--live); color: transparent; }
.is-added > :not(.add-check) { opacity: 0; transition: opacity var(--dur-quick) var(--ease); }
.is-added.is-loading::after { display: none; }
.add-check { color: var(--ink); position: absolute; inset: 0; margin: auto; width: 1.35em; height: 1.35em; stroke-width: 2.4; stroke-dasharray: 20; stroke-dashoffset: 20; animation: mp-check-in 200ms var(--ease) backwards, mp-draw 320ms var(--ease) 60ms forwards; }
.is-added .add-check { opacity: 1 !important; }

/* Count badges bump when their number changes */
.cart-tag.is-bump { animation: mp-ring 700ms var(--ease); }
.cart-tag.is-bump b, .wish-tag.is-bump b { animation: mp-bump 360ms var(--ease); }

/* ---------- Wishlist heart pop ---------- */
.wish-btn .i, .btn .i { transition: fill var(--dur-ui) var(--ease), color var(--dur-ui) var(--ease); }
.is-pop > .i { animation: mp-pop 380ms var(--ease); }

/* ---------- Toasts ---------- */
.toast { animation: mp-toast-in var(--dur-ui) var(--ease) backwards; }
.toast.is-leaving { opacity: 0; transform: translateY(-6px) scale(.98); transition: opacity 160ms var(--ease), transform 160ms var(--ease); }

/* ---------- Menus, popovers and the filter bottom sheet ---------- */
.acct-menu[open] .acct-pop { transform-origin: 100% 0; animation: mp-menu-in var(--dur-ui) var(--ease) backwards; }
.acct-menu.is-closing .acct-pop { animation: mp-menu-out 130ms var(--ease) forwards; }
.shop-menu.is-closing .shop-panel { animation: mp-menu-out 140ms var(--ease) forwards; }
.filter-box[open] .filter-panel { transform-origin: 100% 0; animation: mp-menu-in var(--dur-ui) var(--ease) backwards; }
.filter-box.is-closing .filter-panel { animation: mp-menu-out 130ms var(--ease) forwards; }
@media (max-width: 720px) {
  .filter-box[open] .filter-panel { animation: mp-sheet-in var(--dur-lead) var(--ease) backwards; }
  .filter-box.is-closing .filter-panel { animation: mp-sheet-out 200ms var(--ease) forwards; }
  .filter-box[open]::before { animation: mp-fade var(--dur-ui) var(--ease) backwards; }
  .filter-box.is-closing::before { animation: mp-scrim-out 200ms var(--ease) forwards; }
}

/* ---------- Quantity and total changes ---------- */
.qty input { font-variant-numeric: tabular-nums; }
.qty button { transition: background var(--dur-quick) var(--ease), color var(--dur-quick) var(--ease), transform var(--dur-quick) var(--ease); }
.qty button:active:not(:disabled) { transform: scale(.88); }
.is-ticking { animation: mp-tick var(--dur-ui) var(--ease); }
.cart-line.is-updating [data-line-total] { opacity: .45; transition: opacity var(--dur-ui) var(--ease); }
[data-line-total], [data-total] { transition: opacity var(--dur-ui) var(--ease); }

/* ---------- Validation: errors fade and slide in, nothing shakes ---------- */
.errorlist, .field-error, .err-summary, .form-error-summary, .field .hint.is-error { animation: mp-reveal var(--dur-ui) var(--ease) backwards; }
input, select, textarea { transition: border-color var(--dur-quick) var(--ease), box-shadow var(--dur-quick) var(--ease), background var(--dur-quick) var(--ease); }

/* ---------- Payment states ---------- */
.state-node--ok { position: relative; animation: mp-node 420ms var(--ease) backwards; }
.state-node--ok::after { content: ""; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--ok); pointer-events: none; animation: mp-node-ring 800ms var(--ease) 80ms both; }
.state-node--ok .i { stroke-dasharray: 20; stroke-dashoffset: 20; animation: mp-draw 420ms var(--ease) 160ms forwards; }
.state-node--fault { animation: mp-node 320ms var(--ease) backwards; }
.state-node--live { animation: mp-node 320ms var(--ease) backwards; }
.pay-state .btn.is-loading { opacity: 1; }

/* ---------- Assistant typing dots arrive softly ---------- */
.pp-typing { animation: mp-fade var(--dur-ui) var(--ease) backwards; }

/* ---------- Staff chart: bars grow once from the baseline ---------- */
.chart .bar { transform-box: fill-box; transform-origin: 50% 100%; animation: mp-bar 640ms var(--ease) calc(var(--i, 0) * 28ms) backwards; }

/* ---------- Brand mascot ---------- */
.mascot { display: block; height: auto; max-width: 100%; transform-origin: 50% 100%; }
.mascot--wave { animation: mp-wave 1.9s var(--ease) .6s 2; }
.empty--mascot .mascot { width: 6.5rem; }
.empty-mark { display: block; width: 3.5rem; height: auto; border-radius: 50%; }
.pay-mascot { width: 5.25rem; align-self: end; }
.state-head--mascot { grid-template-columns: auto minmax(0, 1fr) auto; }
.err-mark { width: 3.25rem; height: auto; margin: -.2rem 0 -.2rem auto; border-radius: 50%; }
.err-code { display: flex; align-items: center; gap: var(--s3); }
.foot-note { display: flex; align-items: center; gap: .65rem; }
.foot-badge { display: block; width: 1.75rem; height: auto; flex: none; }
.auth-mark { display: block; width: 3.75rem; height: auto; border-radius: 50%; box-shadow: 0 0 0 2px color-mix(in srgb, var(--live) 40%, transparent); }
.acct-id { display: flex; align-items: center; gap: var(--s4); }
.acct-badge { width: 3.5rem; height: auto; flex: none; }
@media (max-width: 560px) {
  .state-head--mascot { grid-template-columns: auto minmax(0, 1fr); }
  .state-head--mascot .pay-mascot { grid-column: 1 / -1; width: 4.5rem; justify-self: start; }
}

/* ---------- Reduced motion: no movement; colour and state changes stay legible ---------- */
@media (prefers-reduced-motion: reduce) {
  .btn:not([disabled]):active, .icon-btn:active, .mast-link:active, .card-act:active, .pill:active, .chip:active, .pp-icon:active, .filter-close:active, .qty button:active:not(:disabled) { transform: none; }
  .cart-tag.is-bump, .cart-tag.is-bump b, .wish-tag.is-bump b, .is-pop > .i, .is-ticking, .mascot--wave { animation: none; }
  .toast, .errorlist, .field-error, .err-summary, .form-error-summary, .pp-typing { animation: none; }
  .acct-menu[open] .acct-pop, .filter-box[open] .filter-panel, .filter-box[open]::before { animation: none; }
  .state-node--ok, .state-node--ok::after, .state-node--fault, .state-node--live { animation: none; }
  .state-node--ok::after { display: none; }
  .state-node--ok .i, .add-check { animation: none; stroke-dashoffset: 0; }
  .chart .bar { animation: none; }
  .toast.is-leaving { transform: none; }
}
