/* ---------------------------------------------------------------------------
 * cart-drawer.css —— 购物车抽屉（2026-11-24）。
 * 尺寸/动画/移动端全屏与 history-drawer 同一套契约。
 * 内容 = `/cart?fragment=1` 的 <section> 主体，这里只做"塞进抽屉"的适配。
 * --------------------------------------------------------------------------- */

.ps-cart-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1060;
  background: rgba(16, 22, 40, .45);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
}
.ps-cart-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.ps-cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1061;
  display: flex;
  flex-direction: column;
  width: min(460px, 100vw);
  background: #fff;
  box-shadow: -8px 0 30px rgba(16, 22, 40, .18);
  transform: translateX(102%);
  visibility: hidden;
  transition: transform .28s cubic-bezier(.4, 0, .2, 1), visibility .28s;
}
.ps-cart-drawer.is-open {
  transform: none;
  visibility: visible;
}

body.ps-cart-lock {
  overflow: hidden;
}

.ps-cart-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem 1rem;   /* 表头更矮（2026-11-24 用户） */
  border-bottom: 1px solid var(--border, #e5e7f0);
  background: #fff;
}
.ps-cart-head-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: .75rem;
  background: rgba(20, 32, 74, .07);
  color: var(--navy, #14204a);
  font-size: 1.1rem;
}
.ps-cart-head-txt {
  flex: 1 1 auto;
  min-width: 0;
}
.ps-cart-kicker {
  display: block;
  font-size: .68rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted, #6b7280);
}
.ps-cart-title {
  margin: 0;
  font-size: 1.05rem;
  color: var(--navy, #14204a);
}
.ps-cart-close {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: .6rem;
  background: transparent;
  color: var(--muted, #6b7280);
  font-size: 1rem;
  cursor: pointer;
}
.ps-cart-close:hover {
  background: rgba(16, 22, 40, .06);
  color: var(--navy, #14204a);
}

.ps-cart-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: .5rem;
}

.ps-cart-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: 2rem 0;
  color: var(--muted, #6b7280);
  font-size: .85rem;
}

/*
 * 抽屉里的 cart 主体适配：
 *   · 去掉页级留白 / 容器最大宽度，让它吃满抽屉宽度；
 *   · 抽屉窄（<768 触发 Cart 的移动端布局），右栏 summary 自然堆到下面。
 */
.ps-cart-body .section {
  padding-top: .6rem !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}
/*
 * 让 list 尽量**吃满抽屉宽度**（2026-11-24 用户：条目没占满抽屉）。
 * cart 整页有几层横向留白，在 460px 的抽屉里会显得很窄：
 *   · `.container` 的 max-width / 左右 padding；
 *   · `.row` 的负 gutter（列两侧 padding）；
 *   · 变体 `.cart-line` 的 `margin-left`（整页的层级缩进）。
 * 抽屉里全部压掉，条目贴边到只剩一点点内边距。
 */
.ps-cart-body .container {
  max-width: none !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}
/* 组卡片直接贴抽屉左右边（整页的圆角/左右边框在窄抽屉里就是两边白边） */
.ps-cart-body .cart-group {
  border-radius: 0 !important;
  border-left: 0 !important;
  border-right: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  margin-bottom: .5rem !important;   /* 组与组之间更紧（原 mb-3=1rem） */
}
.ps-cart-body .row {
  --bs-gutter-x: 0 !important;
  --bs-gutter-y: .5rem !important;   /* 行间距更紧 */
}
.ps-cart-body .row > [class^="col-"],
.ps-cart-body .row > [class*=" col-"] {
  padding-left: 0 !important;
  padding-right: 0 !important;
}
/*
 * ⚠️ **PC 端 list 只占 2/3 的根因**：list 列是 `col-12 col-lg-8` —— 媒体查询看的是
 * **视口**宽度，不是抽屉宽度。桌面视口 ≥992 时 `col-lg-8` 生效 = 8/12 宽，抽屉里
 * 右侧就空一块；手机视口 <992 才退化成满宽（所以"手机行、PC 不行"）。
 * 抽屉内把 list 列强制 100%，不受视口断点影响。
 */
.ps-cart-body .row > .col-lg-8 {
  flex: 0 0 100% !important;
  max-width: 100% !important;
}
.ps-cart-body .cart-line {
  margin-left: 0 !important;
}
/* 抽屉里**不要**结账三步流程条（1.Cart / 2.Address / 3.Payment）—— 只占高度又多余 */
.ps-cart-body .ui-steps { display: none !important; }

/*
 * ⚠️ **抽屉宽度固定 ~460px，但媒体查询看的是视口**：PC 视口 ≥992 时 cart 用
 *    「桌面展平」布局（`.line-id`/`.line-actions` display:contents，排成一长行），
 *    塞不进 460px 就换行 → 步进器被挤、整行显得很高。
 *    这里把手机（site-mobile.css ≤991.98）那套**两行布局**强制应用到抽屉内，
 *    无视视口宽度。
 */
.ps-cart-body .cart-line-head {
  flex-wrap: wrap !important;
  gap: .25rem .4rem !important;
  align-items: center !important;
}
.ps-cart-body .cart-line-head > .line-id,
.ps-cart-body .cart-line-head > .line-actions {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: .25rem .4rem;
  flex: 1 1 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
  scrollbar-width: none;
}
.ps-cart-body .cart-line-head .line-meta {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: .2rem .3rem;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
.ps-cart-body .cart-line-head > .line-id::-webkit-scrollbar,
.ps-cart-body .cart-line-head .line-meta::-webkit-scrollbar { display: none; }
.ps-cart-body .cart-line-head .line-meta > * { flex: 0 0 auto; }

/* 步进器位置/尺寸（与结账页一致：第二行右侧，单价跟在后面），并压矮一点 */
.ps-cart-body .cart-line-head .cart-qty-form { order: 11; margin-left: auto; flex: 0 0 auto; }
.ps-cart-body .cart-line-head .qty-stepper { gap: .08rem; }
.ps-cart-body .cart-line-head .qty-stepper .cart-qty {
  width: 34px !important;
  min-height: 28px;
  padding: .05rem .1rem;
  font-size: .8rem;
  text-align: center;
}
.ps-cart-body .cart-line-head .qty-stepper .qty-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;   /* − / + 符号居中 */
  width: 26px;
  height: 28px;
  padding: 0;
  line-height: 1;
}
/*
 * 删除表单默认 order:0，会排到 `order:11` 的步进器**前面**（用户报"input 和 −/+
 * 跑到 delete 后面"）。把删除最后（13），顺序 = 颜色尺码 → 步进器(11) → 单价(12) → 删除(13)。
 */
.ps-cart-body .cart-line-head .cart-del { order: 13; }

/* 抽屉内整体行高再紧凑一点（2026-11-24 用户：height 想更紧凑） */
.ps-cart-body .cart-group .group-head {
  padding-top: .3rem !important;
  padding-bottom: .3rem !important;
}
.ps-cart-body .cart-line-head {
  padding-top: .2rem !important;
  padding-bottom: .2rem !important;
}
.ps-cart-body .qty-stepper .qty-step {
  width: 24px;
  height: 24px;
}
.ps-cart-body .qty-stepper .cart-qty {
  min-height: 24px;
}
/* 行内不再重复显示"单价标签/行小计/勾选 label"（手机同款取舍） */
.ps-cart-body .cart-line-head label { display: none !important; }
.ps-cart-body .cart-line-head .line-unit { order: 12; }
.ps-cart-body .cart-line-head .line-unit-lbl { display: none !important; }
.ps-cart-body .cart-line-head .line-sub,
.ps-cart-body .cart-line-head .entry-sub { display: none !important; }
.ps-cart-body .cart-line-head .flex-grow-1 { display: none !important; }

/* 抽屉底部固定条：Checkout 主按钮 + View full cart 次链接（不随 list 滚动）。
   `.flex:0 0 auto` + 抽屉本身是 flex 列 → 这条永远贴在抽屉底部。 */
.ps-cart-foot {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: .45rem;
  padding: .7rem 1.1rem;
  border-top: 1px solid var(--border, #e5e7f0);
  background: #fff;
}
/* 标题行：Cart + 紧跟的 View full cart（2026-11-24 用户：放标题后、跟近一点） */
.ps-cart-title-row {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  flex-wrap: wrap;
}
.ps-cart-viewall {
  flex: 0 0 auto;
  font-size: .78rem;
  white-space: nowrap;
  text-decoration: none;
  color: var(--muted, #6b7280);
}
.ps-cart-viewall:hover {
  color: var(--navy, #14204a);
}

@media (max-width: 767.98px) {
  .ps-cart-drawer {
    width: 100vw;
  }
  .ps-cart-head {
    padding-top: calc(.95rem + env(safe-area-inset-top, 0px));
  }
  .ps-cart-foot {
    padding-bottom: calc(.75rem + env(safe-area-inset-bottom, 0px));
  }
}
