/* ============================================================
   Healzpace 全站共用樣式
   色值一律用 assets/theme.js 注入的 CSS 變數，這裡不寫死色碼。
   ============================================================ */

html { scroll-behavior: smooth; }
body { -webkit-font-smoothing: antialiased; }

/* hidden 屬性一律優先：否則元素上的 flex / grid 等 utility 會蓋掉它，導致該藏的區塊還顯示 */
[hidden] { display: none !important; }

/* FAQ 摺疊：Safari 不吃 list-none，會冒出預設小三角 */
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }

/* 金額、數量等數字對齊 */
.tnum { font-variant-numeric: tabular-nums; }

/* Toast：頂部置中滑入（DESIGN_SYSTEM 規格） */
#toast {
  position: fixed;
  left: 50%;
  top: -100px;
  transform: translateX(-50%);
  background: var(--brand-50);
  color: var(--brand-900);
  border: 1px solid var(--brand-200);
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 12%);
  z-index: 90;
  transition: top .45s cubic-bezier(.175, .885, .32, 1.275);
}
#toast.on { top: 76px; }

/* 點陣背景（A 版 hero） */
.dots {
  background-image: radial-gradient(circle, var(--paper-300) 1px, transparent 1px);
  background-size: 22px 22px;
}

/* 螢光筆重點字 */
.mark-hl { position: relative; z-index: 0; }
.mark-hl::after {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  bottom: 4px;
  height: 12px;
  background: var(--corn-300);
  border-radius: 4px;
  z-index: -1;
}

/* 進場動畫 */
@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}
.rise { animation: rise .7s cubic-bezier(.22, .61, .36, 1) both; }

.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .6s ease, transform .6s ease;
}
.reveal.on { opacity: 1; transform: none; }

/* ============================================================
   商品輪播（首頁、商品頁共用）
   ============================================================ */
.rail {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  padding-bottom: 4px;
}
.rail::-webkit-scrollbar { display: none; }
/* 手機：一張多一點，下一張露邊角當作可滑的提示 */
.rail > * { scroll-snap-align: start; flex: 0 0 78%; }
/* 桌機：三張剛好填滿內容寬度；商品變多時才會溢出、才需要箭頭 */
@media (min-width: 640px)  { .rail > * { flex-basis: calc((100% - 20px) / 2); } }
@media (min-width: 1024px) { .rail > * { flex-basis: calc((100% - 40px) / 3); } }

/* 疊在情境照包裝正面的品牌標示：位置用百分比，跟著照片一起縮放
   （照片必須以 2:1 原比例顯示，百分比才對得準） */
.pouch-mark {
  position: absolute;
  left: 74.2%;
  top: 43%;
  transform: translate(-50%, -50%);
  width: clamp(46px, 9.2%, 150px);
  font-size: clamp(46px, 9.2vw, 150px); /* 內層文字用 em 跟著縮 */
  text-align: center;
}
@media (min-width: 768px) {
  .pouch-mark { font-size: clamp(60px, 9.2vw, 150px); }
}

/* ============================================================
   表單（DESIGN_SYSTEM 表單規格：48px 高、8px 圓角、focus 光暈）
   ============================================================ */
.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-900);
}
.field-label .opt-tag { font-weight: 400; color: var(--ink-400); margin-left: 4px; }

.field {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--ink-300);
  border-radius: 8px;
  background: #fff;
  font-size: 15px;
  color: var(--ink-900);
  transition: border-color .15s, box-shadow .15s;
}
.field::placeholder { color: var(--ink-400); }
.field:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 15%, transparent);
}
.field[aria-invalid="true"] { border-color: var(--danger-600); }
.field[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger-600) 15%, transparent);
}
.field:disabled, .field[readonly] { background: var(--ink-50); color: var(--ink-500); }
textarea.field { height: auto; min-height: 88px; padding: 12px 16px; line-height: 1.6; resize: vertical; }

/* select 自訂箭頭（不用 data URI，顏色跟著主題變數走） */
.select-wrap { position: relative; }
.select-wrap::after {
  content: "";
  position: absolute;
  right: 18px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--ink-400);
  border-bottom: 2px solid var(--ink-400);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.select-wrap select.field { appearance: none; -webkit-appearance: none; padding-right: 44px; }

.field-hint  { margin-top: 6px; font-size: 13px; color: var(--ink-400); }
.field-error { margin-top: 6px; font-size: 13px; color: var(--danger-700); }

/* 單選卡片（配送、付款、發票、購買方式） */
.choice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--ink-300);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.choice:hover { border-color: var(--ink-900); }
.choice:has(input:checked) { border-color: var(--brand-500); background: var(--brand-50); }
.choice:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.choice:has(input:disabled):hover { border-color: var(--ink-300); }
.choice input[type="radio"], .choice input[type="checkbox"] {
  width: 16px; height: 16px; margin-top: 3px; flex-shrink: 0; accent-color: var(--brand-500);
}
.choice:has(input:focus-visible) { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 20%, transparent); }
.choice.items-center input[type="radio"], .choice.items-center input[type="checkbox"] { margin-top: 0; }

/* 規格選項按鈕（口味等），選中狀態由 aria-checked 控制 */
.opt {
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--ink-300);
  border-radius: 6px;
  background: #fff;
  font-size: 15px;
  color: var(--ink-700);
  transition: border-color .15s, background-color .15s;
}
.opt:hover { border-color: var(--ink-900); }
.opt[aria-checked="true"] {
  border-color: var(--brand-500);
  background: var(--brand-50);
  color: var(--brand-700);
  font-weight: 700;
}
.opt:disabled { border-color: var(--ink-200); color: var(--ink-300); cursor: not-allowed; }

/* 提示框：四邊細框 + 淡底（手冊 4.2.1，不用左側粗色條） */
.notice {
  border: 1px solid var(--brand-200);
  background: var(--brand-50);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--brand-900);
}

@media (prefers-reduced-motion: reduce) {
  .rise, .reveal { animation: none; transition: none; opacity: 1; transform: none; }
  #toast { transition: none; }
  .rail { scroll-behavior: auto; }
  html { scroll-behavior: auto; }
}
