/* 商家活動頁（v2/layout/merchant.php）。主色 --accent 由 layout 依活動的 color_bg 帶入 */
:root {
    --ink: #1C1917;
    --ink-2: #57534E;
    --ink-3: #78716C;
    --line: #E7E5E4;
    --bg: #FAFAF9;
    --card: #FFFFFF;
    --price: #C81E1E;
    --accent: #1C1917;
    --on-accent: #FFFFFF;
    --accent-text: #1C1917;
    --r-sm: 10px;
    --r-md: 16px;
    --r-lg: 20px;
    --tap: 44px;
    --shadow: 0 1px 2px rgba(28, 25, 23, .06), 0 4px 16px rgba(28, 25, 23, .06);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    padding-bottom: 140px; /* 底部購物車列；有 JS 時依實際高度調整 */
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.6 "Noto Sans TC", -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", sans-serif;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.m-wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* header */
.m-header { background: var(--accent); color: var(--on-accent); }
.m-header-inner { display: flex; align-items: center; gap: 14px; padding-top: 14px; padding-bottom: 14px; }
.m-logo { width: auto; max-height: 56px; border-radius: var(--r-sm); background: #fff; padding: 4px; flex: none; }
.m-header-text { min-width: 0; }
.m-shop { margin: 0; font-size: 14px; opacity: .85; }
.m-title { margin: 0; font-size: 20px; line-height: 1.35; font-weight: 700; overflow-wrap: anywhere; }
.m-title small { font-size: 14px; font-weight: 500; opacity: .85; }

/* 活動圖、影片、說明 */
.m-hero { padding: 16px 0 0; }
.m-hero .m-wrap { display: grid; gap: 12px; }
.m-hero-img { width: 100%; border-radius: var(--r-md); }
.m-video { position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-md); overflow: hidden; background: #000; }
.m-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.m-note { background: var(--card); border-radius: var(--r-md); padding: 16px 18px; box-shadow: var(--shadow); color: var(--ink-2); overflow-wrap: anywhere; }

.m-state { margin: 16px 0 0; padding: 18px; border-radius: var(--r-md); background: var(--card); box-shadow: var(--shadow); text-align: center; font-size: 22px; font-weight: 700; color: var(--price); }
.m-state small { display: block; font-size: 14px; font-weight: 400; color: var(--ink-3); }

/* STEP */
.m-step { padding: 28px 0 0; }
.m-step-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 14px; font-size: 18px; line-height: 1.4; }
.m-step-no { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 13px; letter-spacing: .04em; }

/* 商品 */
.m-prods { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.m-prod { display: flex; flex-direction: column; background: var(--card); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); }
.m-prod-img { width: 100%; aspect-ratio: 1; /* 正方形縮圖，同商城卡片，圖片滿版 */ object-fit: cover; background: var(--line); }
.m-prod-body { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px 16px; flex: 1; }
.m-prod-name { margin: 0; font-size: 17px; line-height: 1.4; color: var(--accent-text); overflow-wrap: anywhere; }
.m-prod-model { margin: 0; font-size: 13px; color: var(--ink-3); }
.m-prod-note { font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere; }
.m-prod-price { margin: auto 0 0; padding-top: 4px; font-size: 22px; font-weight: 700; text-align: right; color: var(--price); }
.m-specs { display: grid; gap: 8px; }
.m-qty-row { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.m-qty { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: #fff; }
.m-qty button { width: var(--tap); min-height: var(--tap); border: 0; background: var(--accent); color: var(--on-accent); font-size: 20px; cursor: pointer; }
.m-qty button:disabled { background: var(--line); color: var(--ink-3); cursor: not-allowed; }
.m-qty input { width: 64px; border: 0; text-align: center; font-size: 17px; font-weight: 700; -moz-appearance: textfield; }
.m-qty input::-webkit-outer-spin-button, .m-qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.m-stock { order: -1; /* 庫存提示放在數量左邊，數量貼右 */ font-size: 13px; font-weight: 500; color: var(--price); }
.m-stock.is-out { color: var(--ink-3); }

/* 表單 */
.m-form { display: grid; gap: 16px; }
.m-fieldset { margin: 0; padding: 18px; border: 0; border-radius: var(--r-lg); background: var(--card); box-shadow: var(--shadow); display: grid; gap: 14px; min-width: 0; }
.m-fieldset legend { float: left; width: 100%; padding: 0; margin-bottom: 2px; font-size: 16px; font-weight: 700; color: var(--accent-text); }
.m-fieldset legend + * { clear: left; }
.m-field { display: grid; gap: 6px; min-width: 0; }
.m-field > span, .m-field > label { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.m-field input[type=text], .m-field input[type=tel], .m-field input[type=email], .m-select {
    width: 100%; min-height: var(--tap); padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; font-size: 16px;
}
.m-select { appearance: none; -webkit-appearance: none; padding-right: 36px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2378716C' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 12px center; }
.m-field input:focus, .m-select:focus { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 0; }
.m-addr-local { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.m-radios, .m-checks { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.m-radios label, .m-checks label, .m-agree { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); cursor: pointer; }
.m-radios input, .m-checks input, .m-agree input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex: none; }
.m-agree { flex-wrap: wrap; gap: 4px 8px; font-weight: 500; }
.m-link { padding: 0; border: 0; background: none; color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-weight: 700; min-height: var(--tap); justify-self: start; }
.m-hint { margin: 0; padding: 12px 14px; border-radius: var(--r-sm); background: var(--bg); color: var(--ink-2); font-size: 14px; }

/* 付款 */
.m-pay { display: block; width: 100%; max-width: 420px; min-height: 56px; margin: 0 auto; border: 0; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 18px; font-weight: 700; cursor: pointer; box-shadow: var(--shadow); }
.m-pay:disabled { opacity: .6; cursor: progress; }
.m-step-title { scroll-margin-top: 16px; }
.m-pay-note { margin: 8px 0 0; text-align: center; font-size: 13px; color: var(--ink-3); }

/* 底部購物車列 */
.m-cartbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(0, 0, 0, .78); color: #fff; padding-bottom: env(safe-area-inset-bottom); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.m-cartbar-inner { display: flex; align-items: center; gap: 12px; padding-top: 10px; padding-bottom: 10px; }
/* 字級同舊版 .fix-cart：手機 15px / 數字 20px，平板 16 / 26，桌機 22 / 33 */
.m-cart-total { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 12px; font-size: 15px; line-height: 1.35; }
.m-cart-total .impor { font-weight: 700; color: #FFD02F; font-size: 20px; padding: 0 2px; }
.m-cartbar-btn { flex: none; display: inline-flex; align-items: center; text-decoration: none; min-height: var(--tap); padding: 0 22px; border: 0; border-radius: 999px; background: #FFD02F; color: #1C1917; font-weight: 700; cursor: pointer; }

/* 對話框 */
.m-dialog { width: min(640px, calc(100% - 32px)); max-height: calc(100% - 64px); padding: 0; border: 0; border-radius: var(--r-lg); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.m-dialog::backdrop { background: rgba(28, 25, 23, .5); }
.m-dialog-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 12px 12px 20px; background: #fff; border-bottom: 1px solid var(--line); }
.m-dialog-head h2 { margin: 0; font-size: 17px; }
.m-dialog-head button { width: var(--tap); height: var(--tap); border: 0; border-radius: 50%; background: var(--bg); cursor: pointer; font-size: 16px; }
.m-dialog-body { padding: 16px 20px 20px; }
.m-rich { font-size: 15px; color: var(--ink-2); overflow-wrap: anywhere; }
.m-rich img { height: auto; }

/* footer */
/* 聯絡資訊放在白卡裡（同舊版），商家主色再淺都看得清楚 */
.m-footer { margin-top: 40px; padding: 28px 0 24px; background: var(--accent); color: var(--on-accent); }
.m-contact-card { padding: 16px 20px; border-radius: var(--r-md); background: #fff; color: var(--ink); box-shadow: 0 4px 20px rgba(28, 25, 23, .12); }
.m-footer-name { margin: 0 0 6px; font-weight: 700; }
/* 每項依內容寬度排，Email 不會被切在中間；只有一整行都放不下時才斷 */
.m-contact { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 28px; }
.m-contact li { min-width: 0; max-width: 100%; }
.m-contact a { display: flex; align-items: center; gap: 12px; min-height: 52px; text-decoration: none; }
.m-contact a:hover .m-contact-text { text-decoration: underline; }
.m-contact-text { display: block; min-width: 0; line-height: 1.3; font-weight: 500; overflow-wrap: break-word; }
/* inline-block 讓整段一起換行；比整行還長時才在裡面斷 */
.m-nobreak { display: inline-block; max-width: 100%; overflow-wrap: anywhere; }
.m-contact-text small { display: block;  font-size: 12px; font-weight: 400; color: var(--ink-3); }
.m-ic { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; background: var(--ink); color: #fff; }
.m-ic-line { background: #06C755; }
.m-ic-fb { background: #1877F2; }
.m-copy { margin: 16px 0 0; font-size: 12px; opacity: .8; }

@media (min-width: 768px) {
    .m-title { font-size: 24px; }
    .m-step-title { font-size: 20px; }
    .m-fieldset { padding: 22px 24px; }
    .m-cart-total { font-size: 16px; }
    .m-cart-total .impor { font-size: 26px; }
    .m-cartbar-inner { padding-top: 12px; padding-bottom: 12px; }
}
@media (min-width: 1200px) {
    .m-cart-total { font-size: 22px; }
    .m-cart-total .impor { font-size: 33px; }
    .m-cartbar-btn { min-height: 52px; padding: 0 28px; font-size: 18px; }
}

/* 結帳成功頁（v2/pages/success.php） */
body:has(.m-done) { padding-bottom: 0; }
.m-done-head { padding: 24px 18px; border-radius: var(--r-lg); background: var(--card); box-shadow: var(--shadow); text-align: center; }
.m-done-icon { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: var(--on-accent); }
.m-done-title { margin: 12px 0 4px; font-size: 22px; }
.m-done-text { margin: 0; color: var(--ink-2); }
.m-done-no { margin: 14px 0 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-3); }
.m-done-no strong { display: block; font-size: 18px; color: var(--ink); letter-spacing: .04em; overflow-wrap: anywhere; }
.m-order { border-radius: var(--r-lg); background: var(--card); box-shadow: var(--shadow); overflow: hidden; }
.m-order-list { list-style: none; margin: 0; padding: 0; }
.m-order-item { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.m-order-name { font-weight: 500; overflow-wrap: anywhere; }
.m-order-spec { display: block; font-size: 13px; font-weight: 400; color: var(--ink-3); }
.m-order-calc { grid-column: 1; font-size: 14px; color: var(--ink-2); }
.m-order-sum { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-weight: 700; }
.m-order-totals { margin: 0; padding: 10px 18px 16px; }
.m-order-totals div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
.m-order-totals dt { color: var(--ink-2); }
.m-order-totals dd { margin: 0; font-weight: 500; white-space: nowrap; }
.m-order-total { margin-top: 4px; border-top: 1px solid var(--line); padding-top: 12px !important; }
.m-order-total dt { color: var(--ink); font-weight: 700; }
.m-order-total dd { font-size: 22px; font-weight: 700; color: var(--price); }
.m-share { display: flex; flex-wrap: wrap; gap: 10px; }
.m-share-btn { display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); min-width: 108px; padding: 0 18px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink); font-weight: 500; text-decoration: none; cursor: pointer; }
.m-share-btn:hover { border-color: var(--accent); }
