/* ============================================================
 *  购物车样式 · 含顶栏触发器、Drawer 抽屉、Toast
 * ============================================================ */

/* ---------- Toast ---------- */
#ess-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translate(-50%, -16px);
  z-index: 999999;
  background: #2F5A45;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  box-shadow: 0 8px 24px rgba(47, 90, 69, 0.3);
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
}
#ess-toast.show { opacity: 1; transform: translate(-50%, 0); }
#ess-toast .t-ico {
  display: inline-flex;
  width: 22px;
  height: 22px;
  background: #fff;
  color: #2F5A45;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ---------- 顶栏触发器（购物车图标 + 角标） ---------- */
.cart-trigger {
  position: relative;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: #2F5A45;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  margin-left: auto;
  transition: background .2s;
}
.cart-trigger:hover { background: rgba(47, 90, 69, .08); }
.cart-trigger svg { display: block; }
.cart-trigger .cart-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  background: #B8483E;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  font-family: 'Inter', -apple-system, sans-serif;
  border-radius: 999px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
  border: 2px solid #F8F4ED;
  animation: cart-pop .35s cubic-bezier(.34, 1.56, .64, 1);
}
.cart-trigger .cart-badge.show { display: inline-flex; }

@keyframes cart-pop {
  0% { transform: scale(0); }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* 调整 .nav 元素使其让触发器自然位于右侧 */
header .nav {
  margin-right: 8px;
}

/* ---------- Drawer ---------- */
.cart-drawer {
  position: fixed;
  inset: 0;
  z-index: 9990;
  pointer-events: none;
}
.cart-drawer .cart-mask {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.4);
  opacity: 0;
  transition: opacity .25s;
}
.cart-drawer .cart-panel {
  position: absolute; right: 0; top: 0;
  width: 420px;
  max-width: 92vw;
  height: 100vh;
  background: #FBF8F1;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .32s cubic-bezier(.4, 0, .2, 1);
  box-shadow: -8px 0 32px rgba(0,0,0,.16);
  pointer-events: auto;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body.cart-open .cart-drawer { pointer-events: auto; }
body.cart-open .cart-drawer .cart-mask { opacity: 1; }
body.cart-open .cart-drawer .cart-panel { transform: translateX(0); }

/* Drawer 头 */
.cart-drawer .cart-head {
  padding: 20px 22px 16px;
  border-bottom: 1px solid rgba(0,0,0,.06);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: #FBF8F1;
}
.cart-drawer .cart-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #B8483E;
  margin-bottom: 4px;
}
.cart-drawer .cart-head h3 {
  margin: 0;
  font-size: 20px;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  color: #2F5A45;
}
.cart-drawer .cart-close {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 28px;
  color: #2F5A45;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background .2s;
}
.cart-drawer .cart-close:hover { background: rgba(0,0,0,.06); }

/* Drawer 列表 */
.cart-drawer .cart-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 22px;
}
.cart-row {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(0,0,0,.06);
}
.cart-row:last-child { border-bottom: 0; }
.cart-thumb {
  width: 56px; height: 56px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.7);
  font-size: 16px;
  font-weight: 600;
  font-family: 'Cormorant Garamond', serif;
  letter-spacing: .03em;
}
.cart-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.cart-info { flex: 1; min-width: 0; }
.cart-name {
  font-size: 14px;
  font-weight: 600;
  color: #1F2A23;
  margin-bottom: 2px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.cart-sku {
  font-size: 12px;
  color: #8A8773;
  margin-bottom: 8px;
}
.cart-qty-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(0,0,0,.04);
  border-radius: 999px;
  padding: 2px;
}
.cart-qbtn {
  width: 26px; height: 26px;
  border: none;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  color: #2F5A45;
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  transition: background .15s;
}
.cart-qbtn:hover { background: #f3efe4; }
.cart-qty {
  width: 60px;
  text-align: center;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: #1F2A23;
  outline: none;
  font-family: inherit;
}
.cart-rm {
  margin-left: 8px;
  width: 26px; height: 26px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #B8483E;
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background .15s;
}
.cart-rm:hover { background: rgba(184, 72, 62, .1); }

/* 空购物车 */
.cart-empty {
  text-align: center;
  padding: 48px 20px;
  color: #8A8773;
}
.cart-empty p {
  margin: 14px 0 6px;
  font-size: 15px;
  font-weight: 500;
  color: #1F2A23;
}
.cart-empty small {
  font-size: 12.5px;
  line-height: 1.5;
  color: #8A8773;
  display: block;
  max-width: 220px;
  margin: 0 auto;
}

/* Drawer 底部 */
.cart-drawer .cart-foot {
  padding: 16px 22px 20px;
  border-top: 1px solid rgba(0,0,0,.06);
  background: #fff;
}
.cart-foot-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #8A8773;
  margin-bottom: 4px;
}
.cart-foot-row b {
  color: #1F2A23;
  font-weight: 700;
  font-size: 14px;
}
.cart-clear {
  width: 100%;
  margin: 8px 0 10px;
  padding: 8px;
  background: transparent;
  border: 1px dashed rgba(184, 72, 62, .4);
  color: #B8483E;
  border-radius: 8px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
  transition: background .2s;
}
.cart-clear:hover { background: rgba(184, 72, 62, .06); }
.cart-checkout {
  width: 100%;
  padding: 12px 16px;
  background: #2F5A45;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .2s;
}
.cart-checkout:hover { background: #264b39; }
.cart-foot-hint {
  margin-top: 8px;
  font-size: 11.5px;
  color: #8A8773;
  text-align: center;
  line-height: 1.4;
}

/* 防止页面 body 滚动 */
body.cart-open { overflow: hidden; }

/* ---------- "加入购物车"按钮（在产品详情/目录页用） ---------- */
.btn-add-cart {
  background: transparent;
  color: #2F5A45;
  border: 1.5px solid #2F5A45;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background .2s, color .2s, transform .15s;
}
.btn-add-cart:hover { background: #2F5A45; color: #fff; }
.btn-add-cart:active { transform: scale(.97); }
.btn-add-cart.is-added {
  background: #2F5A45;
  color: #fff;
}
.btn-add-cart .ico-cart { display: inline-block; }

@media (max-width: 720px) {
  .cart-trigger { width: 38px; height: 38px; }
}
