/* ========== 基礎重置 ========== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body{
  margin:0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans TC", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align:center;                 /* 全站置中 */
}
img{ display:block; max-width:100%; margin-inline:auto; }
a{ color: inherit; text-decoration: none; }

/* ========== 柔和主題色 ========== */
:root{
  --bg:#fbfbfa;             /* 更柔的米白 */
  --card:#ffffff;           /* 卡片 */
  --text:#1f2937;           /* 主文字深灰 */
  --muted:#6b7280;          /* 次文字 */
  --primary:#9bd4be;        /* 柔薄荷綠 (CTA) */
  --primary-hover:#82c9b0;  /* hover */
  --ring:rgba(155,212,190,.35);
  --border:#eeeeee;
  --shadow:0 8px 24px rgba(16,24,40,.06);
  --radius:14px;
}

/* 可重複使用的容器 */
.container{ width:100%; max-width:1200px; padding:0 16px; margin:0 auto; }

/* ========== 導覽列（含手機漢堡） ========== */
.navbar{
  position:sticky; top:0; z-index:20;
  background:var(--card);
  border-bottom:1px solid var(--border);
  box-shadow:0 2px 12px rgba(16,24,40,.04);
}
.navbar-inner{
  display:flex; align-items:center; justify-content:center; /* 導覽置中 */
  gap:16px; height:64px;
}
.logo a{ font-weight:700; letter-spacing:.2px; }

.nav-links{ display:flex; gap:14px; align-items:center; justify-content:center; }
.nav-links a{ padding:8px 10px; border-radius:10px; }
.nav-links a:hover{ background:#f3f4f6; }
.cart-btn{ font-weight:700; }

/* 漢堡按鈕（手機） */
.nav-toggle{ display:none; cursor:pointer; border:0; background:transparent; padding:8px; border-radius:10px; }
.nav-toggle:focus{ outline:2px solid var(--ring); }

@media (max-width:960px){
  .nav-toggle{ display:block; }
  .nav-links{
    position:absolute; left:0; right:0; top:64px;
    display:none; flex-direction:column; gap:0;
    background:var(--card); border-bottom:1px solid var(--border);
  }
  .nav-links a{ padding:14px 20px; border-radius:0; }
  .nav-links.open{ display:flex; }
}

/* ========== Hero（大圖 Banner + 文字覆蓋） ========== */
.hero-banner{ position:relative; }
.hero-banner img{
  width:100%;
  height:clamp(240px, 36vw, 420px);
  object-fit:cover;
  border-bottom:1px solid var(--border);
}
.hero-text{
  position:absolute; inset:0;
  display:grid; place-items:center;        /* 讓文字區塊在中央 */
  padding:0 20px;
  text-align:center;                        /* 文字置中 */
}
.hero-text h1{
  font-size:clamp(28px, 5vw, 40px);
  color:#111827;
  text-shadow:0 2px 12px rgba(0,0,0,.18);
  margin:0 0 8px;
}
.hero-text p{
  color:#f3f4f6;
  text-shadow:0 2px 12px rgba(0,0,0,.25);
  margin:0 0 12px;
}
.btn{
  display:inline-block;
  background:var(--primary); color:#fff;
  padding:12px 18px; border-radius:12px;
  box-shadow:var(--shadow);
  transition:transform .06s ease, background .15s ease;
}
.btn:hover{ background:var(--primary-hover); transform:translateY(-1px); }
.btn:active{ transform:translateY(0); }

/* ========== 分類卡片（展示牆） ========== */
.section{ padding:40px 0; }

/* 兩個 class 皆可用（相容舊的 .cat-grid） */
.category-grid, .cat-grid{
  display:grid; gap:20px; justify-items:center;       /* 每格內容置中 */
  grid-template-columns:repeat(3, minmax(0,1fr));     /* 手機 3 欄 */
}
@media (max-width:520px){
  .category-grid, .cat-grid{ grid-template-columns:repeat(2, minmax(0,1fr)); } /* 極小螢幕 2 欄 */
}
@media (min-width:768px){
  .category-grid, .cat-grid{ grid-template-columns:repeat(4, minmax(0,1fr)); }
}
@media (min-width:1024px){
  .category-grid, .cat-grid{ grid-template-columns:repeat(6, minmax(0,1fr)); }
}
@media (min-width:1280px){
  .category-grid, .cat-grid{ grid-template-columns:repeat(8, minmax(0,1fr)); } /* 桌機 8 欄 */
}

.cat-card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  overflow:hidden;
  box-shadow:var(--shadow);
  transition:transform .12s ease, box-shadow .12s ease;
  text-align:center;                                    /* 卡片內文置中 */
}
.cat-card:hover{ transform:translateY(-2px); box-shadow:0 10px 28px rgba(16,24,40,.08); }
.cat-card a{ display:block; }
.cat-card img{ width:100%; height:210px; object-fit:cover; }
.cat-card span{
  display:block;
  padding:10px 12px 12px;
  font-weight:600;
  font-size:14px;
  color:var(--text);
}

/* ========== 商品網格（category / products） ========== */
.product-grid{
  display:grid; gap:16px; justify-items:center;        /* 置中 */
  grid-template-columns:repeat(3, minmax(0,1fr));      /* 手機 3 欄 */
}
@media (max-width:520px){ .product-grid{ grid-template-columns:repeat(2, minmax(0,1fr)); } }
@media (min-width:768px){ .product-grid{ grid-template-columns:repeat(4, minmax(0,1fr)); } }
@media (min-width:1024px){ .product-grid{ grid-template-columns:repeat(6, minmax(0,1fr)); } }
@media (min-width:1280px){ .product-grid{ grid-template-columns:repeat(8, minmax(0,1fr)); } }

.product-card{
  background:var(--card); border:1px solid var(--border); border-radius:var(--radius);
  box-shadow:var(--shadow); overflow:hidden; display:flex; flex-direction:column;
  text-align:center;
}
.product-card img{ width:100%; aspect-ratio:1/1; object-fit:cover; }
.product-card .p-body{ padding:10px 12px; }
.product-card .title{ font-size:14px; line-height:1.4; margin:0 0 6px; color:var(--text); }
.price{ font-weight:700; }
.action-row{ display:flex; gap:8px; padding:10px 12px 14px; }
.action-row .btn{ width:100%; text-align:center; padding:10px 12px; }

/* ========== 表單（若有需要可以個別改回左對齊） ========== */
input[type="text"], input[type="search"], select{
  width:100%; padding:12px 14px; border:1px solid var(--border); border-radius:12px; background:#fff; color:var(--text);
  text-align:left;             /* 表單欄位維持左對齊，較好輸入 */
}
input:focus, select:focus{ outline:2px solid var(--ring); border-color:transparent; }

/* ========== 頁尾 ========== */
footer{ margin-top:40px; background:var(--card); border-top:1px solid var(--border); }
footer .container{ padding:18px 0; color:var(--muted); font-size:14px; }

/* Banner 無圖時的降級樣式 */
.hero-banner.no-image{
  min-height: clamp(240px, 36vw, 420px);
  background: linear-gradient(180deg,#ffffff 0%, #fbfbfa 100%);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.hero-banner.no-image .hero-text{
  position: absolute; inset: 0;
  display: grid; place-items: center;
  text-align: center;
}

/* === 大項圖卡：桌機 4 欄 / 手機 2 欄，整組置中 === */
.category-grid.grid-4x2,
.cat-grid.grid-4x2{
  display: grid;
  gap: 24px;
  /* 先用 2 欄（手機） */
  grid-template-columns: repeat(2, minmax(220px, 280px));
  /* 讓整個網格在容器內置中（當欄寬不是 100% 時生效） */
  justify-content: center;
  /* 每個格子內的卡片也置中 */
  justify-items: center;
}

/* ≥ 992px（桌機）改成 4 欄 */
@media (min-width: 992px){
  .category-grid.grid-4x2,
  .cat-grid.grid-4x2{
    grid-template-columns: repeat(4, minmax(220px, 280px));
  }
}

/* 卡片本身避免被拉得太寬，維持視覺一致 */
.grid-4x2 .cat-card{
  width: 100%;
  max-width: 280px;
  text-align: center;
}

/* 圖片高度一致、置中裁切 */
.grid-4x2 .cat-card img{
  width: 100%;
  height: 210px;
  object-fit: cover;
}

/* === 修正手機溢出：大項卡片桌機4 / 手機2，自適應不溢出 === */
.category-grid.grid-4x2,
.cat-grid.grid-4x2{
  display: grid;
  gap: 16px;
  /* 手機：2 欄，欄寬自適應整體不超出 */
  grid-template-columns: 1fr 1fr;
  justify-content: center;   /* 整組置中 */
  justify-items: center;     /* 每格內容置中 */
}

@media (min-width: 992px){
  /* 桌機：4 欄 */
  .category-grid.grid-4x2,
  .cat-grid.grid-4x2{
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
  }
}

/* 卡片寬度交給格線，不再強制 280px，避免擠出螢幕 */
.grid-4x2 .cat-card{
  width: 100%;
  max-width: 100%;
  text-align: center;
}

/* 圖片用比例控制，避免固定高度在窄螢幕變形或撐寬 */
.grid-4x2 .cat-card img{
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;   /* 你也可以改成 1 / 1 看起來更方 */
  object-fit: cover;
  display: block;
}

/* 手機邊距略縮，避免總寬被 padding 擠破 */
@media (max-width: 480px){
  .container{ padding-left: 12px; padding-right: 12px; }
}

/* 商品網格 */
.product-grid{
  display:grid; gap:16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));   /* mobile: 3 */
}
@media (max-width:380px){
  .product-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width:768px){
  .product-grid{ grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width:1024px){
  .product-grid{ grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (min-width:1280px){
  .product-grid{ grid-template-columns: repeat(8, minmax(0, 1fr)); }
}

