/* Layout เดิมที่คุณต้องการ */
.youtube-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px; /* เพิ่มขึ้นนิดหน่อยเพื่อให้ดูไม่เบียดเกินไป */
  margin: 5px 0;
}

.youtube-card {
  background: var(--main-darker);
  border-radius: 5px; /* เพิ่มเป็น 12px เพื่อความทันสมัย */
  overflow: hidden;
  border: 1px solid #111;
  /* เทคนิคช่วยให้ overflow: hidden ทำงานเนียนขึ้น */
  isolation: isolate; 
  backface-visibility: hidden;
  transform: translateZ(0);
}

.youtube-thumbnail {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000;
  border-radius: 4px 4px 0 0; 
}

.youtube-thumbnail img {
  width: 100%; /* ขยาย 1% เพื่อลดรอยต่อสีขาวที่ขอบ */
  height: 100%;
  object-fit: cover;
  display: block;
}

.youtube-info {
  padding: 12px; /* เพิ่มพื้นที่หายใจให้เนื้อหา */
  background: var(--main-darker);
}

.youtube-title-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.youtube-title {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.4;
  margin: 0;
  /* color: #add8e6;  */
  cursor: pointer;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ปรับปุ่ม Play ให้ดูเนียนขึ้น */
.play-button-overlay {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 0, 0, 0.9);
  color: white;
  padding: 12px 22px;
  border-radius: 5px;
  font-size: 1.6rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ปุ่ม External Link ปรับให้เข้ากับโทนเว็บ */
.yt-external-link {
  text-decoration: none;
  font-size: 0.8rem;
  padding: 4px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  transition: 0.2s;
  flex-shrink: 0;
}

.yt-external-link:hover {
  background: #ff0000;
  border-color: #ff0000;
}

.youtube-date {
  font-size: 0.8rem;
  color: #88acc1;
  display: flex;
  align-items: center;
  gap: 5px;
}

.yt-external-link {
  text-decoration: none;
  font-size: 0.9rem;
  padding: 2px 5px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  transition: 0.2s;
}

.yt-external-link:hover {
  background: #ff0000;
  color: #fff;
  border-color: #ff0000;
}

.youtube-thumbnail {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9; /* บังคับสัดส่วนวิดีโอมาตรฐาน */
  overflow: hidden;     /* ตัดขอบดำที่เกินออกมาทิ้ง */
  background: none;     /* ลบสีพื้นหลังดำออก */
}
.youtube-thumbnail img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover; 
}

.play-button-overlay {
  position: absolute;
  top: 50%; 
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 0, 0, 0.85);
  color: white;
  padding: 5px 20px;
  border-radius: 8px;
  font-size: 1.5rem;
  transition: 0.3s;
  cursor: pointer;
}
.youtube-thumbnail:hover .play-button-overlay {
  transform: translate(-50%, -50%) scale(1.1);
  background: #ff0000;
}









/* --- ระบบ Modal (Pop-up) --- */
.video-modal {
  display: none; /* ซ่อนไว้ */
  position: fixed;
  z-index: 9999;
  left: 0; top: 0;
  width: 100%; height: 100%;
  background-color: rgba(0,0,0,0.9);
  backdrop-filter: blur(5px);
}

.modal-content {
  position: relative;
  margin: auto;
  top: 50%;
  transform: translateY(-50%);
  width: 80%;
  max-width: 800px;
}

.video-container {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
}

.video-container iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

.close-btn {
  position: absolute;
  top: -40px; right: 0;
  color: #fff;
  font-size: 35px;
  font-weight: bold;
  cursor: pointer;
}

/* Responsive เหมือนเดิม */
@media (max-width: 900px) { 
  .youtube-grid { 
    grid-template-columns: repeat(2, 1fr); 
  } 
}
@media (max-width: 600px) {
  .youtube-grid { 
    grid-template-columns: 1fr; 
  } 
  .modal-content { 
    width: 95%; 
  } 
}