/* =========================================================================
 * style.css — 團購商店樣式 (mobile-first)
 * ===================================================================== */
:root {
  --primary: #1f7a6b;       /* 健康綠 */
  --primary-dark: #155c50;
  --accent: #ff5a3c;        /* CTA 橘紅 */
  --accent-dark: #e8482c;
  --ink: #1d2630;
  --muted: #6b7785;
  --line: #e8ecef;
  --bg: #f6f7f8;
  --card: #ffffff;
  --gold: #e8a33d;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(20, 40, 50, 0.08);
  --maxw: 720px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei",
    -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
.section { padding: 28px 0; }
.section-title {
  font-size: 20px; font-weight: 800; margin-bottom: 4px;
  display: flex; align-items: center; gap: 8px;
}
.section-sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; height: 54px; }
.brand { font-weight: 900; font-size: 17px; letter-spacing: .5px; }
.brand span { color: var(--primary); }
.lang { font-size: 12px; color: var(--muted); border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 999px; }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(160deg, #eafaf4 0%, #f6f7f8 70%);
  text-align: center; padding: 30px 0 24px;
}
.hero .pill {
  display: inline-block; background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 700; padding: 6px 14px; border-radius: 999px;
  margin-bottom: 14px; box-shadow: 0 4px 12px rgba(255,90,60,.35);
}
.hero h1 { font-size: 27px; font-weight: 900; line-height: 1.3; }
.hero h1 em { color: var(--primary); font-style: normal; }
.hero p.lead { color: var(--muted); margin-top: 10px; font-size: 15px; }

/* countdown */
.countdown { display: flex; gap: 8px; justify-content: center; margin-top: 18px; }
.cd-box {
  background: var(--ink); color: #fff; border-radius: 10px;
  min-width: 56px; padding: 8px 4px;
}
.cd-box b { display: block; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.cd-box small { font-size: 11px; opacity: .7; }
.cd-label { font-size: 13px; color: var(--accent); font-weight: 700; margin-top: 14px; }

/* ---------- Benefit strip ---------- */
.benefits { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.benefit {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); display: flex; gap: 10px; align-items: flex-start;
}
.benefit .ico { font-size: 22px; }
.benefit b { display: block; font-size: 14px; }
.benefit small { color: var(--muted); font-size: 12px; }

/* gift progress */
.gift-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-top: 12px; }
.progress { height: 10px; background: #eef1f3; border-radius: 999px; overflow: hidden; margin: 10px 0; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #34b39c);
  width: 0; transition: width .4s ease; }
.gift-tiers { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.gift-tiers span.hit { color: var(--primary); font-weight: 800; }

/* ---------- Product gallery ---------- */
.gallery .main-img {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; aspect-ratio: 1/1; display: flex; align-items: center; justify-content: center;
}
.gallery .main-img img { width: 100%; height: 100%; object-fit: cover; }
.thumbs { display: flex; gap: 8px; margin-top: 10px; }
.thumbs img { width: 60px; height: 60px; border-radius: 10px; object-fit: cover;
  border: 2px solid transparent; cursor: pointer; background: #fff; }
.thumbs img.active { border-color: var(--primary); }

.prod-head h2 { font-size: 21px; font-weight: 800; }
.prod-head .tagline { color: var(--muted); font-size: 14px; margin: 4px 0 8px; }
.stars { color: var(--gold); font-size: 14px; }
.stars small { color: var(--muted); margin-left: 6px; }

.price-row { display: flex; align-items: baseline; gap: 10px; margin: 12px 0; }
.price-now { font-size: 28px; font-weight: 900; color: var(--accent); }
.price-list { color: var(--muted); text-decoration: line-through; font-size: 15px; }
.price-off { background: #ffe9e3; color: var(--accent-dark); font-size: 12px;
  font-weight: 800; padding: 3px 8px; border-radius: 6px; }

.highlights { list-style: none; margin: 10px 0; }
.highlights li { font-size: 14px; padding: 4px 0 4px 24px; position: relative; }
.highlights li::before { content: "✓"; position: absolute; left: 0; color: var(--primary); font-weight: 900; }

/* ---------- Tier selector ---------- */
.tiers { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 10px 0 4px; }
.tier {
  border: 2px solid var(--line); border-radius: 12px; padding: 12px; text-align: center;
  background: #fff; cursor: pointer; transition: .15s; position: relative;
}
.tier.active { border-color: var(--accent); background: #fff7f5; }
.tier .t-label { font-weight: 800; font-size: 14px; }
.tier .t-unit { color: var(--accent); font-weight: 900; font-size: 18px; margin-top: 2px; }
.tier .t-each { font-size: 11px; color: var(--muted); }
.tier .t-tag { position: absolute; top: -9px; right: 8px; background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }

/* options */
.opt { margin: 14px 0; }
.opt > label { font-size: 13px; font-weight: 700; display: block; margin-bottom: 7px; }
.opt-values { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px;
  padding: 8px 14px; font-size: 13px; cursor: pointer; transition: .15s;
}
.chip.active { border-color: var(--primary); background: var(--primary); color: #fff; }

/* qty */
.qty { display: inline-flex; align-items: center; border: 1.5px solid var(--line);
  border-radius: 10px; overflow: hidden; }
.qty button { width: 38px; height: 38px; font-size: 18px; background: #fff; color: var(--ink); }
.qty input { width: 46px; height: 38px; text-align: center; border: none; font-size: 15px;
  border-left: 1px solid var(--line); border-right: 1px solid var(--line); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 12px; font-weight: 800; font-size: 16px; padding: 14px 18px; width: 100%;
  transition: .15s;
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(255,90,60,.3); }
.btn-primary:active { transform: translateY(1px); }
.btn-outline { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-ghost { background: #eef1f3; color: var(--ink); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Cards / FAQ / reviews ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.faq-item { border-bottom: 1px solid var(--line); }
.faq-q { padding: 14px 0; font-weight: 700; font-size: 15px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; }
.faq-a { font-size: 14px; color: var(--muted); padding: 0 0 14px; display: none; }
.faq-item.open .faq-a { display: block; }
.faq-item.open .faq-q .arrow { transform: rotate(180deg); }
.arrow { transition: .2s; color: var(--muted); }

.review { padding: 12px 0; border-bottom: 1px solid var(--line); }
.review:last-child { border-bottom: none; }
.review .r-top { display: flex; justify-content: space-between; font-size: 13px; }
.review .r-name { font-weight: 700; }
.review p { font-size: 14px; color: #424b54; margin-top: 4px; }

/* detail blocks */
.detail-block h3 { font-size: 18px; margin: 20px 0 8px; color: var(--primary-dark); }
.detail-block p { font-size: 15px; color: #3a434c; }
.spec-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.spec-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.spec-table td:first-child { color: var(--muted); width: 35%; background: #fafbfb; }

/* ---------- Floating cart bar ---------- */
.cartbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: #fff; border-top: 1px solid var(--line);
  box-shadow: 0 -6px 24px rgba(0,0,0,.08);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.cartbar .wrap { display: flex; align-items: center; gap: 12px; }
.cartbar .ci { flex: 1; }
.cartbar .ci .lbl { font-size: 11px; color: var(--muted); }
.cartbar .ci .amt { font-size: 19px; font-weight: 900; color: var(--accent); }
.cartbar .btn { width: auto; flex: 0 0 auto; padding: 13px 26px; }
.cart-fab-badge {
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 800;
  border-radius: 999px; padding: 1px 7px; margin-left: 4px;
}
body { padding-bottom: 88px; }

/* ---------- Cart drawer ---------- */
.drawer-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 80;
  opacity: 0; pointer-events: none; transition: .25s; }
.drawer-mask.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; right: 0; top: 0; bottom: 0; width: min(420px, 90vw);
  background: var(--bg); z-index: 90; transform: translateX(100%); transition: .28s ease;
  display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: center;
  padding: 16px; border-bottom: 1px solid var(--line); background: #fff; }
.drawer-head b { font-size: 17px; }
.drawer-head .x { font-size: 24px; background: none; color: var(--muted); }
.drawer-body { flex: 1; overflow-y: auto; padding: 12px 16px; }
.drawer-foot { padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid var(--line); }

.line-item { display: flex; gap: 12px; background: #fff; border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.line-item img { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: #eee; }
.line-item .li-info { flex: 1; min-width: 0; }
.line-item .li-name { font-size: 14px; font-weight: 700; }
.line-item .li-opt { font-size: 12px; color: var(--muted); }
.line-item .li-bot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.line-item .li-price { font-weight: 800; color: var(--accent); }
.li-remove { background: none; color: var(--muted); font-size: 12px; text-decoration: underline; }
.qty-sm button { width: 30px; height: 30px; font-size: 16px; }
.qty-sm input { width: 38px; height: 30px; }

.empty { text-align: center; color: var(--muted); padding: 50px 0; }
.empty .big { font-size: 46px; }

/* summary rows */
.sum-row { display: flex; justify-content: space-between; font-size: 14px; padding: 4px 0; }
.sum-row.total { font-size: 18px; font-weight: 900; border-top: 1px dashed var(--line);
  margin-top: 8px; padding-top: 10px; }
.sum-row .save { color: var(--primary); }
.note-free { font-size: 13px; background: #eafaf4; color: var(--primary-dark);
  padding: 8px 12px; border-radius: 8px; margin: 8px 0; }

/* ---------- Checkout steps ---------- */
.steps { display: flex; align-items: center; gap: 4px; margin: 18px 0 22px; }
.step { flex: 1; text-align: center; font-size: 11px; color: var(--muted); }
.step .dot { width: 28px; height: 28px; border-radius: 50%; background: #e3e7ea; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; margin: 0 auto 4px; font-size: 13px; }
.step.active .dot { background: var(--primary); }
.step.done .dot { background: var(--primary); }
.step.active { color: var(--primary); font-weight: 800; }

.field { margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 700; display: block; margin-bottom: 6px; }
.field label .req { color: var(--accent); }
.field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 12px;
  font-size: 15px; font-family: inherit; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary);
}
.field .err { color: var(--accent); font-size: 12px; margin-top: 4px; display: none; }
.field.invalid input, .field.invalid select { border-color: var(--accent); }
.field.invalid .err { display: block; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.pay-opt, .ship-opt {
  display: flex; gap: 12px; align-items: center; border: 1.5px solid var(--line);
  border-radius: 12px; padding: 14px; margin-bottom: 10px; cursor: pointer; background: #fff;
}
.pay-opt.active, .ship-opt.active { border-color: var(--primary); background: #f3fbf9; }
.pay-opt .ico { font-size: 22px; }
.pay-opt b, .ship-opt b { font-size: 15px; }
.pay-opt small, .ship-opt small { color: var(--muted); font-size: 12px; display: block; }
.radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); flex: 0 0 auto; }
.pay-opt.active .radio, .ship-opt.active .radio { border-color: var(--primary); border-width: 6px; }

.review-list { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 16px; }

.checkout-nav { display: flex; gap: 12px; margin-top: 20px; }
.checkout-nav .btn { flex: 1; }

/* sticky mini summary on checkout */
.mini-sum { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 16px; }

/* complete page */
.complete { text-align: center; padding: 50px 0; }
.complete .check { width: 84px; height: 84px; border-radius: 50%; background: var(--primary);
  color: #fff; font-size: 44px; display: flex; align-items: center; justify-content: center; margin: 0 auto 18px; }
.complete h1 { font-size: 24px; }
.order-box { text-align: left; margin: 20px 0; }

.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; font-size: 14px;
  font-weight: 700; z-index: 200; opacity: 0; transition: .25s; pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 16px 110px; }
.footer a { color: var(--primary); }

/* ---------- Product grid (全部商品) ---------- */
.product-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.pcard { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; display: flex; flex-direction: column; position: relative; transition: .15s; }
.pcard:active { transform: scale(.99); }
.pcard-badge { position: absolute; top: 8px; left: 8px; z-index: 2; background: var(--accent);
  color: #fff; font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px; }
.pcard-img { aspect-ratio: 1/1; background: #fff; }
.pcard-img img { width: 100%; height: 100%; object-fit: cover; }
.pcard-body { padding: 12px; display: flex; flex-direction: column; flex: 1; }
.pcard-name { font-weight: 800; font-size: 14px; }
.pcard-tag { color: var(--muted); font-size: 12px; margin: 2px 0 8px; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard-price { font-size: 13px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pcard-price b { color: var(--accent); font-size: 18px; }
.pcard-price small { color: var(--muted); text-decoration: line-through; }
.pcard .btn { font-size: 14px; padding: 9px; }

/* desktop tweaks */
@media (min-width: 760px) {
  .hero h1 { font-size: 32px; }
  .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
}
