/* =========================================================
   線上點餐 - 顧客前端樣式
   主題全部走 CSS 變數，換客戶只需改 :root 一處
   行動優先 RWD、暖色餐飲調、手機 sticky 底部購物車列
   ========================================================= */

:root {
  /* —— 品牌主題（華承軒 麵館）—— */
  --bg: #f7f1e7;        /* 暖奶油 cream */
  --card: #fdfaf4;      /* 紙白 paper */
  --ink: #1c1714;       /* 墨黑 */
  --muted: #4a3f37;     /* ink-soft */
  --brand: #c0392b;     /* 朱紅 vermilion */
  --brand-ink: #9c2a1d; /* 朱紅深 vermilion-deep */
  --accent: #b8893b;    /* 火腿金 gold */
  --line: #e7dcc8;      /* 暖色淺邊 */
  --radius: 16px;
  --shadow: 0 6px 20px rgba(60, 40, 25, 0.08), 0 1px 3px rgba(60, 40, 25, 0.05);
  --shadow-lg: 0 -8px 28px rgba(60, 40, 25, 0.12);

  /* —— 衍生 —— */
  --radius-sm: 10px;
  --radius-pill: 999px;
  --brand-soft: rgba(192, 57, 43, 0.10);
  --accent-soft: rgba(184, 137, 59, 0.12);
  --maxw: 760px;
  --bar-h: 72px;

  --font: "Noto Sans TC", -apple-system, BlinkMacSystemFont, "Segoe UI",
          "PingFang TC", "Microsoft JhengHei", "Helvetica Neue", Arial, sans-serif;
  /* 標題／店名楷體 */
  --font-serif: "LXGW WenKai TC", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* 預留底部 sticky 購物車列空間 */
  padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px));
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: 18px;
}

/* =========================================================
   頂部品牌列
   ========================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  flex: none;
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--brand), var(--brand-ink));
  color: #fff;
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: 22px;
  box-shadow: var(--shadow);
}
.brand-text { min-width: 0; }
.brand-name {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-tag { font-size: 12px; color: var(--muted); }

.header-phone {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--brand-ink);
  background: var(--brand-soft);
  font-weight: 700;
  font-size: 13px;
  padding: 8px 13px;
  border-radius: var(--radius-pill);
  transition: background .18s ease;
}
.header-phone:active { background: rgba(192, 57, 43, 0.2); }

/* =========================================================
   主視覺
   ========================================================= */
.hero {
  background:
    radial-gradient(120% 90% at 100% 0%, var(--brand-soft), transparent 55%),
    radial-gradient(90% 80% at 0% 100%, var(--accent-soft), transparent 60%);
  border-bottom: 1px solid var(--line);
}
.hero-inner { padding-block: 30px 34px; }
.hero-kicker {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--brand-ink);
  background: var(--card);
  border: 1px solid var(--line);
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(30px, 7.8vw, 44px);
  font-weight: 900;
  letter-spacing: 1px;
}
.hero-sub {
  margin-top: 12px;
  max-width: 30em;
  color: var(--muted);
  font-size: 15px;
}

/* =========================================================
   分類導覽（sticky 橫向捲動）
   ========================================================= */
.cat-nav {
  position: sticky;
  top: 60px;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.cat-nav:empty, .cat-nav[hidden] { display: none; }
.cat-nav-inner {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-block: 11px;
  scroll-snap-type: x proximity;
}
.cat-nav-inner::-webkit-scrollbar { display: none; }
.cat-chip {
  flex: none;
  scroll-snap-align: start;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
  padding: 7px 15px;
  border-radius: var(--radius-pill);
  text-decoration: none;
  white-space: nowrap;
  transition: all .16s ease;
}
.cat-chip.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* =========================================================
   菜單區
   ========================================================= */
.menu-area { padding-block: 22px 40px; }

.cat-block { margin-bottom: 30px; scroll-margin-top: 116px; }
.cat-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: .5px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.cat-title::before {
  content: "";
  width: 4px; height: 20px;
  border-radius: 4px;
  background: var(--brand);
}
.cat-rule { height: 1px; background: var(--line); margin: 12px 0 16px; }

.dish-list { display: grid; gap: 12px; }

/* 菜品卡片 */
.dish {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  align-items: start;
}
.dish-main { min-width: 0; }
.dish-name {
  font-size: 16.5px;
  font-weight: 700;
}
.dish-desc {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dish-price {
  margin-top: 9px;
  font-size: 16px;
  font-weight: 900;
  color: var(--brand-ink);
}
.dish-price small { font-size: 12px; font-weight: 700; opacity: .8; }

.dish-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.dish-thumb {
  width: 92px; height: 92px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--bg);
  border: 1px solid var(--line);
}
.dish-thumb-ph {
  width: 92px; height: 92px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--brand-soft), var(--accent-soft));
  color: var(--brand-ink);
}

/* 加入購物車 / 數量加減 */
.dish-add {
  border: 0;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  height: 38px;
  padding: 0 18px;
  border-radius: var(--radius-pill);
  transition: transform .12s ease, background .16s ease;
  box-shadow: 0 3px 10px rgba(192, 57, 43, .28);
}
.dish-add:active { transform: scale(.95); background: var(--brand-ink); }

.qty-stepper {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--brand-soft);
  border-radius: var(--radius-pill);
  padding: 3px;
}
.qty-btn {
  width: 32px; height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  display: grid; place-items: center;
  transition: transform .1s ease;
}
.qty-btn:active { transform: scale(.9); }
.qty-num {
  min-width: 26px;
  text-align: center;
  font-weight: 800;
  font-size: 15px;
  color: var(--brand-ink);
}

/* =========================================================
   狀態（載入 / 空 / 錯誤）
   ========================================================= */
.state {
  text-align: center;
  padding: 56px 20px;
  color: var(--muted);
}
.state h3 { color: var(--ink); font-size: 18px; margin-bottom: 6px; }
.state-icon { color: var(--brand); opacity: .85; margin-bottom: 12px; }
.state .btn { margin-top: 18px; }

.spinner {
  width: 34px; height: 34px;
  margin: 0 auto 14px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================
   頁尾
   ========================================================= */
.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 26px 30px;
  text-align: center;
  color: var(--muted);
}
.foot-name { font-family: var(--font-serif); font-weight: 900; color: var(--ink); font-size: 18px; letter-spacing: 1px; }
.foot-info { font-size: 13px; margin-top: 6px; }
.foot-copy { font-size: 12px; margin-top: 12px; opacity: .7; }

/* =========================================================
   通用按鈕
   ========================================================= */
.btn {
  border: 0;
  border-radius: var(--radius-pill);
  font-weight: 800;
  font-size: 16px;
  padding: 14px 22px;
  transition: transform .12s ease, opacity .16s ease, background .16s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-block { width: 100%; }
.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 14px rgba(192, 57, 43, .3);
}
.btn-primary:active { background: var(--brand-ink); }
.btn-outline {
  background: transparent;
  color: var(--brand-ink);
  border: 1.5px solid var(--brand);
}

/* =========================================================
   手機 sticky 底部購物車列
   ========================================================= */
.cart-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.cart-bar[hidden] { display: none; }
.cart-bar-btn {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 0;
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius);
  padding: 13px 18px;
  box-shadow: 0 6px 18px rgba(192, 57, 43, .34);
  transition: transform .12s ease, background .16s ease;
}
.cart-bar-btn:active { transform: scale(.99); background: var(--brand-ink); }
.cart-bar-left { display: inline-flex; align-items: center; gap: 12px; }
.cart-bar-icon { position: relative; display: inline-flex; }
.cart-count {
  position: absolute;
  top: -8px; right: -10px;
  min-width: 19px; height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: #fff;
  color: var(--brand-ink);
  font-size: 11.5px;
  font-weight: 900;
  display: grid; place-items: center;
  line-height: 1;
}
.cart-bar-label { font-weight: 800; font-size: 15.5px; }
.cart-bar-total { font-weight: 900; font-size: 17px; }

/* =========================================================
   購物車 / 結帳 抽屜
   ========================================================= */
.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(34, 26, 21, .42);
  opacity: 0;
  animation: fadeIn .2s ease forwards;
}
.sheet-overlay[hidden] { display: none; }
@keyframes fadeIn { to { opacity: 1; } }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 70;
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  max-height: 92vh;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  animation: slideUp .28s cubic-bezier(.22, 1, .36, 1) forwards;
}
.sheet[hidden] { display: none; }
@keyframes slideUp { to { transform: translateY(0); } }

.sheet-handle {
  width: 40px; height: 4px;
  background: var(--line);
  border-radius: 4px;
  margin: 9px auto 2px;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.sheet-head h3 { font-family: var(--font-serif); font-size: 21px; font-weight: 900; letter-spacing: .5px; }
.sheet-close {
  border: 0;
  background: var(--bg);
  color: var(--muted);
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
}
.sheet-close:active { background: var(--line); }

.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 18px 8px;
  flex: 1;
}

/* 購物車明細 */
.cart-empty { text-align: center; padding: 40px 10px; }
.cart-empty-title { font-weight: 800; font-size: 16px; }
.cart-empty-sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; }

.cart-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.cart-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 14px;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.cart-item:last-child { border-bottom: 0; }
.ci-name { font-weight: 700; font-size: 15px; }
.ci-price { color: var(--muted); font-size: 13px; margin-top: 2px; }
.ci-line-total { font-weight: 900; color: var(--brand-ink); font-size: 15px; white-space: nowrap; }
.ci-controls { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; }
.ci-remove {
  border: 0; background: none; color: var(--muted);
  font-size: 13px; text-decoration: underline; padding: 4px 0;
}

/* 結帳表單 */
.form-section-title {
  font-size: 14px;
  font-weight: 900;
  color: var(--ink);
  margin: 18px 0 10px;
}
.form-section-title:first-child { margin-top: 4px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 6px;
}
.req { color: var(--brand); }
.field input,
.field textarea {
  width: 100%;
  font-family: inherit;
  font-size: 16px; /* 16px 防 iOS 縮放 */
  color: var(--ink);
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: border-color .16s ease, background .16s ease;
}
.field input::placeholder,
.field textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--card);
}
.field textarea { resize: vertical; min-height: 56px; }

/* 分段選擇器 segmented control */
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 6px;
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  text-align: center;
  font-weight: 700;
  font-size: 14.5px;
  color: var(--muted);
  padding: 9px 6px;
  border-radius: 8px;
  transition: all .16s ease;
}
.seg input:checked + label {
  background: var(--card);
  color: var(--brand-ink);
  box-shadow: var(--shadow);
}

.form-error {
  color: var(--brand-ink);
  background: var(--brand-soft);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 12px;
  margin-top: 6px;
}
.form-error[hidden] { display: none; }

/* 抽屜底部操作列 */
.sheet-foot {
  border-top: 1px solid var(--line);
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
}
.sheet-foot[hidden] { display: none; }
.sheet-total { flex: none; line-height: 1.2; }
.sheet-total span { display: block; font-size: 12px; color: var(--muted); }
.sheet-total strong { font-size: 20px; font-weight: 900; color: var(--brand-ink); }
.sheet-foot .btn { flex: 1; }

/* 下單成功 */
.success { text-align: center; padding: 18px 6px 8px; }
.success-icon {
  width: 76px; height: 76px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}
.success h3 { font-family: var(--font-serif); font-size: 24px; font-weight: 900; letter-spacing: .5px; }
.success-sub { color: var(--muted); margin-top: 6px; font-size: 14px; }
.success-card {
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 18px 0 10px;
}
.success-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
}
.success-row + .success-row { border-top: 1px dashed var(--line); }
.success-row span { color: var(--muted); font-size: 14px; }
.success-row strong { font-size: 17px; font-weight: 900; }
.success-row #successNo { color: var(--brand-ink); letter-spacing: .5px; }
.success-tip { color: var(--muted); font-size: 13px; margin: 6px 0 18px; }

/* =========================================================
   平板 / 桌機微調
   ========================================================= */
@media (min-width: 640px) {
  .dish-list { grid-template-columns: 1fr 1fr; }
  .hero-inner { padding-block: 44px 48px; }
}

@media (min-width: 900px) {
  .cart-bar { padding-bottom: 14px; }
}

/* 尊重減少動態偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}
