/* ============================================================================
   w4.css — MEG TradesPortal 软装选购（#/decor）组件（P5 · W4 · 2026-09-09）
   ----------------------------------------------------------------------------
   仅被 assets/js/w4-ui.js 消费；全部引用 tokens.css 变量（--meg-* / ui-kit）。
   不覆盖 styles.css / ui-kit.css 既有类；克制专业、无装饰渐变。
   ========================================================================== */

/* ---- 布局：主网格 + 右侧购物车 ---- */
.w4-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-20);
  margin-top: var(--space-16);
  align-items: start;
}
@media (min-width: 980px) {
  .w4-layout { grid-template-columns: minmax(0, 1fr) 360px; }
}

/* ---- 分类 tab ---- */
.w4-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-8);
  margin-top: var(--space-14);
}
.w4-tab {
  appearance: none;
  border: var(--border-w) solid var(--meg-line);
  border-radius: var(--radius-pill);
  background: var(--meg-paper-2);
  color: var(--meg-ink);
  font-family: inherit;
  font-size: var(--fs-13);
  font-weight: var(--fw-600);
  line-height: 1.2;
  padding: 8px 16px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
}
.w4-tab:hover { background: var(--meg-paper); }
.w4-tab:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-offset); }
.w4-tab.active {
  background: var(--meg-green-600);
  border-color: var(--meg-green-600);
  color: var(--on-green-deep);
}

/* ---- 聚合提示（另有 N 组 · M 款筹备中） ---- */
.w4-queue-note {
  margin-top: var(--space-12);
  font-size: var(--fs-12);
  color: var(--meg-muted);
  border: var(--border-w) dashed var(--meg-line);
  border-radius: var(--radius-sm);
  background: var(--meg-paper);
  padding: var(--space-8) var(--space-12);
}

/* ---- 卡片网格 ---- */
.w4-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: var(--space-14);
}
.w4-card {
  display: flex;
  flex-direction: column;
  background: var(--meg-paper-2);
  border: var(--border-w) solid var(--meg-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.w4-card:hover { border-color: var(--meg-green-300); }
.w4-card.is-muted { background: var(--meg-paper); box-shadow: none; }
.w4-card.is-muted:hover { border-color: var(--meg-line); }

/* ---- 缩略图（图片 / emoji 兜底占位） ---- */
.w4-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--meg-paper);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.w4-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.w4-thumb-ph .w4-thumb-ico { font-size: 34px; line-height: 1; }
.w4-thumb-ico {
  font-size: 34px;
  line-height: 1;
  color: var(--meg-muted);
  display: grid;
  place-items: center;
}

/* ---- 卡片正文 ---- */
.w4-card-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-12) var(--space-12) var(--space-14);
  flex: 1;
}
.w4-card-name {
  font-size: var(--fs-14);
  font-weight: var(--fw-700);
  color: var(--meg-ink);
  line-height: var(--lh-text);
  min-height: 2.9em;
}
.w4-card.is-muted .w4-card-name { color: var(--meg-muted); }
.w4-card-meta { font-size: var(--fs-11); color: var(--meg-muted); }
.w4-card-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-8);
  flex-wrap: wrap;
}
.w4-card-price { font-size: var(--fs-16); font-weight: var(--fw-800); color: var(--meg-green-700); font-variant-numeric: tabular-nums; }
.w4-card.is-muted .w4-card-price { color: var(--meg-muted); }

/* ---- 待定价徽标 ---- */
.w4-badge {
  display: inline-flex;
  align-items: center;
  font-size: var(--fs-11);
  font-weight: var(--fw-700);
  line-height: 1;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  border: var(--border-w) dashed var(--meg-line);
  background: var(--meg-paper);
  color: var(--meg-muted);
  white-space: nowrap;
}

/* ---- 购物车 ---- */
.w4-cart {
  position: sticky;
  top: calc(var(--topbar-h) + var(--space-16));
  border: var(--border-w) solid var(--meg-line);
  border-radius: var(--radius);
  background: var(--meg-paper-2);
  box-shadow: var(--shadow);
  padding: var(--space-16);
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
  font-size: var(--fs-13);
}
.w4-cart-title {
  font-size: var(--fs-15);
  font-weight: var(--fw-800);
  color: var(--meg-ink);
  padding-bottom: var(--space-8);
  border-bottom: var(--border-w-2) solid var(--meg-line);
}
.w4-cart-empty { color: var(--meg-muted); padding: var(--space-8) 0; line-height: var(--lh-text); }
.w4-cart-line {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: var(--space-10);
  align-items: start;
  border-bottom: var(--border-w) solid var(--meg-paper);
  padding: var(--space-8) 0;
}
.w4-cart-thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--meg-paper);
  overflow: hidden;
}
.w4-cart-thumb-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.w4-cart-info { min-width: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.w4-cart-name { font-weight: var(--fw-700); color: var(--meg-ink); line-height: var(--lh-text); word-break: break-word; }
.w4-cart-sub { font-size: var(--fs-11); color: var(--meg-muted); }
.w4-cart-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-8); }
.w4-cart-del {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--meg-muted);
  font-size: var(--fs-13);
  cursor: pointer;
  padding: var(--space-4);
  line-height: 1;
  border-radius: var(--radius-xs);
}
.w4-cart-del:hover { color: var(--meg-red); background: var(--meg-red-soft); }
.w4-cart-del:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-offset); }

/* ---- 数量步进器 ---- */
.w4-qty {
  display: inline-flex;
  align-items: center;
  gap: var(--space-6);
  border: var(--border-w) solid var(--meg-line);
  border-radius: var(--radius-sm);
  padding: 2px;
  background: var(--meg-paper-2);
}
.w4-qty-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--meg-ink);
  width: 22px;
  height: 22px;
  font-size: var(--fs-15);
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-xs);
}
.w4-qty-btn:hover:not(:disabled) { background: var(--ghost-hover); }
.w4-qty-btn:disabled { color: var(--meg-muted); cursor: not-allowed; opacity: .5; }
.w4-qty-btn:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-offset); }
.w4-qty-val { min-width: 20px; text-align: center; font-variant-numeric: tabular-nums; font-weight: var(--fw-700); }
.w4-line-total { font-weight: var(--fw-800); color: var(--meg-green-700); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- 购物车底 ---- */
.w4-cart-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-10);
  border-top: var(--border-w-2) solid var(--meg-line);
  font-weight: var(--fw-700);
}
.w4-cart-total b { color: var(--meg-green-700); font-size: var(--fs-17); }
.w4-cart-actions {
  display: flex;
  gap: var(--space-8);
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.w4-cart-hint { font-size: var(--fs-11); color: var(--meg-muted); line-height: var(--lh-text); }

@media (max-width: 560px) {
  .w4-card-foot { flex-direction: column; align-items: stretch; }
  .w4-card-foot .ui-btn { width: 100%; }
  .w4-cart { position: static; }
}
