/* ==========================================================================
   storefront/style.css
   暖奶磚紅・長輩友善大字體主題（全 CSS 變數管理，1 分鐘可換膚 — Q15）
   ========================================================================== */

:root {
  --bg-milk: #FAF7F2;
  --surface: #FFFFFF;
  --surface-soft: #FFFBF6;
  --primary: #B83B2A;
  --primary-dark: #8E271A;
  --primary-soft: #FDECE8;
  --primary-border: #F2C9BE;
  --green: #1E7F5C;
  --green-soft: #E6F5EE;
  --amber: #D97706;
  --amber-soft: #FEF3C7;
  --ice: #0284C7;
  --ice-soft: #E0F2FE;
  --ambient: #78716C;
  --ambient-soft: #F3EFEA;
  --border: #E8DDD0;
  --text-main: #231915;
  --text-sub: #5E4C43;
  --text-muted: #88766C;
  --shadow-card: 0 6px 18px rgba(78, 48, 32, 0.07);
  --shadow-float: 0 -4px 20px rgba(78, 48, 32, 0.12);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-pill: 999px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-milk);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input {
  font-family: inherit;
}

.app-shell {
  max-width: 540px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(108px + env(safe-area-inset-bottom, 0px));
  position: relative;
}

/* 頂部暖磚紅標頭 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(135deg, #C74533 0%, var(--primary) 58%, var(--primary-dark) 100%);
  color: #FFFFFF;
  padding: 14px 16px 13px;
  box-shadow: 0 4px 14px rgba(142, 39, 26, 0.22);
}

.topbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.store-brand {
  min-width: 0;
}

.store-title {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.store-sub {
  font-size: 13px;
  color: #FDE8E4;
  margin-top: 2px;
  font-weight: 600;
}

.topbar-btn {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.20);
  color: #FFFFFF;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  border-radius: var(--radius-pill);
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.topbar-btn:active {
  transform: scale(0.97);
}

/* Demo / 狀態提醒橫幅 */
.status-banner {
  margin: 12px 14px 0;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
}

.status-banner.info {
  background: var(--amber-soft);
  color: #92400E;
  border: 1px solid #FCD34D;
}

.status-banner.error {
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
}

/* 搜尋與分類列 */
.controls-sticky {
  background: var(--bg-milk);
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input {
  width: 100%;
  height: 48px;
  padding: 0 44px 0 42px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  font-size: 16px;
  font-weight: 600;
  outline: none;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(184, 59, 42, 0.14);
}

.search-icon {
  position: absolute;
  left: 15px;
  font-size: 18px;
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: 10px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: #EAE0D5;
  color: var(--text-main);
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  display: none;
}

.cat-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 2px 2px;
  scrollbar-width: none;
}

.cat-tabs::-webkit-scrollbar {
  display: none;
}

.cat-tab {
  flex-shrink: 0;
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-sub);
  font-size: 15.5px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.cat-tab.active {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
  box-shadow: 0 4px 10px rgba(184, 59, 42, 0.24);
}

/* 商品列表 */
.product-list {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.product-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
}

.product-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--surface-soft);
  overflow: hidden;
}

.product-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 無圖時的溫層＋屬性質感文字卡片 (Q7) */
.artwork-fallback {
  width: 100%;
  height: 100%;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.artwork-fallback.temp-FROZEN {
  background: linear-gradient(135deg, #0369A1 0%, #0EA5E9 55%, #7DD3FC 100%);
  color: #FFFFFF;
}

.artwork-fallback.temp-CHILLED {
  background: linear-gradient(135deg, #0F766E 0%, #14B8A6 60%, #99F6E4 100%);
  color: #FFFFFF;
}

.artwork-fallback.temp-AMBIENT {
  background: linear-gradient(135deg, #9A3412 0%, #C25338 56%, #F3B391 100%);
  color: #FFFFFF;
}

.artwork-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.artwork-pill {
  background: rgba(255, 255, 255, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.45);
  color: #FFFFFF;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  font-weight: 800;
}

.artwork-title {
  font-size: 24px;
  font-weight: 900;
  line-height: 1.25;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ordered-float-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #FFFBEB;
  color: #B45309;
  border: 1.5px solid #F59E0B;
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.16);
}

.product-body {
  padding: 14px 16px 16px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 800;
}

.pill-temp-FROZEN, .pill-temp-CHILLED {
  background: var(--ice-soft);
  color: var(--ice);
}

.pill-temp-AMBIENT {
  background: var(--ambient-soft);
  color: var(--ambient);
}

.pill-attr {
  background: var(--primary-soft);
  color: var(--primary);
}

.pill-mix {
  background: #F3E8FF;
  color: #7C3AED;
}

.pill-date {
  background: #F1F5F9;
  color: #475569;
}

.product-name {
  margin: 0 0 6px;
  font-size: 19px;
  font-weight: 900;
  color: var(--text-main);
  line-height: 1.32;
}

.product-desc {
  margin: 0 0 12px;
  font-size: 14.5px;
  color: var(--text-sub);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.price-tag {
  font-size: 24px;
  font-weight: 900;
  color: var(--primary);
  line-height: 1.1;
}

.price-unit-hint {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  margin-left: 3px;
}

.btn-select {
  min-height: 46px;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--primary);
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(184, 59, 42, 0.24);
}

.btn-select:active {
  transform: scale(0.97);
}

/* 底部浮動購物車條 */
.cart-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 540px;
  z-index: 40;
  background: var(--surface);
  border-top: 1.5px solid var(--border);
  box-shadow: var(--shadow-float);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.cart-bar.hidden {
  display: none;
}

.cart-summary {
  display: flex;
  flex-direction: column;
}

.cart-count-text {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-sub);
}

.cart-total-text {
  font-size: 23px;
  font-weight: 900;
  color: var(--primary);
  line-height: 1.1;
}

.btn-checkout-bar {
  min-height: 50px;
  padding: 12px 24px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--primary);
  color: #FFFFFF;
  font-size: 17px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 5px 14px rgba(184, 59, 42, 0.28);
}

/* 彈窗 / Bottom Sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(25, 18, 14, 0.56);
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop.open {
  display: flex;
}

.sheet-panel {
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -10px 32px rgba(0, 0, 0, 0.22);
}

.sheet-head {
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--surface-soft);
}

.sheet-title {
  margin: 0;
  font-size: 19px;
  font-weight: 900;
  color: var(--text-main);
}

.sheet-close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-sub);
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.sheet-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
}

.sheet-foot {
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* 規格選擇卡片 */
.opt-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.opt-item {
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  background: var(--surface);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.opt-item.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.opt-name {
  font-size: 16.5px;
  font-weight: 800;
  color: var(--text-main);
}

.opt-sub {
  font-size: 13.5px;
  color: var(--text-sub);
  margin-top: 2px;
}

.opt-price {
  font-size: 20px;
  font-weight: 900;
  color: var(--primary);
  white-space: nowrap;
}

/* 數量加減器（長輩大按鈕） */
.stepper-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-milk);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.stepper-ctrl {
  display: flex;
  align-items: center;
  gap: 12px;
}

.step-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  font-size: 24px;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.step-btn.plus {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}

.step-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.step-val {
  min-width: 34px;
  text-align: center;
  font-size: 20px;
  font-weight: 900;
  color: var(--text-main);
}

/* FREE_MIX 視覺化選口味器 (Q8) */
.freemix-box {
  background: var(--bg-milk);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-top: 10px;
}

.freemix-progress-bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #E5D9CC;
  overflow: hidden;
  margin: 8px 0 10px;
}

.freemix-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--amber);
  transition: width 0.18s ease, background 0.18s ease;
}

.freemix-progress-fill.ready {
  background: var(--green);
}

.freemix-status {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 12px;
}

.freemix-status.pending {
  background: var(--amber-soft);
  color: #92400E;
}

.freemix-status.ready {
  background: var(--green-soft);
  color: #14532D;
}

.flavor-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.flavor-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.flavor-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
}

.primary-cta {
  width: 100%;
  min-height: 54px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--primary);
  color: #FFFFFF;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(184, 59, 42, 0.28);
}

.primary-cta:disabled {
  background: #C7B9B0;
  box-shadow: none;
  cursor: not-allowed;
}

.secondary-cta {
  width: 100%;
  min-height: 48px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  margin-top: 10px;
}

/* 購物車項目 */
.cart-item {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px;
  margin-bottom: 10px;
  background: var(--surface-soft);
}

.cart-item-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.cart-item-title {
  font-size: 17px;
  font-weight: 900;
  color: var(--text-main);
}

.cart-item-spec {
  font-size: 14.5px;
  color: var(--text-sub);
  margin: 4px 0 10px;
  word-break: break-word;
}

.cart-remove-btn {
  background: #FEE2E2;
  color: #B91C1C;
  border: none;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

/* 🎟️ 櫃台核銷碼大螢幕視圖 (?mode=qr — Q16) */
.qr-view {
  padding: 16px;
}

.qr-card {
  background: var(--surface);
  border: 2px solid var(--primary-border);
  border-radius: 22px;
  padding: 20px 18px;
  text-align: center;
  box-shadow: var(--shadow-card);
}

.qr-title {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 900;
  color: var(--primary);
}

.qr-sub {
  margin: 0 0 14px;
  font-size: 15px;
  color: var(--text-sub);
  font-weight: 700;
}

.qr-svg-wrap {
  width: 248px;
  height: 248px;
  margin: 0 auto 12px;
  padding: 12px;
  background: #FFFFFF;
  border: 3px solid var(--text-main);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-svg-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}

.qr-countdown {
  display: inline-block;
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  background: var(--green-soft);
  color: var(--green);
  font-size: 15px;
  font-weight: 900;
  margin-bottom: 14px;
}

.qr-countdown.expired {
  background: #FEE2E2;
  color: #B91C1C;
}

.qr-summary-box {
  margin-top: 14px;
  text-align: left;
  background: var(--bg-milk);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.qr-summary-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
  font-weight: 900;
  margin-bottom: 10px;
}

.qr-pickup-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.empty-state {
  text-align: center;
  padding: 44px 20px;
  background: var(--surface);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-lg);
  margin: 14px;
  color: var(--text-sub);
}

.empty-state h3 {
  margin: 8px 0 6px;
  font-size: 19px;
  color: var(--text-main);
}

.receipt-box {
  background: var(--green-soft);
  border: 1.5px solid #86EFAC;
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
  text-align: center;
}

.receipt-list-item {
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 15.5px;
}

.receipt-list-item:last-child {
  border-bottom: none;
}
