/**
 * WT Video Popup Slider - Giao diện & Hiệu ứng
 * Chuyên gia Lập trình Frontend (UI/UX Developer) & WordPress Performance Engineer
 */

:root {
  --wt-primary-color: #ffffff;
  --wt-bg-card: #ffffff0a; /* Navy/Dark Slate */
  --wt-bg-hover: #1c2541;
  --wt-text-color: #ffffff;
  --wt-play-btn-size: 54px;
  --wt-transition-default: all 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
  --wt-hardware-acceleration: translate3d(0, 0, 0);
}

/* 1. Khung slider tổng thể bọc ngoài cùng */
.wt-video-slider-container {
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  position: relative;
}

/* 2. Thanh trượt chứa danh sách các thẻ - Desktop (> 1024px) */
.wt-video-slider-track {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  box-sizing: border-box;
  width: 100%;
  position: relative;
}

/* 3. Thẻ bài viết video */
.wt-video-card {
  background-color: var(--wt-bg-card);
  border-radius: 8px;
  border: 1px solid #ffffff1a;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  transition: var(--wt-transition-default);
  transform: var(--wt-hardware-acceleration);
  will-change: transform, box-shadow;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* Hiệu ứng hover cho toàn bộ thẻ */
@media (hover: hover) {
  .wt-video-card:hover {
    transform: translateY(-6px) scale(1.01);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
    background-color: var(--wt-bg-hover);
  }
}

/* Vùng bọc ảnh thumbnail và nút play */
.wt-video-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9; /* Khóa cứng tỷ lệ vàng 16:9 */
  overflow: hidden;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  transform: var(--wt-hardware-acceleration);
}

/* Thẻ ảnh đại diện */
.wt-video-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* Phủ kín, không móp ảnh */
  display: block;
  transition: var(--wt-transition-default);
  will-change: transform;
}

/* Phóng to ảnh nhẹ khi hover vào thẻ */
@media (hover: hover) {
  .wt-video-card:hover .wt-video-thumb-wrap img {
    transform: scale(1.06);
  }
}

/* Nút bấm phát video (hình tròn) */
.wt-video-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  width: var(--wt-play-btn-size);
  height: var(--wt-play-btn-size);
  background-color: var(--wt-primary-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  transition: var(--wt-transition-default);
  z-index: 10;
  will-change: transform;
}

/* Icon tam giác bên trong nút play */
.wt-video-play-btn svg {
  width: 16px;
  height: 18px;
  fill: var(--wt-bg-card); /* Màu xanh đen tối */
  margin-left: 3px; /* Căn chỉnh quang học tâm tam giác */
  transition: fill var(--wt-transition-default);
}

/* Hover thẻ bài viết -> Tự động phóng to nút tròn Play */
@media (hover: hover) {
  .wt-video-card:hover .wt-video-play-btn {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 8px 25px rgba(255, 255, 255, 0.35);
  }

  .wt-video-card:hover .wt-video-play-btn svg {
    fill: #000000;
  }
}

/* Tiêu đề chữ của thẻ */
.wt-video-card-title {
  color: var(--wt-text-color);
  text-transform: uppercase;
  font-size: 20px;
  font-weight: 700;
  text-align: left;
  padding: 20px 24px;
  margin: 0;
  line-height: 1.4;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 4. Giao diện Modal Popup Lightbox */
.wt-video-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85); /* Lớp nền màu đen mờ mượt mà */
  backdrop-filter: blur(8px); /* Blur mượt mà đẳng cấp */
  -webkit-backdrop-filter: blur(8px);
  z-index: 999999; /* Tầng trên cùng cực cao */
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  will-change: opacity;
}

/* Trạng thái hiển thị hoạt động */
.wt-video-modal-overlay.wt-active {
  opacity: 1;
  pointer-events: auto;
}

/* Vùng nội dung bên trong modal */
.wt-video-modal-content {
  position: relative;
  width: 90%;
  max-width: 960px;
  aspect-ratio: 16 / 9;
  transform: scale(0.9) translate3d(0, 0, 0);
  transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  will-change: transform;
}

.wt-video-modal-overlay.wt-active .wt-video-modal-content {
  transform: scale(1) translate3d(0, 0, 0);
}

/* Khung bọc iframe responsive */
.wt-video-iframe-responsive {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
}

/* Trình phát video gốc iframe */
.wt-video-iframe-responsive iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

/* Nút đóng khung video (Ký tự nhân ×) */
.wt-video-modal-close {
  position: absolute;
  top: -45px;
  right: 0;
  color: var(--wt-primary-color);
  font-size: 42px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  border: none;
  background: transparent;
  outline: none;
  padding: 0;
  display: inline-block;
  transition:
    transform 0.3s ease,
    color 0.3s ease;
  user-select: none;
  -webkit-user-select: none;
}

.wt-video-modal-close:hover {
  transform: rotate(90deg);
  color: #ff3b30; /* Highlight red/pink on close */
}

/* 5. Cấu trúc Responsive & Slider (HIỆU NĂNG PHẦN CỨNG CAO) */
@media (max-width: 1024px) {
  /* Ép buộc toàn bộ các thẻ nằm trên một hàng ngang duy nhất, cho phép vuốt */
  .wt-video-slider-track {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden; /* Ngăn cuộn dọc ngoài ý muốn gây gián đoạn */
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch; /* Cuộn mượt trên iOS */
    gap: 15px;
    padding: 0px 20px 12px 0px; /* Thêm padding trái phải và dưới cho thoáng */
    box-sizing: border-box;

    /* Ẩn hoàn toàn thanh cuộn (scrollbar) trên mọi trình duyệt */
    -ms-overflow-style: none; /* IE and Edge */
    scrollbar-width: none; /* Firefox */
  }

  .wt-video-slider-track::-webkit-scrollbar {
    display: none; /* WebKit (Chrome, Safari, Safari iOS) */
  }

  /* Mỗi thẻ trên mobile chiếm 72% chiều rộng hiển thị của màn hình */
  .wt-video-card {
    flex: 0 0 72%;
    scroll-snap-align: center; /* Hít và căn chính giữa màn hình */
    max-width: 450px; /* Tránh thẻ bị quá to trên tablet màn lớn */
  }

  /* Tối ưu hóa vị trí nút đóng trên màn hình nhỏ để dễ bấm hơn */
  .wt-video-modal-close {
    top: -50px;
    right: 10px;
    font-size: 48px;
  }
}

@media (max-width: 480px) {
  .wt-video-card {
    flex: 0 0 78%; /* Mobile cực nhỏ hiển thị khoảng 78% để gợi ý thẻ tiếp theo rõ hơn */
  }
}

/* 6. Giao diện Pagination (Dots) */
.wt-video-slider-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.wt-pagination-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #2c3545; /* Dark grayish blue from the reference image */
  cursor: pointer;
  transition:
    background-color 0.3s ease,
    transform 0.3s ease;
}

.wt-pagination-dot:hover {
  background-color: #3b485c;
}

.wt-pagination-dot.wt-active {
  background-color: #cfd8dc; /* Light gray from the reference image */
  transform: scale(1.1);
}

/* Ẩn pagination trên desktop do hiển thị dạng Grid */
@media (min-width: 1025px) {
  .wt-video-slider-pagination {
    display: none;
  }
}

/* 7. Hướng dẫn cuộn (Scroll Guide) */
.wt-video-scroll-guide {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 99;
  pointer-events: none !important; /* Đảm bảo không bắt sự kiện click/touch */
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.4s ease,
    visibility 0.4s ease;
}

.wt-video-scroll-guide *,
.wt-scroll-guide-pill {
  pointer-events: none !important; /* Ngăn toàn bộ con của scroll guide cản trở vuốt */
}

.wt-video-scroll-guide.wt-active {
  opacity: 1 !important;
  visibility: visible !important;
}


.wt-scroll-guide-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background-color: #00000099;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 100px;
  padding: 10px 24px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
}

.wt-scroll-guide-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
}

.wt-scroll-guide-hand {
  display: flex;
  align-items: center;
  justify-content: center;
}

.wt-scroll-guide-hand svg {
  display: block;
  animation: wt-hand-swipe 1.6s ease-in-out infinite;
}

@keyframes wt-hand-swipe {
  0% {
    transform: translateX(-4px);
  }
  50% {
    transform: translateX(4px);
  }
  100% {
    transform: translateX(-4px);
  }
}

.wt-video-scroll-guide.wt-hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  display: none !important; /* Ẩn hoàn toàn khỏi DOM cây hiển thị để tránh cản trở touch */
}

/* Ẩn hoàn toàn trên desktop */
@media (min-width: 1025px) {
  .wt-video-scroll-guide {
    display: none;
  }
}
