/* public/products/style.css — P3 สินค้า (ยาง + แม็ค)
   ใช้โทเคนจาก /shared/tokens.css ล้วน (ห้ามเขียนค่าสี/ระยะห่างดิบ — design/00-direction.md §2.1)
   ต้นแบบการ์ด "ไม่มีรูป/ไม่มีราคา" มาจาก design/00-direction.md §4.3 (การ์ดสินค้าเด่นหน้าแรก) —
   P3 เองไม่มีสเปกละเอียดใน design/01-pages.md (designer เว้นไว้ทำรอบสุดท้ายตาม §1) จึงขยายจากต้นแบบนั้น
   ⚠️ ไม่เอาสไตล์การ์ดนี้ไปรวมกับ shared/ — คงซ้ำกับของ P1 ไว้ตั้งใจ (P1 กำลังทำคู่ขนานอยู่คนละไฟล์) */

/* ตารางสินค้ากว้างได้ถึง 1080px (design/00-direction.md §4.1) — กว้างกว่า .container ทั่วไป (720px) */
.container--wide { max-width: 1080px; }

.page-intro {
  color: var(--on-surface-2);
  margin-top: var(--sp-2);
  margin-bottom: var(--sp-5);
}

.section-heading {
  font-size: var(--fs-h2);
  font-weight: 700;
  margin-top: var(--sp-7);
  margin-bottom: var(--sp-3);
}

/* ---------- แท็บ ยาง/แม็ค ---------- */
.tabs {
  display: flex;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
  border-bottom: 1px solid var(--line);
}
.tab-btn {
  min-height: var(--tap-min);
  padding: 0 var(--sp-4);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--on-surface-2);
  font-size: var(--fs-btn);
  font-weight: 600;
  cursor: pointer;
}
.tab-btn:active { background: var(--surface-2); }
.tab-btn[aria-selected="true"] {
  color: var(--on-surface);
  border-bottom-color: var(--accent);
  font-weight: 700;
}

/* ---------- กล่องค้นหา ---------- */
.search-box { margin-bottom: var(--sp-5); }
.search-box__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: flex-end;
  margin-top: var(--sp-3);
}
.search-box__row .field { flex: 1 1 200px; }
.search-box__row .field--grow { flex: 2 1 240px; }
.search-box__result {
  margin-top: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.search-box__result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: var(--tap-min);
}

/* ---------- ช่องกรอก/select ทั่วไปในหน้านี้ (เหมือนฟอร์มหน้าอื่น) ---------- */
.field { display: flex; flex-direction: column; gap: var(--sp-1); }
.field label { font-size: var(--fs-small); font-weight: 500; }
.field select,
.field input {
  height: var(--btn-h);
  padding: 0 var(--sp-3);
  font-size: 18px;
  font-family: inherit;
  background: var(--surface-3);
  color: var(--on-surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}
.field select:disabled { color: var(--on-surface-3); }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: flex-end;
  margin-top: var(--sp-4);
}
.inline-form .field--grow { flex: 1 1 220px; }
.inline-form button { flex: none; }

/* ---------- โครงรายการตอนกำลังโหลด (skeleton) ---------- */
.product-skeleton__card {
  height: 220px;
  border-radius: var(--radius);
  background: var(--surface-2);
  margin-bottom: var(--sp-3);
}

/* ---------- ตารางสินค้า ---------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--sp-3);
  /* ⚠️ แก้ 2026-07-31 (QA เว็บจริง): ค่าเริ่มต้นของ align-items คือ stretch — พอการ์ดหนึ่งใบกางออก
     (<details open>) สูงขึ้นมาก การ์ดใบอื่นในแถวเดียวกัน (ยังไม่ได้กาง) จะถูกยืดให้สูงเท่ากันไปด้วย
     เหลือพื้นที่ว่างเปล่าสีพื้นการ์ดด้านล่างเนื้อหาจริง หน้าตาเหมือนกล่องดำว่างเปล่า 3 กล่อง ทำให้ดูเหมือน
     หน้าพัง — align-items: start ให้แต่ละการ์ดสูงเท่าเนื้อหาของตัวเองเสมอ ไม่ถูกยืดตามเพื่อนบ้านในแถว */
  align-items: start;
}

/* ---------- การ์ดสินค้า — <details>/<summary> (design/00-direction.md §4.1) ---------- */
.product-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.product-card__summary {
  list-style: none;
  cursor: pointer;
  padding: var(--sp-3);
  position: relative;
}
.product-card__summary::-webkit-details-marker { display: none; }
.product-card__summary::marker { content: ""; }
/* ตัวบอกกาง/หุบ — ลูกศรมุมขวาบน หมุนเมื่อกางออก */
.product-card__summary::after {
  content: "";
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
}
.product-card__summary::before {
  content: "";
  position: absolute;
  top: calc(var(--sp-3) + 9px);
  right: calc(var(--sp-3) + 8px);
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--on-surface-2);
  border-bottom: 2px solid var(--on-surface-2);
  transform: rotate(45deg);
  transition: transform 150ms ease;
  z-index: 1;
}
.product-card[open] > .product-card__summary::before { transform: rotate(-135deg); }
.product-card__summary:active { background: var(--surface-3); }

/* กรอบรูป 4:3 (design/00-direction.md §4.4) — พื้น --surface-photo ทั้งมีรูปและไม่มีรูป */
.product-card__frame {
  aspect-ratio: 4 / 3;
  background: var(--surface-photo);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: var(--sp-3);
}
.product-card__photo { width: 100%; height: 100%; object-fit: cover; object-position: center; }
.product-card__frame-text {
  font-size: var(--fs-h2);
  font-weight: 800;
  color: var(--on-surface-3);
  font-variant-numeric: tabular-nums;
  padding-inline: var(--sp-2);
  text-align: center;
}

.product-card__detail { color: var(--on-surface-2); font-size: var(--fs-small); margin-top: var(--sp-1); }
.product-card__price { color: var(--accent); font-size: var(--fs-price); font-weight: 700; margin-top: var(--sp-2); }
.product-card__summary .fine-print { margin-top: var(--sp-1); }

.badge {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 var(--sp-2);
  border-radius: var(--radius-sm);
  font-size: var(--fs-small);
  font-weight: 600;
  margin-top: var(--sp-2);
}
.badge--secondhand {
  background: var(--surface-3);
  color: var(--on-surface);
  border: 1px solid var(--line-strong);
}

/* ---------- ส่วนที่กางออก ---------- */
.product-card__expanded {
  padding: 0 var(--sp-3) var(--sp-3);
  border-top: 1px solid var(--line);
  padding-top: var(--sp-3);
}
.product-card__gallery {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  margin-bottom: var(--sp-3);
}
.product-card__gallery-photo {
  width: 120px;
  height: 90px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  flex: none;
}
.product-card__spec {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-1) var(--sp-3);
  margin: 0 0 var(--sp-3);
  font-size: var(--fs-small);
}
.product-card__spec dt { color: var(--on-surface-2); }
.product-card__spec dd { margin: 0; }

/* POLISH 5 (แก้ตามรีวิว 2026-07-31): เดิม flex แถวเดียวมี flex-wrap ทำให้ปุ่มโทรของ site-chrome.js
   (มีข้อความ "· กดเพื่อคัดลอก" ต่อท้ายเบอร์) ถูกบีบแคบในกริด 4 คอลัมน์บนเดสก์ท็อป ตัวหนังสือเลยตัดขึ้นบรรทัด
   ใหม่ทีละพยางค์ (ดูพัง ไม่ใช่แค่ไม่เรียบร้อย) — เปลี่ยนเป็นเรียงคอลัมน์แนวตั้งแทน ให้ทุกปุ่ม/ฟอร์มได้ความกว้าง
   เต็มการ์ดเสมอไม่ว่าจอกว้างแค่ไหน (ไม่ต้องแก้ shared/site-chrome.js หรือ shared/chrome.css เลย) */
.product-card__actions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.product-card__notify button { width: 100%; }

/* POLISH 5 ต่อ (แก้ตามรีวิว 2026-07-31): flex-direction: column ข้างบนทำให้ปุ่มโทรได้ความกว้างเต็มการ์ดแล้ว
   แต่ในกริดเดสก์ท็อป 4 คอลัมน์การ์ดยังแคบอยู่ดี (~220-280px) ไม่พอให้ "📞 โทร 061-956-4259 · กดเพื่อคัดลอก"
   อยู่บรรทัดเดียว — ปุ่มนี้มาจาก shared/site-chrome.js buildCallButton() (ไฟล์ที่ห้ามแก้) ซึ่งไม่ได้ตั้ง
   white-space: nowrap ไว้ที่ span ย่อย ทำให้ข้อความ "· กดเพื่อคัดลอก" ตัดขึ้นบรรทัดใหม่ทีละพยางค์เมื่อบีบแคบ
   (§3.4.6 ห้ามตัดวลีสั้นๆ กลางคำ) — override เฉพาะจุดที่ใช้ในการ์ดนี้ด้วย selector ที่เจาะจงกว่า แทนการแก้ไฟล์
   shared/: ให้แต่ละ span ห่อเป็นวลีทั้งชิ้น แล้วให้แถวขึ้นบรรทัดใหม่เป็นวลีแทนตัดกลางคำ */
.product-card__actions .call-btn {
  flex-wrap: wrap;
  height: auto;
  min-height: var(--btn-h);
  padding-block: var(--sp-2);
}
.product-card__actions .call-btn__number,
.product-card__actions .call-btn__hint {
  white-space: nowrap;
}
