/* 加购动效（配合 public/js/bz-cart-fx.js）
   部分选择器加了 body 前缀：主题的按钮 / 抽屉样式在本文件之后加载、特异性相同，不加会被盖掉。 */

/* ---- 1. 加购按钮：按下回弹 → 收成圆形转圈 → 变绿画对勾 → 展开恢复 ---------- */
body .product-form__submit,
body .pp-glass-buy .product-form__submit {
  /* 收缩成圆 150ms；拉回原长度 / 恢复的展开仍是 300ms（见 .bz-atc--wide / .bz-atc--expanding） */
  transition:
    width 150ms ease-in-out,
    border-radius 150ms ease-in-out,
    background-color 250ms ease,
    box-shadow 250ms ease;
}

/* 按下缩到 0.95 再回弹（transform 不影响布局，和宽度收缩互不干扰） */
.product-form__submit.bz-atc--press {
  animation: bz-atc-press 380ms cubic-bezier(.3, 1.6, .5, 1);
}
@keyframes bz-atc-press {
  0% { transform: scale(1); }
  35% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

/* 收缩中：圆形、居中；原有内容（图标/文字/价格）淡出，主题自带的转圈藏起来。
   玻璃按钮的圆角是 `.pp-glass-buy .product-form__submit { border-radius: … !important }`
   且在本文件之后加载，所以这里要多带 body 前缀才盖得过，否则收出来是圆角方块 */
body .product-form__submit.bz-atc--busy {
  min-width: 0 !important;
  margin-inline: auto !important;
  padding-inline: 0 !important;
  border-radius: calc(var(--bz-atc-h, 48px) / 2) !important;
  overflow: hidden;
  pointer-events: none;
}
.product-form__submit > *:not(.bz-atc-spinner):not(.bz-atc-check) {
  transition: opacity 150ms ease;
}
.product-form__submit.bz-atc--busy > *:not(.bz-atc-spinner):not(.bz-atc-check) {
  opacity: 0 !important;
}
/* 玻璃按钮外圈的柔光跟着变形；变绿时柔光也换成绿色 ——
   它在按钮自己的层叠上下文里（isolation:isolate + z-index:-1），会压在底色上，
   保留原来的粉蓝渐变会把绿色染成灰绿 */
body .product-form__submit.bz-atc--busy::after { border-radius: inherit !important; }
body .product-form__submit.bz-atc--done::after {
  background: #22a06b !important;
  opacity: 0.35 !important;
}
.product-form__submit.bz-atc--busy .loading-overlay__spinner,
.product-form__submit.bz-atc--busy loading-overlay-spinner {
  display: none !important;
}

.bz-atc-spinner,
.bz-atc-check {
  position: absolute;
  top: 50%;
  left: 50%;
  opacity: 0;
  pointer-events: none;
}
.bz-atc-spinner {
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border: 2.5px solid rgba(255, 255, 255, 0.32);
  border-top-color: #fff;
  border-radius: 50%;
  transition: opacity 200ms ease 150ms;
  animation: bz-atc-spin 0.8s linear infinite;
}
@keyframes bz-atc-spin { to { transform: rotate(360deg); } }
.product-form__submit.bz-atc--busy:not(.bz-atc--done) .bz-atc-spinner { opacity: 1; }

body .product-form__submit.bz-atc--wide,
body .product-form__submit.bz-atc--expanding,
body .pp-glass-buy .product-form__submit.bz-atc--wide,
body .pp-glass-buy .product-form__submit.bz-atc--expanding {
  transition-duration: 300ms, 300ms, 250ms, 250ms;
}

/* 对勾画完后绿色按钮拉回原长度：圆角回到按钮原本的圆角，内容仍隐藏、对勾居中 */
body .product-form__submit.bz-atc--busy.bz-atc--wide {
  border-radius: var(--buy-glass-radius, 14px) !important;
}

/* 成功：变绿 + 对勾一笔画出 */
/* 玻璃按钮的底色是 `.pp-glass-buy .product-form__submit { background: … !important }`，
   要多一层特异性才盖得过 */
body .pp-glass-buy .product-form__submit.bz-atc--done,
body .product-form__submit.bz-atc--done {
  background: #22a06b !important;
  border-color: #22a06b !important;
  box-shadow: 0 10px 24px rgba(34, 160, 107, 0.32) !important;
}
.bz-atc-check {
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
}
.bz-atc-check path {
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
}
.product-form__submit.bz-atc--done .bz-atc-check { opacity: 1; }
.product-form__submit.bz-atc--done .bz-atc-check path {
  animation: bz-atc-draw 380ms ease-out 80ms forwards;
}
@keyframes bz-atc-draw { to { stroke-dashoffset: 0; } }

/* ---- 2. 飞向购物车的圆形缩略图 ---------------------------------------------- */
.bz-fly {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2147483000;
  border-radius: 50%;
  background: #fff center / cover no-repeat;
  border: 2px solid #fff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  pointer-events: none;
  will-change: transform, opacity;
}

/* ---- 3. 购物车：白色悬浮气泡 + 黑色半透明阴影 + 红色角标 ------------------------ */
#cart-icon-bubble,
#cart-icon-bubble-wrapper {
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16), 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#cart-icon-bubble:hover,
#cart-icon-bubble-wrapper:hover {
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2), 0 1px 3px rgba(0, 0, 0, 0.08);
}
/* 桌面端 / 移动端都收成正圆（导航里原本是 35×42 的点击区） */
.header.bz-floating .component-menu-header_title-block_right #cart-icon-bubble {
  width: 40px !important;
  height: 40px !important;
}
.header.bz-floating .header-mobile__cart-button,
.header.bz-floating #cart-icon-bubble-wrapper {
  width: 38px !important;
  height: 38px !important;
}
/* 数量改由红色角标显示，主题自带的小数字隐藏 */
#cart-icon-bubble .header-mobile__cart-count,
#cart-icon-bubble-wrapper .header-mobile__cart-count {
  display: none !important;
}

.bz-cart-host {
  position: relative;
  display: inline-flex;
  align-items: center;
  overflow: visible;
}
.bz-cart-badge {
  position: absolute;
  top: -5px;
  right: -6px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #e5484d;
  color: #fff;
  font-family: 'Manrope', var(--body-font), sans-serif;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  overflow: hidden;
  pointer-events: none;
  transform: scale(1);
  transition: transform 0.25s cubic-bezier(.3, 1.6, .5, 1), opacity 0.2s ease;
}
.bz-cart-badge.is-empty { transform: scale(0); opacity: 0; }
.bz-cart-badge.is-pop { animation: bz-badge-pop 520ms cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bz-badge-pop {
  0% { transform: scale(0.4); }
  55% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
.bz-cart-badge__num { display: block; }
/* 数字向上滚动：旧数字上滑消失，新数字从下方滑入 */
.bz-cart-badge__num.is-leaving {
  position: absolute;
  animation: bz-num-out 380ms ease forwards;
}
.bz-cart-badge__num.is-entering { animation: bz-num-in 380ms ease; }
@keyframes bz-num-out { to { transform: translateY(-110%); opacity: 0; } }
@keyframes bz-num-in { from { transform: translateY(110%); opacity: 0; } }

/* 「+N」从角标处向上飘起 */
.bz-cart-plus {
  position: absolute;
  left: 50%;
  top: -2px;
  color: #e5484d;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  animation: bz-plus-up 850ms ease-out forwards;
}
.bz-cart-badge:has(.bz-cart-plus) { overflow: visible; }
@keyframes bz-plus-up {
  0% { transform: translate(-50%, 0); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(-50%, -22px); opacity: 0; }
}

/* 落进购物车时左右晃一下 */
.bz-cart-shake { animation: bz-cart-shake 560ms ease; }
@keyframes bz-cart-shake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-14deg) scale(1.08); }
  40% { transform: rotate(11deg) scale(1.08); }
  60% { transform: rotate(-6deg); }
  80% { transform: rotate(3deg); }
}

/* 移动端页头滚出视口后，单独悬浮在右上角的购物车气泡（挂在 body 上，由 bz-cart-fx.js 生成） */
.bz-cart-float {
  position: fixed;
  top: 12px;
  right: 14px;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22), 0 1px 3px rgba(0, 0, 0, 0.1);
}
.bz-cart-float__icon {
  width: 22px;
  height: 22px;
  background: var(--bz-icon-bag-global) center / contain no-repeat;
}
.bz-cart-float .bz-cart-badge { top: -4px; right: -5px; }
@media (max-width: 959px) {
  .bz-cart-float.is-on {
    display: flex;
    animation: bz-cart-float-in 320ms cubic-bezier(.22, 1, .36, 1);
  }
}
@keyframes bz-cart-float-in {
  from { transform: translateY(-16px) scale(0.85); opacity: 0; }
}

/* ---- 4. 购物车抽屉：从右往左丝滑拉开到半屏 ------------------------------------ */
body .cart-drawer {
  background-color: transparent;
  transition: visibility 0ms linear 700ms, background-color 500ms ease;
}
body .cart-drawer.active {
  background-color: rgba(var(--color-mask), 0.35);
  transition: visibility 0ms linear 0ms, background-color 500ms ease;
}
body .cart-drawer__inner,
body .cart-drawer__fixed-checkout {
  transition: transform 700ms cubic-bezier(.22, 1, .36, 1);
}
body .cart-drawer-container {
  width: 50vw;
  min-width: 460px;
}
@media (max-width: 959px) {
  body .cart-drawer-container {
    width: 88vw;
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .product-form__submit,
  .cart-drawer__inner,
  .cart-drawer__fixed-checkout { transition-duration: 1ms; }
  .bz-cart-badge.is-pop,
  .bz-cart-shake { animation: none; }
}
