/* =========================================================
   products.css — Product card, filter, product detail
   ========================================================= */

/* ---------- 1. Product grid & card ---------- */
.product-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

.product-card {
  display: flex; flex-direction: column;
  background: var(--warm-white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}
.product-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--sage-green); }

.product-card__media { position: relative; aspect-ratio: 1 / 1; overflow: hidden; background: var(--light-sage); }
.product-card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.product-card:hover .product-card__media img { transform: scale(1.05); }

.badge {
  position: absolute; top: 10px; left: 10px;
  background: var(--accent-orange); color: #fff;
  font-size: .72rem; font-weight: 500;
  padding: 4px 11px; border-radius: var(--radius-pill);
}
.badge--green { background: var(--primary-green); }
.badge--sage { background: var(--sage-green); color: var(--text); }

.product-card__body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.product-card__cat { font-size: .74rem; color: var(--primary-green); letter-spacing: .02em; }
.product-card__name { font-size: .97rem; font-weight: 500; line-height: 1.4; }
.product-card__name a:hover { color: var(--primary-green); }
.product-card__desc { font-size: .82rem; color: var(--muted); flex: 1; }
.price-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.price { font-size: 1.06rem; font-weight: 600; color: var(--text); }
.price--old { font-size: .84rem; font-weight: 300; color: var(--muted); text-decoration: line-through; }
.product-card__actions { display: flex; gap: 8px; margin-top: 12px; }
.product-card__actions .btn { flex: 1; padding-inline: 10px; white-space: nowrap; }
.product-card__actions .btn--icon {
  flex: 0 0 auto; width: 42px; height: 42px; padding: 0;
  display: grid; place-items: center; border-radius: 50%;
}
.product-card__actions .btn--icon svg { width: 19px; height: 19px; stroke: currentColor; }

/* ---------- 2. Featured (sage) section variant ---------- */
.section--sage .product-card { background: var(--warm-white); border-color: transparent; }

/* ---------- 3. Toolbar (search / sort / count) ---------- */
.shop-layout { display: grid; gap: 24px; align-items: start; }
/* ตัวควบคุมในแถบเครื่องมือสูงเท่ากันหมด */
.shop-toolbar { --control-h: 42px; }
.shop-toolbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  justify-content: space-between; margin-bottom: 18px;
}
.shop-toolbar__left { display: flex; gap: 10px; align-items: center; flex: 1 1 260px; min-width: 0; }
.field {
  display: flex; align-items: center; gap: 8px;
  background: var(--cream); border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  /* ต้องหดได้ ไม่งั้นมันจะไปบีบปุ่มตัวกรองจนข้อความตกบรรทัด */
  flex: 1 1 auto; min-width: 0; width: auto;
  /* ความสูงคงที่ ไม่ให้ line-height 1.7 ที่สืบทอดจาก body ดันให้อ้วน */
  height: var(--control-h, 42px); padding: 0 16px;
}
.field svg { width: 18px; height: 18px; stroke: var(--muted); flex-shrink: 0; }
.field input { border: 0; background: none; outline: none; width: 100%; font-size: .92rem; line-height: 1.2; }
.select {
  border: 1px solid var(--line); background: var(--cream);
  border-radius: var(--radius-pill);
  height: var(--control-h, 42px); padding: 0 16px; line-height: 1.2;
  font-size: .9rem; cursor: pointer;
}
.result-count { font-size: .86rem; color: var(--muted); }
/* ปุ่มตัวกรองต้องไม่ถูกบีบและไม่ตัดคำ ไม่งั้น "ตัวกรอง" จะตกเป็น 2 บรรทัดแล้วปุ่มอ้วนขึ้น */
.filter-open {
  display: none; flex-shrink: 0; white-space: nowrap;
  height: var(--control-h, 42px); padding: 0 18px;
}

/* ---------- 4. Filter sidebar ---------- */
.filters {
  background: var(--warm-white); border: 1px solid var(--line);
  border-radius: var(--radius-md); padding: 22px;
  display: grid; gap: 22px; align-content: start;
}
.filters__head { display: flex; align-items: center; justify-content: space-between; }
.filters__head h2 { font-size: 1.05rem; }
.filter-group h3 { font-size: .92rem; margin-bottom: 10px; }
.filter-group ul { display: grid; gap: 8px; }
.check { display: flex; align-items: center; gap: 10px; font-size: .88rem; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--primary-green); cursor: pointer; flex-shrink: 0; }
.filters-close { display: none; }
.clear-filters { font-size: .82rem; color: var(--accent-orange); text-decoration: underline; }

/* ---------- 5. Empty state ---------- */
.no-result {
  grid-column: 1 / -1; text-align: center; padding: 56px 20px;
  border: 1px dashed var(--line); border-radius: var(--radius-md); color: var(--muted);
}
.no-result h3 { font-size: 1.1rem; color: var(--text); margin-bottom: 8px; }

/* ---------- 6. Product detail ---------- */
.pdp { display: grid; gap: 32px; align-items: start; }
.pdp__gallery { display: grid; gap: 12px; }
.pdp__main-img {
  width: 100%; aspect-ratio: 1 / 1; object-fit: cover;
  border-radius: var(--radius-lg); background: var(--light-sage);
}
.pdp__thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.pdp__thumb {
  border-radius: var(--radius-sm); overflow: hidden; border: 2px solid transparent;
  aspect-ratio: 1 / 1; background: var(--light-sage); padding: 0;
}
.pdp__thumb img { width: 100%; height: 100%; object-fit: cover; }
.pdp__thumb.is-active { border-color: var(--primary-green); }

.pdp__info h1 { font-size: clamp(1.5rem, 3.6vw, 2.1rem); margin-top: 8px; }
.pdp__rating { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); margin-top: 10px; }
.pdp__short { color: var(--muted); margin-top: 14px; }
/* ราคากับช่องจำนวนอยู่แถวแนวนอนเดียวกัน — ราคาชิดซ้าย ช่องจำนวนชิดขวา */
.pdp__pricerow {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-top: 18px;
}
.pdp__price { display: flex; align-items: baseline; gap: 12px; margin: 0; flex-wrap: wrap; }
.pdp__price .price { font-size: 1.75rem; color: var(--primary-green); }
.pdp__promo {
  background: var(--light-sage); border-radius: var(--radius-sm);
  padding: 12px 16px; font-size: .88rem; margin-top: 16px;
  display: flex; gap: 10px; align-items: flex-start;
}
.pdp__promo svg { width: 20px; height: 20px; stroke: var(--primary-green-dark); flex-shrink: 0; margin-top: 3px; }
.pdp__buy { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 22px; }
@media (max-width: 575px) {
  .pdp__buy .btn { flex: 1 1 100%; }
}
.pdp__pricerow .qty-box { flex-shrink: 0; }
.qty-box {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 5px 8px;
}
.qty-box button { width: 32px; height: 32px; border-radius: 50%; background: var(--light-sage); display: grid; place-items: center; }
.qty-box button:hover { background: var(--sage-green); color: #fff; }
.qty-box span { min-width: 32px; text-align: center; }
/* ข้อมูลสินค้า — จัดเป็นตารางสเปก ป้ายชิดซ้าย ค่าชิดขวา มีเส้นคั่นแต่ละแถว
   อ่านง่ายกว่าบรรทัดยาวต่อกันโดยเฉพาะบนมือถือ */
.pdp__meta {
  margin-top: 22px;
  display: grid;
  font-size: .88rem;
  background: var(--warm-white);
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 1px var(--line);
  padding: 2px 16px;
}
.pdp__meta p {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 11px 0;
  color: var(--text);
  text-align: right;
}
.pdp__meta p + p { box-shadow: inset 0 1px 0 var(--line); }
.pdp__meta strong {
  font-weight: 400; color: var(--muted-strong);
  flex-shrink: 0; text-align: left;
}
.pdp__meta a {
  color: var(--primary-green-dark);
  text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: rgba(71, 97, 78, .35);
}
.pdp__meta a:hover { text-decoration-color: currentColor; }

/* ---------- 7. Accordion ---------- */
.accordion { display: grid; gap: 10px; }
.acc-item { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--warm-white); overflow: hidden; }
.acc-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 18px; font-size: .96rem; font-weight: 500; text-align: left;
}
.acc-btn svg { width: 18px; height: 18px; stroke: var(--primary-green); transition: transform var(--t); flex-shrink: 0; }
.acc-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.acc-panel { padding: 0 18px 18px; font-size: .91rem; color: var(--muted); }
.acc-panel[hidden] { display: none; }
.acc-panel ul { display: grid; gap: 6px; }
.acc-panel li { padding-left: 16px; position: relative; }
.acc-panel li::before {
  content: ""; position: absolute; left: 0; top: 11px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--sage-green);
}

/* ---------- 8. Disclaimer ---------- */
.disclaimer {
  background: var(--cream); border-radius: var(--radius-md);
  padding: 18px 20px; font-size: .84rem; color: var(--muted); margin-top: 24px;
}

/* ปุ่มโหลดสินค้าเพิ่ม */
/* display: flex ของ .load-more ทับกฎ [hidden] ของเบราว์เซอร์ ต้องประกาศซ้ำเอง */
.load-more[hidden] { display: none; }
.load-more {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-top: 2.25rem;
}
.load-more__note {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

/* ปุ่มแชร์สินค้า */
.pdp__share {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
  padding: 0;
  background: none;
  border: 0;
  font: inherit;
  font-size: .88rem;
  color: var(--muted);
  cursor: pointer;
  transition: color var(--t);
}
.pdp__share:hover { color: var(--primary-green); }
.pdp__share svg { width: 17px; height: 17px; stroke: currentColor; fill: none; }

/* ปุ่มหัวใจ (รายการโปรด) บนการ์ดสินค้า */
.wish-btn {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  padding: 0;
  background: rgba(255, 253, 248, .92);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--t), border-color var(--t), transform var(--t);
}
.wish-btn svg { width: 18px; height: 18px; stroke: var(--muted); fill: none; transition: stroke var(--t), fill var(--t); }
.wish-btn:hover { transform: scale(1.08); border-color: var(--sage-green); }
.wish-btn:hover svg { stroke: var(--accent-orange); }
.wish-btn.is-active svg { stroke: var(--accent-orange); fill: var(--accent-orange); }

/* แถวปุ่มรอง (รายการโปรด + แชร์) ในหน้าสินค้า */
.pdp__extra { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; }
.pdp__extra .pdp__share { margin-top: 14px; }
.pdp__share.is-active { color: var(--accent-orange); }
.pdp__share.is-active svg { fill: currentColor; }

/* ---------- Coverflow สินค้าแนะนำ ---------- */
.cf { --cf-w: 310px; --cf-h: 470px; }
.cf__stage {
  position: relative;
  height: calc(var(--cf-h) + 56px);
  display: flex; align-items: center; justify-content: center;
  perspective: 1500px;
  /* ไม่คลิปที่นี่ การ์ดข้างจะได้ไม่โดนตัด — กันล้นจอที่ระดับ section แทน */
}
.cf__track { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; }

.cf__card {
  position: absolute; top: 50%; left: 50%;
  width: var(--cf-w); height: var(--cf-h);
  margin: calc(var(--cf-h) / -2) 0 0 calc(var(--cf-w) / -2);
  display: flex; flex-direction: column;
  padding: 12px 12px 0;
  background: linear-gradient(170deg, #fff 0%, var(--warm-white) 62%, var(--cream) 100%);
  border-radius: 26px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(32, 35, 31, .05), 0 10px 26px rgba(71, 97, 78, .10);
  transition: transform .55s cubic-bezier(.25,.8,.25,1), opacity .55s ease,
              box-shadow .45s ease, filter .45s ease;
}
/* เส้นขอบบางด้านในแทน border ปกติ ไม่กินพื้นที่และดูละเอียดกว่า */
.cf__card::after {
  content: ""; position: absolute; inset: 0;
  border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(32, 35, 31, .07);
}
/* ใบข้างเบลอเล็กน้อย ช่วยดันใบกลางให้เด้งออกมา */
.cf__card:not(.is-active) { filter: blur(1.4px) saturate(.85); }
.cf__card.is-active {
  cursor: default;
  box-shadow: 0 4px 12px rgba(71, 97, 78, .10), 0 26px 54px rgba(71, 97, 78, .22);
}

.cf__media {
  position: relative;
  flex: 1;
  border-radius: 18px;
  overflow: hidden;
  background: radial-gradient(125% 95% at 50% 0%, #fff 0%, #f2ece1 100%);
}
.cf__media img {
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 14px;
  /* เงาใต้โปสเตอร์ ทำให้รูปดูลอยเหมือนแผ่นพิมพ์วางอยู่ ไม่แบนติดพื้น */
  filter: drop-shadow(0 10px 16px rgba(32, 35, 31, .20));
  transition: transform .55s ease;
}
.cf__card.is-active:hover .cf__media img { transform: scale(1.05) translateY(-2px); }

.cf__tags { position: absolute; top: 12px; left: 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.cf__tag {
  font-size: .7rem; font-weight: 500;
  padding: 4px 11px; border-radius: var(--radius-pill);
  background: var(--accent-orange-deep); color: #fff;
  box-shadow: 0 2px 8px rgba(189, 84, 32, .3);
}
.cf__tag--sale { background: var(--primary-green-dark); box-shadow: 0 2px 8px rgba(71, 97, 78, .3); }

/* ปุ่มหัวใจแบบกระจกฝ้า ลอยบนรูปโดยไม่บังเนื้อหา */
.cf__wish {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 36px; height: 36px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .78);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(32, 35, 31, .12);
  cursor: pointer;
  transition: background var(--t), transform var(--t);
}
.cf__wish svg { width: 18px; height: 18px; stroke: var(--muted); fill: none; transition: stroke var(--t), fill var(--t); }
.cf__wish:hover { transform: scale(1.08); }
.cf__wish:hover svg { stroke: var(--accent-orange); }
.cf__wish.is-active svg { stroke: var(--accent-orange); fill: var(--accent-orange); }
.cf__wish:focus-visible { outline: 2px solid var(--primary-green); outline-offset: 2px; }

.cf__body { padding: 14px 8px 16px; }
/* ชิปหมวดหมู่ อ่านเป็นป้ายกำกับ ไม่ปนกับเนื้อความ */
.cf__cat {
  display: inline-block; margin: 0 0 8px;
  font-size: .68rem; font-weight: 500; letter-spacing: .06em;
  color: var(--primary-green-dark);
  background: var(--light-sage);
  padding: 3px 10px; border-radius: var(--radius-pill);
}
.cf__name {
  font-size: 1rem; font-weight: 500; line-height: 1.5; margin: 0;
  color: var(--text); text-wrap: balance;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cf__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 12px;
}
.cf__price { margin: 0; font-size: 1.3rem; font-weight: 600; color: var(--text); line-height: 1.2; }
.cf__price s { display: block; font-size: .78rem; font-weight: 300; color: var(--muted); }
/* CTA เป็นแคปซูลเขียวเข้ม อ่านชัดกว่าปุ่มส้มบนพื้นครีม และไม่แย่งซีนกับป้ายลดราคา */
.cf__go {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 7px;
  height: 42px; padding: 0 16px;
  background: var(--primary-green-dark); color: #fff;
  font-size: .85rem; font-weight: 500;
  border-radius: var(--radius-pill);
  transition: background var(--t), gap var(--t);
}
.cf__go svg { width: 16px; height: 16px; stroke: currentColor; fill: none; }
.cf__go:hover { background: var(--primary-green); gap: 11px; }
.cf__go:focus-visible { outline: 2px solid var(--primary-green); outline-offset: 2px; }

.cf__arrow {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 30;
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--warm-white);
  border: 1px solid var(--line); border-radius: 50%;
  color: var(--primary-green);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background var(--t), color var(--t), transform var(--t);
}
.cf__arrow svg { width: 22px; height: 22px; stroke: currentColor; fill: none; }
.cf__arrow:hover { background: var(--primary-green); color: #fff; }
.cf__arrow:focus-visible { outline: 2px solid var(--primary-green); outline-offset: 2px; }
.cf__arrow--prev { left: 8px; }
.cf__arrow--next { right: 8px; }

.cf__dots { display: flex; justify-content: center; gap: 4px; margin-top: 18px; }
.cf__dots button {
  /* พื้นที่แตะ 44px ตามเกณฑ์ แต่จุดที่มองเห็นยังเล็กเท่าเดิม */
  width: 21px; height: 44px; padding: 17.5px 6px;
  border: 0; background: transparent;
  cursor: pointer;
}
.cf__dots button::before {
  content: ""; display: block;
  width: 9px; height: 9px;
  border-radius: var(--radius-pill);
  background: var(--sage-green);
  transition: width var(--t), background var(--t);
}
.cf__dots button:hover::before { background: var(--primary-green); }
.cf__dots button.is-on { width: 38px; padding-inline: 6px; }
.cf__dots button.is-on::before { width: 26px; background: var(--primary-green); }
.cf__dots button:focus-visible { outline: 2px solid var(--primary-green); outline-offset: -12px; border-radius: var(--radius-pill); }

@media (max-width: 575px) {
  .cf { --cf-w: 250px; --cf-h: 430px; }
  .cf__foot { flex-direction: column; align-items: stretch; gap: 12px; }
  .cf__go { justify-content: center; }
}

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

/* ปุ่มแคปซูลขนาดใหญ่ ใช้นอกการ์ดได้ */
.cf__go--lg { height: 50px; padding: 0 24px; font-size: .95rem; }
