/* แถวหมวดประกัน: โหลดหลัง CSS ของหน้าและ tci-shared.css
   คุม overflow เอง ไม่ใช้ร่วมกับ tci-shared-scroll-row เพราะจอกว้างต้อง wrap. */

/* Scoped reset ต้องอยู่ก่อนกฎของ component. */
.tci-shared-category-row,
.tci-shared-category-row * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.tci-shared-category-row :where(a) {
  text-decoration: none;
  color: inherit;
}

.tci-shared-category-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  font-family: var(--tci-font-body);
}

.tci-shared-category-link {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  /* กันข้อความล้นก้นการ์ดตอนคอลัมน์ถูกบีบแคบ (เช่น 6 คอลัมน์ที่ desktop แคบสุด
     ~768px) ซึ่ง aspect-ratio จะทำให้สูง = กว้าง และแคบกว่าที่ไอคอน 64/72px คงที่
     + ป้ายข้อความ 2 บรรทัดต้องการจริง min-height เป็นตัวกันขั้นต่ำไว้. */
  min-height: 132px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 400;
  color: var(--tci-dark);
  background: #ffffff;
  border: 1px solid #f4f4f4;
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.06);
  padding: 10px 6px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.tci-shared-category-link:hover {
  /* คงสีเดิม — กัน a:hover ของ Bootstrap บนเว็บจริง (สีน้ำเงิน) ทับ */
  color: var(--tci-dark);
  transform: translateY(-4px);
  border-color: var(--tci-orange);
  box-shadow: 0 12px 24px rgba(242, 110, 35, 0.25);
}

/* ป้าย "แนะนำ" ริบบิ้นเฉียงมุมซ้ายบน: wrap ครอบตัด overflow ไม่ให้ล้นการ์ด
   ส่วนตัวป้ายหมุน -45deg พาดมุมแบบริบบิ้นมุมการ์ดทั่วไป. */
.tci-shared-category-badge-wrap {
  position: absolute;
  top: 0;
  left: 0;
  width: 56px;
  height: 56px;
  overflow: hidden;
  border-radius: 12px 0 0 0;
  z-index: 1;
  pointer-events: none;
}

.tci-shared-category-badge {
  position: absolute;
  top: 11px;
  left: -21px;
  width: 90px;
  transform: rotate(-45deg);
  background: var(--tci-orange);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  padding: 4px 0;
}

.tci-shared-category-icon {
  display: block;
  width: var(--tci-category-icon-size, 50%);
  height: var(--tci-category-icon-size, 50%);
  min-width: var(--tci-category-icon-size, 50%);
  border-radius: 50%;
  object-fit: contain;
}

/* เดิม breakpoint นี้เริ่มที่ 768px ทำให้ iPad (portrait ~768-1024) ได้ grid
   6 คอลัมน์แถวเดียวแบบ desktop ไปด้วย เลื่อนขึ้นมาเป็น 1025px ให้ iPad portrait
   ยังคงเห็นแบบมือถือ (2 คอลัมน์ 3 แถว) เหมือนเดิม เฉพาะจอ desktop จริงๆ
   (>=1025px) เท่านั้นที่สลับเป็น 6 คอลัมน์แถวเดียว. */
@media (min-width: 1025px) {

  .tci-shared-category-row {
    grid-template-columns: repeat(6, 1fr);
    gap: var(--tci-category-row-gap, 16px);
  }

  .tci-shared-category-link {
    max-width: 160px;
    min-height: 156px;
    justify-self: center;
    padding: 12px 8px;
    font-size: 17px;
  }

}

@media (max-width: 1024.98px) {
  .tci-shared-category-link { font-size: 13px; }
}

/* iPad (768-1024): 3 คอลัมน์ต่อแถว (6 การ์ด = 2 แถว บน-ล่าง) แทนที่จะใช้ 2
   คอลัมน์แบบมือถือจริง (ซึ่งจะกลายเป็น 3 แถว) — มือถือจริง (<768) ยังคงเดิม. */
@media (min-width: 768px) and (max-width: 1024.98px) {
  .tci-shared-category-row {
    grid-template-columns: repeat(3, 1fr);
  }
}
