/* ============================================================
   蜗牛严选 · 商城前台视觉系统（新中式 / 全主题兼容）

   设计 token 来源：
     - 颜色：app.css 的 :root (--green / --cream / --gold / --ink / ...)
       theme.js 切主题时把这些变量改写成 5 套之一，本样式自动跟随。
     - 字体：app.css 的 :root --serif（"Noto Serif SC", Songti SC, ...serif）
       标题类元素统一走 var(--serif)，sans 系列走 var(--sans)。

   作用范围：所有 .mall-page 选择器限定，互不污染其他页面。
   ============================================================ */

/* ---------- 页面容器 ---------- */
.mall-page {
  background: var(--cream);
  min-height: 100%;
  /* 安全区：底部固定 tabbar(56px) + iOS home indicator + 空气感 */
  padding-bottom: calc(64px + env(safe-area-inset-bottom) + 12px);
  font-family: var(--sans);
  color: var(--ink);
}

/* ---------- Hero 横幅 ---------- */
.mall-hero {
  position: relative;
  overflow: hidden;
  padding: 38px 22px 30px;
  background:
    radial-gradient(120% 80% at 88% -10%, rgba(255, 255, 255, .12), transparent 58%),
    linear-gradient(158deg, var(--green-deep) 0%, var(--green-soft) 100%);
  color: #fff;
  isolation: isolate;
}
.mall-hero::after {
  content: "";
  position: absolute;
  left: 22px; right: 22px; bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-light), transparent);
  opacity: .55;
}
.mh-seal {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif);
  font-size: 22px; font-weight: 700;
  color: var(--gold-light);
  border: 1.5px solid var(--gold);
  background: rgba(255, 255, 255, .06);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .06);
  margin-bottom: 16px;
}
.mh-title {
  font-family: var(--serif);
  font-size: 30px; font-weight: 700;
  letter-spacing: 4px; line-height: 1.15;
  margin: 0;
}
.mh-sub {
  margin-top: 8px;
  font-size: 13px; letter-spacing: 1.5px;
  color: rgba(255, 255, 255, .82);
}
.mh-meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px;
  margin-top: 16px;
  font-size: 12px; color: rgba(255, 255, 255, .88);
}
.mh-badge {
  letter-spacing: 1px;
  font-feature-settings: "tnum" 1;
}
.mh-tone-gold { color: var(--gold-light); }
.mh-tone-mute { color: rgba(255, 255, 255, .55); }
.mh-dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--gold); display: inline-block; opacity: .8;
}
.mh-deco {
  position: absolute; right: -34px; top: -34px;
  width: 128px; height: 128px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .14);
  pointer-events: none;
}
.mh-deco::before {
  content: ""; position: absolute; inset: 20px;
  border-radius: 50%; border: 1px solid rgba(255, 255, 255, .08);
}

/* ---------- 分区标题（甄选好物） ----------
   关键：放在分类之上、网格之上；高度足够大；衬线字体；任何主题下都清晰 */
.mall-sec {
  position: relative;
  z-index: 3;            /* 永远压在网格之上，挡住任何意外重叠 */
  display: flex; align-items: center; justify-content: center;
  gap: 14px;
  padding: 26px 22px 14px;
  background: var(--cream);   /* 不让 hero 的渐变渗出来 */
}
.mall-sec .ms-line {
  flex: 0 0 36px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold));
}
.mall-sec .ms-line:last-child {
  background: linear-gradient(90deg, var(--gold), transparent);
}
.mall-sec .ms-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px; font-weight: 700;
  letter-spacing: 5px;
  color: var(--green-deep);
}
.mall-sec .ms-title .ms-c {
  display: inline-block;
  position: relative;
}
.mall-sec .ms-title .ms-c::before,
.mall-sec .ms-title .ms-c::after {
  content: "";
  display: inline-block;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--gold);
  vertical-align: middle;
  margin: 0 6px;
  position: relative;
  top: -2px;
}

/* ---------- 分类筛选 ---------- */
.mall-cats {
  position: relative;
  z-index: 2;
  display: flex; gap: 8px;
  overflow-x: auto;
  padding: 4px 18px 14px;
  background: var(--cream);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.mall-cats::-webkit-scrollbar { display: none; }
.mc {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12.5px; font-weight: 500;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  transition: transform .18s ease, background .2s ease, color .2s ease, box-shadow .2s ease, border-color .2s ease;
  white-space: nowrap;
}
.mc.on {
  color: #fff;
  background: linear-gradient(135deg, var(--green), var(--green-deep));
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .12);
  font-weight: 600;
}
.mc:active { transform: scale(.95); }

/* ---------- 商品网格（始终在标题/分类之下） ----------
   ⚠️ 显式重置 app.css 里残留的旧 .mall-grid 规则：
     - margin-top: -26px（旧 mall-head 设计让网格上提叠在头部）
     - z-index: 2（旧值会压到分类栏上）
     - padding: 0 14px（旧值让首行卡顶与分类栏紧贴）
   这些残留规则会导致第一行卡片顶部被分类栏的 cream 背景覆盖（边框/圆角被截断）。 */
.mall-page .mall-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 0;                    /* 覆盖 app.css 旧 .mall-grid{margin-top:-26px} */
  padding: 14px 18px 8px;        /* 覆盖 app.css 旧 .mall-grid{padding:0 14px} */
  transition: opacity .2s ease;
}
.mall-card {
  position: relative;
  background: var(--card);
  border-radius: var(--r-card);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .04);
  cursor: pointer;
  display: flex; flex-direction: column;
  transition: transform .25s ease, box-shadow .25s ease;
  animation: mallIn .5s both;
}
.mall-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 26px rgba(0, 0, 0, .10);
}
.mall-card:active { transform: translateY(-1px); }
.mc-pic {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--cream-2);
  overflow: hidden;
}
.mc-emoji {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 54px;
}
.mc-pic img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  transition: transform .4s ease;
}
.mall-card:hover .mc-pic img { transform: scale(1.05); }
.mc-badge {
  position: absolute; top: 10px; left: 10px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .5px;
  color: #fff;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
}
.mc-body {
  padding: 10px 12px 12px;
  display: flex; flex-direction: column; gap: 4px;
  flex: 1;
}
.mc-name {
  font-family: var(--serif);     /* 商品名也走衬线，呼应品牌 */
  font-size: 14px; font-weight: 600; color: var(--ink);
  line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
  overflow: hidden;
}
.mc-desc {
  font-size: 11.5px; color: var(--muted); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 32px;
}
.mc-foot {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-top: auto; gap: 6px; flex-wrap: wrap;
}
.mc-price {
  display: flex; align-items: baseline; gap: 2px;
  color: var(--green-deep);
  font-family: var(--serif);
}
.mc-price .cur { font-size: 12px; font-weight: 600; }
.mc-price .num { font-size: 20px; font-weight: 700; line-height: 1; }
.mc-price .ori {
  font-size: 11px; color: var(--muted);
  text-decoration: line-through;
  margin-left: 4px; font-family: var(--sans);
}
.mc-sold { font-size: 10px; color: var(--muted); white-space: nowrap; }

@keyframes mallIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- 空态 ---------- */
.mall-empty {
  text-align: center; padding: 60px 30px; color: var(--muted);
}
.mall-empty .e-icon { font-size: 40px; margin-bottom: 12px; }
.mall-empty .e-t { font-size: 14px; color: var(--ink); }

/* ---------- 详情弹层协调（仅 mall 上下文） ---------- */
body.mall-context .sheet { border-radius: 20px 20px 0 0; }
body.mall-context .sheet .price { color: var(--green-deep); font-family: var(--serif); }

/* ---------- 响应式 ---------- */
@media (max-width: 360px) {
  .mall-grid { gap: 10px; padding: 12px 14px; }
  .mall-cats { padding: 4px 14px 12px; }
  .mall-sec { padding: 22px 18px 12px; }
  .mh-title { font-size: 26px; }
  .mall-hero { padding: 32px 18px 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .mall-card { animation: none; }
  .mall-card:hover { transform: none; }
  .mc-pic img { transition: none; }
}

/* ---------- 前台首页「精选推荐」置顶专区 ---------- */
.mall-top { background: var(--cream); }
.mall-top .mt-head {
  display: flex; align-items: center; justify-content: center;
  gap: 14px; padding: 22px 22px 12px;
}
.mall-top .ms-line {
  flex: 0 0 36px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold));
}
.mall-top .ms-line:last-child {
  background: linear-gradient(90deg, var(--gold), transparent);
}
.mall-top .ms-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px; font-weight: 700; letter-spacing: 5px;
  color: var(--green-deep);
}
.mall-top .ms-title .ms-c {
  display: inline-block; position: relative;
}
.mall-top .ms-title .ms-c::before,
.mall-top .ms-title .ms-c::after {
  content: ""; display: inline-block;
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--gold); vertical-align: middle;
  margin: 0 6px; position: relative; top: -2px;
}
.mall-top-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 12px; padding: 4px 18px 6px;
  transition: opacity .2s ease;
}
.mall-top .mall-empty { padding: 30px 30px; }

/* ---------- 库存状态徽标（卡片 + 详情）---------- */
.mc-stock {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
}
.mc-stock-unlimited { color: var(--green-deep); background: rgba(31, 95, 175, .10); }
.mc-stock-ok { color: #2f7d4f; background: rgba(47, 125, 79, .12); }
.mc-stock-warn { color: #b9740a; background: rgba(224, 142, 11, .14); }
.mc-stock-out { color: #c0392b; background: rgba(192, 57, 43, .12); }

/* 详情弹层内的库存行 */
.g-stock { font-weight: 600; }
.g-stock.st-unlimited { color: var(--green-deep); }
.g-stock.st-ok { color: #2f7d4f; }
.g-stock.st-warn { color: #b9740a; }
.g-stock.st-out { color: #c0392b; }

/* ===== 商品详情页（独立路由 #/mall-detail/:pid）===== */
.pdp { padding-bottom: 72px; }
.pdp-hero { position: relative; width: 100%; aspect-ratio: 1 / 1; max-height: 420px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: var(--cream-2); }
.pdp-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pdp-emoji { font-size: 96px; }
.pdp-info { padding: 16px 18px 10px; background: var(--card); }
.pdp-name { font-family: var(--serif); font-size: 20px; font-weight: 700; color: var(--ink); line-height: 1.35; margin: 0; }
.pdp-price { display: flex; align-items: baseline; gap: 3px; margin-top: 10px; }
.pdp-price .cur { font-size: 14px; font-weight: 600; color: var(--green-deep); }
.pdp-price .num { font-family: var(--serif); font-size: 28px; font-weight: 800; color: var(--green-deep); line-height: 1; }
.pdp-price .ori { font-size: 14px; color: var(--muted); text-decoration: line-through; margin-left: 6px; font-family: var(--sans); }
.pdp-info .g-stock { display: inline-block; margin-top: 8px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pdp-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pdp-tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; color: var(--gold); background: rgba(212, 175, 55, .12); }
.pdp-sold { font-size: 12px; color: var(--muted); margin-left: auto; }
.pdp-desc { margin-top: 10px; padding: 16px 18px; background: var(--card); }
.pdp-desc-title { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 8px; letter-spacing: 1px; }
.pdp-desc-body { font-size: 14px; color: var(--ink); line-height: 1.7; }
.pdp-desc-body img { max-width: 100%; border-radius: 8px; margin: 6px 0; }
.pdp-desc-body p { margin: 6px 0; }
.pdp-bar { position: fixed; bottom: 0; left: 0; right: 0; max-width: 430px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -2px 12px rgba(0,0,0,.06); z-index: 50; }
.pdp-qty { display: inline-flex; align-items: center; gap: 10px; }
.pdp-qty button { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--green); color: var(--green); font-size: 16px; background: #fff; display: flex; align-items: center; justify-content: center; }
.pdp-qty .n { font-weight: 700; min-width: 20px; text-align: center; font-size: 16px; }
.pdp-bar .btn-lite { flex: 0 0 auto; padding: 10px 14px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pdp-bar .btn-primary { flex: 1; padding: 11px 0; font-size: 14px; white-space: nowrap; }
.pdp-buy { flex: 1; }
@media (max-width: 370px) {
    .pdp-name { font-size: 18px; }
    .pdp-price .num { font-size: 24px; }
    .pdp-bar { gap: 6px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); }
    .pdp-bar .btn-lite { padding: 10px 10px; font-size: 12px; }
    .pdp-bar .btn-primary { font-size: 13px; }
}
