* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  background: #f5f5f5;
  padding: 20px;
}

/* === Слайдер === */

.slider-wrapper {
  position: relative;
  max-width: 800px;
  margin: 0 auto;
}

.main-slide-container {
  width: 100%;
  height: 450px;
  overflow: hidden;
  position: relative;
  background: #222;
  border-radius: 8px;
}

.main-slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
  pointer-events: none;
  cursor: default;
  object-fit: cover;
}

.main-slide.active {
  opacity: 1;
  pointer-events: auto;
}

img.main-slide {
  cursor: pointer;
}

/* === Обёртка для видео-слайда === */

.video-slide-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
  pointer-events: none;
}

.video-slide-wrapper.active {
  opacity: 1;
  pointer-events: auto;
}

.video-slide-wrapper iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

/* === Оверлей с иконкой «плей» === */

.play-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 5;
  cursor: pointer;
  transition: opacity 0.3s;
}

.video-slide-wrapper.playing .play-overlay {
  opacity: 0;
  pointer-events: none;
}

.play-icon {
  width: 64px;
  height: 64px;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
  transition: transform 0.2s;
}

.play-overlay:hover .play-icon {
  transform: scale(1.15);
}

/* === Кнопки навигации слайдера === */

.prev-btn, .next-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.7);
  color: #333;
  border: none;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 20px;
  user-select: none;
  z-index: 10;
  border-radius: 4px;
  transition: background 0.2s;
}

.prev-btn:hover, .next-btn:hover {
  background: rgba(255,255,255,0.95);
}

.prev-btn { left: 10px; }
.next-btn { right: 10px; }

/* === Блок миниатюр с прокруткой === */

.thumbs-wrapper {
  display: flex;
  align-items: center;
  margin-top: 15px;
  gap: 8px;
}

.thumb-arrow {
  flex-shrink: 0;
  width: 32px;
  height: 60px;
  background: rgba(51, 51, 51, 0.8);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 24px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s, opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.thumb-arrow:hover {
  background: rgba(51, 51, 51, 1);
}

.thumb-arrow.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.thumbs-viewport {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.thumbnails {
  display: flex;
  gap: 10px;
  transition: transform 0.35s ease;
  will-change: transform;
}

.thumbnail {
  flex-shrink: 0;
  width: 100px;
  height: 60px;
  background-size: cover;
  background-position: center;
  cursor: pointer;
  border: 2px solid transparent;
  box-sizing: border-box;
  opacity: 0.7;
  transition: opacity 0.3s ease, border-color 0.3s ease;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.thumbnail:hover {
  opacity: 1;
}

.thumbnail.active {
  border-color: #333;
  opacity: 1;
}

.has-video::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}

.thumb-play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
  z-index: 2;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
}

/* === Lightbox === */

.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  transition: opacity 0.3s;
  touch-action: pan-y;
}

.lightbox.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.lightbox-image {
  max-width: 90%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
  transition: opacity 0.25s;
}

.lightbox-image.fade {
  opacity: 0;
}

.close-btn {
  position: absolute;
  top: 20px;
  right: 30px;
  color: #fff;
  font-size: 40px;
  line-height: 1;
  cursor: pointer;
  z-index: 1001;
  user-select: none;
  transition: opacity 0.2s;
}

.close-btn:hover {
  opacity: 0.7;
}

.lb-prev, .lb-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 32px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 1002;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: background 0.2s, transform 0.15s;
}

.lb-prev:hover, .lb-next:hover {
  background: rgba(255, 255, 255, 0.6);
}

.lb-prev { left: 20px; }
.lb-next { right: 20px; }

.lb-prev:active, .lb-next:active {
  transform: translateY(-50%) scale(0.95);
}

/* === Адаптив === */

@media (max-width: 600px) {
  .main-slide-container { height: 260px; }
  .thumbnail { width: 70px; height: 42px; }
  .thumb-play-icon { width: 20px; height: 20px; }
  .play-icon { width: 48px; height: 48px; }
  .prev-btn, .next-btn { padding: 8px 12px; font-size: 16px; }
  .lb-prev, .lb-next { width: 40px; height: 40px; font-size: 24px; }
  .close-btn { font-size: 32px; top: 15px; right: 20px; }
  .thumb-arrow { width: 28px; height: 42px; font-size: 18px; }
}
