/* === Modal Overlay (fullscreen dark background) === */
.slideshow-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(10,10,10,0.85);

  display: none;
  justify-content: center;
  align-items: center;

  padding: 20px;
  overflow: auto; /* allow scroll if slideshow taller than viewport */
}
.slideshow-modal.open {
  display: flex;
  animation: fadeIn 0.3s ease-in-out;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* === Slideshow Container === */
.slideshow-wrap {
  display: grid;
  grid-template-rows: auto 1fr auto auto; /* title | media | caption | thumbs */
  grid-template-areas:
    "title"
    "media"
    "caption"
    "thumbs";

  width: min(90vw, 1100px);
  max-height: 90vh;

  background: #111;
  border-radius: 12px;
  border: solid 2px #020618;
  box-shadow: 0 0 20px 5px rgba(255, 255, 255, 0.8);

  overflow: hidden;
  position: relative; /* important for absolute close button */
  margin: auto;
}

.slideshow-title {
  grid-area: title;
  background: #222;
  color: #fff;
  font-size: 16px;
  font-weight: bold;

  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;

  padding: 10px 40px; /* extra right padding for close button space */
  text-align: center;
  border-bottom: 1px solid #333;
}

/* Close button aligned to the right inside title bar */
.slideshow-close {
  position: absolute;
  top: 22px;
  right: 8px;
  
  transform: translateY(-50%);

  background: transparent;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  padding: 1px;
  border-radius: 4px;
  transition: background 0.2s;
}
.slideshow-close:hover {
  background: rgba(255,255,255,0.15);
}


/* === Media Area === */
.slideshow-media {
  grid-area: media;
  min-height: 0;
  min-width: 0;

  display: flex;
  justify-content: center;
  align-items: center;

  background: #000;
  padding: 10px;
  overflow: hidden;
}
.slideshow-image,
.slideshow-video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

/* === Caption === */
.slideshow-caption {
  grid-area: caption;
  background: #181818;
  color: #ddd;
  font-size: 14px;
  padding: 8px;
  text-align: center;
  border-top: 1px solid #333;
}

/* === Thumbnails === */
.slideshow-thumbs {
  grid-area: thumbs;
  display: flex;
  gap: 6px;
  padding: 8px;
  overflow-x: auto;
  background: #111;
  border-top: 1px solid #333;
  justify-content: center;
}
.slideshow-thumbs img {
  width: 70px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.6;
  transition: transform 0.2s, opacity 0.2s;
}
.slideshow-thumbs img:hover {
  transform: scale(1.05);
  opacity: 0.9;
}
.slideshow-thumbs img.active {
  border: 2px solid #0af;
  opacity: 1;
}

/* === Controls (Prev/Next/Close) === */
.slideshow-prev,
.slideshow-next,
.slideshow-close {
  position: absolute;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 28px;
  padding: 8px 14px;
  border-radius: 50%;
  transition: background 0.3s;
}
.slideshow-prev:hover,
.slideshow-next:hover,
.slideshow-close:hover {
  background: rgba(255,255,255,0.2);
}

/* Close button fixed inside top-right of slideshow */
.slideshow-close {
  top: 22px;
  right: 8px;
  font-size: 22px;
  z-index: 20;
}

/* Prev/Next vertically centered */
.slideshow-prev {
  top: 50%;
  left: 15px;
  transform: translateY(-50%);
}
.slideshow-next {
  top: 50%;
  right: 15px;
  transform: translateY(-50%);
}

/* === Responsive Design === */
@media (max-width: 768px) {
  .slideshow-wrap {
    width: 95vw;
    height: 85vh;
    border-radius: 8px;
  }
  .slideshow-title {
    font-size: 14px;
    padding: 8px;
  }
  .slideshow-image,
  .slideshow-video {
    max-height: 55vh;
  }
  .slideshow-thumbs img {
    width: 55px;
    height: 40px;
  }
}

@media (max-width: 480px) {
  .slideshow-wrap {
    width: 100vw;
    height: 100vh;
    border-radius: 6px;
  }
  .slideshow-title {
    font-size: 13px;
    padding: 6px;
  }
  .slideshow-caption {
    font-size: 12px;
    padding: 6px;
  }
  .slideshow-thumbs {
    gap: 4px;
    padding: 6px;
  }
  .slideshow-thumbs img {
    width: 45px;
    height: 32px;
  }
  .slideshow-close {
    font-size: 16px;
    top: 16px;
    right: 8px;
    padding: 6px 10px;
  }
  .slideshow-prev,
  .slideshow-next {
    font-size: 20px;
    padding: 6px;
  }
}
