/* ===== Video Slider Section ===== */
.section-video-slider {
  width: 100%;
  padding: 80px 0;
  box-sizing: border-box;
  color: #1f2937;
  background: #ffffff;
}

.video-slider-container {
  width: 100%;
  margin: 0;
}

.video-slider-title {
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 600;
  margin: 0 0 48px 0;
  padding: 0 20px;
  line-height: 1.2;
  text-align: center;
  color: #1f2937;
}

.video-slider-wrapper {
  position: relative;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(44, 90, 160, 0.5) transparent;
  padding-bottom: 12px;
}

/* 슬라이드 모드일 때도 전체 폭 사용 */
.video-slider-wrapper.view-slide {
  padding-left: 0;
  padding-right: 0;
}

/* 그리드 모드일 때는 세로 스크롤만 가능 (무한 스크롤 지원) */
.video-slider-wrapper.view-grid {
  overflow-x: hidden;
  overflow-y: visible;
  padding-bottom: 0;
}

.video-slider-wrapper::-webkit-scrollbar {
  height: 6px;
}

.video-slider-wrapper::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 3px;
}

.video-slider-wrapper::-webkit-scrollbar-thumb {
  background: rgba(44, 90, 160, 0.4);
  border-radius: 3px;
  transition: background 0.3s ease;
}

.video-slider-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgba(44, 90, 160, 0.6);
}

/* 슬라이드 보기 모드 (기본값 - 가로 스크롤) */
.video-slider-grid {
  display: flex;
  gap: 20px;
  width: 100%;
  min-width: 100%;
}

.video-slider-wrapper.view-slide .video-slider-grid {
  display: flex;
  gap: 20px;
  width: 100%;
  min-width: 100%;
}

/* 그리드 보기 모드 (세로 스크롤, 무한 스크롤) */
.video-slider-wrapper.view-grid .video-slider-grid {
  display: grid;
  grid-template-columns: repeat(var(--items-per-row-pc, 3), 1fr);
  gap: 20px;
  width: 100%;
  padding: 0;
}

.video-slider-wrapper.view-grid {
  padding: 0;
}

@media (max-width: 768px) {
  .video-slider-wrapper.view-grid .video-slider-grid {
    grid-template-columns: repeat(var(--items-per-row-mobile, 2), 1fr);
    gap: 16px;
  }
}

.video-slider-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  background-color: #000;
  flex-shrink: 0;
}

/* 슬라이드 모드 아이템 크기 */
.video-slider-wrapper.view-slide .video-slider-item {
  width: calc((100% - (var(--items-per-row-pc, 3) - 1) * 20px) / var(--items-per-row-pc, 3));
  min-width: calc((100% - (var(--items-per-row-pc, 3) - 1) * 20px) / var(--items-per-row-pc, 3));
}

/* 그리드 모드 아이템 크기 */
.video-slider-wrapper.view-grid .video-slider-item {
  width: 100%;
}

/* 높이가 설정된 경우 높이 기준으로 크기 조정 */
.video-slider-wrapper.has-custom-height-pc .video-slider-item {
  height: var(--item-height-pc, auto);
}

@media (max-width: 768px) {
  .video-slider-wrapper.has-custom-height-mobile .video-slider-item {
    height: var(--item-height-mobile, auto);
  }

  /* 슬라이드 모드에서 모바일 아이템 크기 */
  .video-slider-wrapper.view-slide .video-slider-item {
    width: calc((100% - (var(--items-per-row-mobile, 2) - 1) * 16px) / var(--items-per-row-mobile, 2));
    min-width: calc((100% - (var(--items-per-row-mobile, 2) - 1) * 16px) / var(--items-per-row-mobile, 2));
  }
}

.video-slider-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0);
  transition: background 0.3s ease;
  z-index: 1;
  pointer-events: none;
}

.video-slider-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.video-slider-item:hover::before {
  background: rgba(0, 0, 0, 0.2);
}

.video-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform 0.3s ease;
}

.video-slider-item:hover .video-thumbnail {
  transform: scale(1.05);
}

/* fill-thumbnail 클래스가 없을 때 (체크 해제 시) contain 사용 */
.video-slider-wrapper:not(.fill-thumbnail) .video-thumbnail {
  object-fit: contain;
}

/* fill-thumbnail 클래스가 있을 때 (체크됨) cover 사용 - 높이 설정 여부와 관계없이 */
.video-slider-wrapper.fill-thumbnail .video-thumbnail {
  object-fit: cover;
}

/* 높이가 설정된 경우 썸네일은 높이 기준으로 크기 유지 */
.video-slider-wrapper.has-custom-height-pc .video-slider-item {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* fill-thumbnail 클래스가 없을 때만 contain 사용 */
.video-slider-wrapper.has-custom-height-pc:not(.fill-thumbnail) .video-thumbnail {
  width: auto;
  max-width: 100%;
  height: 100%;
  object-fit: contain;
}

/* fill-thumbnail 클래스가 있을 때는 cover 사용 */
.video-slider-wrapper.has-custom-height-pc.fill-thumbnail .video-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 768px) {
  .video-slider-wrapper.has-custom-height-mobile .video-slider-item {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* fill-thumbnail 클래스가 없을 때만 contain 사용 */
  .video-slider-wrapper.has-custom-height-mobile:not(.fill-thumbnail) .video-thumbnail {
    width: auto;
    max-width: 100%;
    height: 100%;
    object-fit: contain;
  }

  /* fill-thumbnail 클래스가 있을 때는 cover 사용 */
  .video-slider-wrapper.has-custom-height-mobile.fill-thumbnail .video-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}

.video-play-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  background: transparent;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 2;
  border: 2px solid rgba(255, 255, 255, 0.9);
  opacity: 0.9;
}

.video-slider-item:hover .video-play-button {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.1);
  border-color: rgba(255, 255, 255, 1);
  border-width: 3px;
}

.video-play-button svg {
  width: 28px;
  height: 28px;
  margin-left: 3px;
  fill: #ffffff;
}

.video-item-title {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  line-height: 1.4;
  z-index: 1;
  transition: background 0.3s ease, padding 0.3s ease;
}

.video-slider-item:hover .video-item-title {
  background: rgba(0, 0, 0, 0.85);
  padding: 14px 12px;
}

/* 모달 스타일 */
.video-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.video-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  transition: opacity 0.3s ease;
}

.video-modal-content {
  position: relative;
  width: 100%;
  max-width: 1200px;
  max-height: 90vh;
  z-index: 10001;
  background-color: #000;
  border-radius: 8px;
  overflow: hidden;
}

.video-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.2);
  border: none;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10002;
  transition: background-color 0.2s ease;
}

.video-modal-close:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

.video-modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.2);
  border: none;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10002;
  transition: background-color 0.2s ease;
}

.video-modal-nav:hover:not(:disabled) {
  background-color: rgba(255, 255, 255, 0.3);
}

.video-modal-nav:disabled {
  cursor: not-allowed;
}

.video-modal-prev {
  left: 16px;
}

.video-modal-next {
  right: 16px;
}

.video-modal-player {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 비율 */
  height: 0;
  overflow: hidden;
  background-color: #000;
}

.video-modal-player video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-modal-player iframe,
.video-modal-player .youtube-embed {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border: none !important;
  border-radius: 12px !important;
  background-color: #000 !important;
  z-index: 10 !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* video 태그가 숨겨져 있을 때도 iframe이 보이도록 */
.video-modal-player:has(iframe) video {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  z-index: -1 !important;
}

@media (max-width: 768px) {
  .section-video-slider {
    padding: 60px 0;
  }

  .video-slider-title {
    font-size: clamp(28px, 6vw, 36px);
    margin-bottom: 32px;
    padding: 0 16px;
  }

  /* 그리드 모드에서만 모바일 그리드 설정 적용 */
  .video-slider-wrapper.view-grid .video-slider-grid {
    grid-template-columns: repeat(var(--items-per-row-mobile, 2), 1fr);
    gap: 16px;
  }

  .video-slider-wrapper.view-slide .video-slider-grid {
    gap: 16px;
  }

  .video-play-button {
    width: 56px;
    height: 56px;
  }

  .video-play-button svg {
    width: 24px;
    height: 24px;
  }

  .video-modal-content {
    max-height: 80vh;
    border-radius: 8px;
  }

  .video-modal-close {
    width: 36px;
    height: 36px;
    top: 12px;
    right: 12px;
  }

  .video-modal-nav {
    width: 40px;
    height: 40px;
  }

  .video-modal-prev {
    left: 12px;
  }

  .video-modal-next {
    right: 12px;
  }
}

/* Sentinel 요소 (무한 스크롤 트리거) */
.video-slider-sentinel {
  width: 100%;
  height: 1px;
  visibility: hidden;
  pointer-events: none;
}

/* 로딩 스피너 개선 */
.video-slider-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 20px;
  color: #6b7280;
  font-size: 14px;
}

.video-slider-loading-text {
  position: relative;
  padding-left: 24px;
}

.video-slider-loading-text::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border: 2px solid #e5e7eb;
  border-top-color: #2c5aa0;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: translateY(-50%) rotate(360deg);
  }
}

/* 에러 메시지 스타일 */
.video-slider-error {
  padding: 24px;
  text-align: center;
  color: #ef4444;
  font-size: 14px;
  background-color: #fef2f2;
  border-radius: 12px;
  margin: 20px 0;
}

