/* 三層：前層（列表卡片，影最淺）→ 側層（抽屜）→ 最上層（確認層，影最深） */
:root {
  --ink: #2b1b12;
  --cream: #fffaf2;
  --brand: #8e2a12;
  --shadow-card: 0 2px 8px rgba(43, 27, 18, 0.12);
  --shadow-drawer: 0 -6px 24px rgba(43, 27, 18, 0.28);
  --shadow-confirm: 0 12px 48px rgba(43, 27, 18, 0.45);
}

body {
  margin: 0;
  font-family: sans-serif;
  font-size: 20px;
  color: var(--ink);
  background: var(--cream);
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
  box-sizing: border-box;
}

header {
  padding: 20px 0 16px;
  background: #ffe0a8;
  border-bottom: 3px solid var(--brand);
}

header h1 {
  margin: 0;
  font-size: 32px;
}

.tagline {
  margin: 4px 0 0;
  font-size: 20px;
}

/* 怎麼買：三步，不是按鈕 */
.how {
  padding: 16px 0 4px;
}

.how h2 {
  margin: 0 0 12px;
  font-size: 22px;
}

.how-steps {
  display: flex;
  max-width: 640px;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.how-step {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  font-size: 22px;
  font-weight: bold;
  color: #fff;
  background: var(--brand);
  border-radius: 50%;
}

.step-text {
  font-size: 18px;
  font-weight: bold;
}

main {
  padding-top: 8px;
  padding-bottom: 32px;
}

.product-list {
  position: relative;
  z-index: 1;
}

.type-title {
  margin: 24px 0 12px;
  padding-left: 10px;
  font-size: 26px;
  color: var(--brand);
  border-left: 6px solid var(--brand);
}

.type-grid {
  display: grid;
  gap: 16px;
}

.product-card {
  padding: 12px 12px 16px;
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
}

.product-image {
  aspect-ratio: 4 / 3;
  background: #d9d9d9;
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}

.product-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.badge {
  display: inline-block;
  margin: 0 0 8px;
  padding: 2px 10px;
  font-size: 16px;
  font-weight: bold;
  color: #3d1f0d;
  background: #ffe8b8;
  border-radius: 999px;
}

.badge-dried-fruit {
  color: #2b3a0a;
  background: #e4f0c8;
}

.product-card h3 {
  margin: 0 0 4px;
  font-size: 24px;
}

.product-card .price {
  margin: 0 0 12px;
  font-size: 28px;
  font-weight: bold;
}

/* 按鈕：高 ≥56px、字 22px 粗、間距 ≥12px（R1 數字） */
.btn {
  display: block;
  width: 100%;
  min-height: 56px;
  margin: 0;
  padding: 0 16px;
  font-size: 22px;
  font-weight: bold;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--brand);
  border-radius: 8px;
  box-sizing: border-box;
  cursor: pointer;
}

.btn-primary {
  color: #fff;
  background: var(--brand);
}

.variant-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.variant-row .btn {
  width: auto;
  flex: 1 1 40%;
}

.variant-row .btn.selected {
  color: #fff;
  background: var(--brand);
}

.drawer-price {
  margin: 12px 0;
  font-size: 28px;
  font-weight: bold;
}

/* 側層：商品抽屜從下方滑出，高約 85% */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 11;
  height: 85vh;
  overflow-y: auto;
  box-sizing: border-box;
  background: var(--cream);
  color: var(--ink);
  border-radius: 16px 16px 0 0;
  box-shadow: var(--shadow-drawer);
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.drawer-image {
  width: 100%;
  margin-bottom: 0;
  border-radius: 0;
}

.drawer-body {
  padding: 16px 16px 100px;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer.open {
  transform: translateY(0);
}

.drawer h2 {
  margin: 0 0 8px;
  font-size: 28px;
}

#drawer-storage,
#drawer-heat {
  margin: 0 0 8px;
  font-size: 18px;
}

.drawer #drawer-add,
.drawer #drawer-close {
  margin-top: 12px;
}

/* 底部「看訂單」列（固定在畫面下方，蓋在抽屜上面） */
.order-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 12;
  padding: 12px 16px;
  box-sizing: border-box;
  background: var(--cream);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15);
}

/* 確認層：最上層（z 20），遮罩在它下面（z 19） */
.order-backdrop {
  position: fixed;
  inset: 0;
  z-index: 19;
  background: rgba(0, 0, 0, 0.5);
}

.order-layer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  max-height: 90vh;
  overflow-y: auto;
  padding: 16px;
  box-sizing: border-box;
  background: var(--cream);
  border-radius: 16px 16px 0 0;
  box-shadow: var(--shadow-confirm);
  animation: slide-up 0.28s ease;
}

@keyframes slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes pop-in {
  from { opacity: 0; transform: translate(-50%, -46%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

.order-layer h2 {
  margin: 0 0 12px;
  font-size: 24px;
}

.order-row {
  padding: 12px 0;
  border-bottom: 1px solid #ddd;
}

.order-row .order-name {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: bold;
}

.qty-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.qty-btn {
  width: auto;
  min-width: 56px;
  flex: 0 0 auto;
  padding: 0 12px;
}

.qty-num {
  min-width: 2em;
  text-align: center;
  font-size: 24px;
  font-weight: bold;
}

.order-subtotal {
  margin: 8px 0 0;
  font-size: 20px;
}

.order-total {
  margin: 12px 0;
  font-size: 28px;
  font-weight: bold;
}

.shop-info p {
  margin: 0 0 8px;
  font-size: 18px;
}

.order-hint {
  margin: 12px 0 0;
  font-size: 18px;
  font-weight: bold;
  color: var(--brand);
}

.order-layer .btn {
  margin-top: 12px;
}

/* 連結按鈕（用 LINE 送出訂單）：文字置中、不要底線 */
a.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  text-decoration: none;
}

/* LINE 綠底黑字（白字在這個綠上對比不夠） */
#order-line {
  color: #000;
  background: #06c755;
  border-color: #046b2e;
}

.order-copy-msg {
  min-height: 1.5em;
  margin: 8px 0 0;
  font-size: 18px;
  font-weight: bold;
}

.order-text {
  width: 100%;
  margin-top: 8px;
  box-sizing: border-box;
  font-size: 18px;
}

/* 電腦版：3 欄列表，抽屜改右側欄，確認層置中 */
@media (min-width: 900px) {
  .type-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .drawer {
    left: auto;
    top: 0;
    width: 440px;
    height: 100vh;
    border-radius: 0;
    box-shadow: -8px 0 28px rgba(43, 27, 18, 0.28);
    transform: translateX(100%);
  }

  .drawer.open {
    transform: translateX(0);
  }

  .order-layer {
    left: 50%;
    right: auto;
    top: 50%;
    bottom: auto;
    width: 520px;
    border-radius: 16px;
    transform: translate(-50%, -50%);
    animation: pop-in 0.28s ease;
  }
}

/* 量測頁（?selftest=1）關掉動畫，量到的是開完後的位置 */
.selftest *,
.selftest *::before {
  transition: none !important;
  animation: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .drawer-backdrop,
  .drawer {
    transition: none;
  }

  .order-layer {
    animation: none;
  }
}
