/* Layout and spacing for the service cards on Home and Our Services. */
.containers-services {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  justify-content: center;
  gap: 10px;
}

@media (min-width: 1025px) and (max-width: 1420px) {
  div.containers-services {
    display: grid;
    grid-template-columns: repeat(3, 0fr);
    gap: 10px;
    justify-items: center;
    align-items: center;
    row-gap: 50px;
    place-self: center;
  }

  div.containers-services > div {
    padding: 0 50px !important;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  div.containers-services {
    display: grid;
    grid-template-columns: repeat(3, 0fr);
    row-gap: 50px;
    justify-items: center;
    align-items: center;
    place-self: center;
  }

  div.containers-services > div {
    padding: 0 30px !important;
  }
}

@media (max-width: 768px) {
  div.containers-services > div {
    padding: 0 50px !important;
  }
}

@media (min-width: 375px) and (max-width: 768px) {
  div.containers-services {
    display: grid;
    grid-template-columns: repeat(2, 0fr);
    justify-items: center;
    align-items: center;
    place-self: center;
    gap: 0;
    row-gap: 50px;
  }
}

@media (max-width: 600px) {
  .box-wyn-pic {
    width: 115px !important;
    height: 170px !important;
  }

  div.containers-services > div {
    padding: 0 15px !important;
    width: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
}

@media (max-width: 375px) {
  div.containers-services {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    justify-items: center;
    align-items: center;
    gap: 0;
    row-gap: 50px;
    place-self: center;
  }

  div.containers-services > div {
    width: 170px;
  }
}

.services-custom-border {
  border-right: 3px solid rgb(218, 218, 218);
}

@media (min-width: 1024px) and (max-width: 1420px) {
  .services-custom-border {
    padding: 2rem !important;
  }
}

/* สำหรับหน้าจอที่มีขนาด ≤ 768px */
@media (max-width: 768px) {
  .services-custom-border {
    border: none;
  }
}

/* Desktop: services 5 + 4 (แถวล่างจัดกึ่งกลาง) พร้อมเส้นคั่นแนวตั้ง */
@media (min-width: 1025px) {
  /* ขยายเกิน container-lg (950px ที่ <1200px) ไม่ให้การ์ด 5 ใบล้นคอลัมน์ */
  div.layout-services {
    max-width: 1320px;
    padding: 0 2rem;
  }
  div.containers-services {
    width: 100%;
    grid-template-columns: repeat(10, minmax(0, 1fr));
    justify-items: stretch;
    gap: 3rem 0;
  }
  div.containers-services > .services-custom-border {
    grid-column: span 2;
    min-width: 0;
    padding: 0 1rem !important;
    border: 0;
    border-right: 3px solid rgb(218, 218, 218);
  }
  /* กรอบดำย่อตามคอลัมน์ได้ แต่ไม่เกินขนาดเดิม 185x270 */
  div.containers-services .box-wyn-pic {
    width: 100%;
    max-width: 185px;
    height: auto;
    aspect-ratio: 185 / 270;
  }
  div.containers-services > .services-custom-border:nth-child(5),
  div.containers-services > .services-custom-border:nth-child(9) {
    border-right-color: transparent; /* คงความกว้างเส้นไว้ ให้กรอบดำทุกใบขนาดเท่ากัน */
  }
  div.containers-services > .services-custom-border:nth-child(6) {
    grid-column: 2 / span 2;
  }
}

/* Tablet (3 คอลัมน์): เส้นคั่นเฉพาะระหว่างคอลัมน์ ไม่มีเส้นที่ใบสุดท้ายของแถว */
@media (min-width: 769px) and (max-width: 1024px) {
  div.containers-services > .services-custom-border {
    border: 0;
    border-right: 3px solid rgb(218, 218, 218);
  }
  div.containers-services > .services-custom-border:nth-child(3n),
  div.containers-services > .services-custom-border:last-child {
    border-right: 0;
  }
}

/* Mobile (2 คอลัมน์): เส้นคั่นเฉพาะใบซ้าย ใบสุดท้ายที่อยู่เดี่ยวไม่มีเส้น */
@media (max-width: 768px) {
  div.containers-services > .services-custom-border {
    border: 0;
    border-right: 3px solid rgb(218, 218, 218);
  }
  div.containers-services > .services-custom-border:nth-child(2n),
  div.containers-services > .services-custom-border:last-child {
    border-right: 0;
  }
  /* ใบที่ 9 อยู่เดี่ยว: จัดกึ่งกลางแถว */
  div.containers-services > .services-custom-border:last-child {
    grid-column: 1 / -1;
    justify-self: center;
  }
}
