/* ==========================================================================
   Lightbox / Media Viewer — JeffAPierson.com
   ========================================================================== */

/* --- Overlay --- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* --- Lightbox Container (wraps content, nav, info, filmstrip) --- */
.lightbox-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100vh;
  overflow: hidden;
}

/* --- Content Container --- */
.lightbox-content {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
  max-width: calc(100vw - 80px);
  max-height: calc(100vh - 160px);
  padding: 20px;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  user-select: none;
  -webkit-user-drag: none;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.lightbox-content video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 4px;
  outline: none;
}

.lightbox-content audio {
  width: 100%;
  max-width: 480px;
}

/* Loading state */
.lightbox-content .lightbox-loading {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #58a6ff;
  border-radius: 50%;
  animation: lightbox-spin 0.8s linear infinite;
}

@keyframes lightbox-spin {
  to { transform: rotate(360deg); }
}

/* --- Close Button --- */
.lightbox-close {
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 10002;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.lightbox-close:focus-visible {
  outline: 2px solid #58a6ff;
  outline-offset: 2px;
}

/* --- Navigation Arrows --- */
.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10001;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  user-select: none;
}

.lightbox-prev {
  left: 12px;
}

.lightbox-next {
  right: 12px;
}

.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(255, 255, 255, 0.18);
}

.lightbox-prev:active,
.lightbox-next:active {
  transform: translateY(-50%) scale(0.95);
}

.lightbox-prev:focus-visible,
.lightbox-next:focus-visible {
  outline: 2px solid #58a6ff;
  outline-offset: 2px;
}

.lightbox-prev[disabled],
.lightbox-next[disabled] {
  opacity: 0.25;
  pointer-events: none;
}

/* --- Info Bar --- */
.lightbox-info {
  width: 100%;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.6);
  flex-shrink: 0;
}

.lightbox-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 16px;
}

.lightbox-counter {
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
}

/* --- Filmstrip / Thumbnail Strip --- */
.lightbox-filmstrip {
  width: 100%;
  padding: 8px 12px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  background: rgba(0, 0, 0, 0.7);
  flex-shrink: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.lightbox-filmstrip::-webkit-scrollbar {
  height: 6px;
}

.lightbox-filmstrip::-webkit-scrollbar-track {
  background: transparent;
}

.lightbox-filmstrip::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.lightbox-thumb {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  opacity: 0.5;
  transition: opacity 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.lightbox-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lightbox-thumb:hover {
  opacity: 0.8;
}

.lightbox-thumb.active {
  opacity: 1;
  border-color: #58a6ff;
}

.lightbox-thumb:focus-visible {
  outline: 2px solid #58a6ff;
  outline-offset: 2px;
  opacity: 1;
}

/* --- Slide Transitions --- */
.lightbox-slide-enter {
  opacity: 0;
  transform: scale(0.95);
}

.lightbox-slide-enter-active {
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.lightbox-slide-exit {
  opacity: 1;
  transform: scale(1);
}

.lightbox-slide-exit-active {
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .lightbox-content {
    max-width: 100vw;
    padding: 10px;
    max-height: calc(100vh - 140px);
  }

  .lightbox-prev,
  .lightbox-next {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }

  .lightbox-prev { left: 4px; }
  .lightbox-next { right: 4px; }

  .lightbox-close {
    top: 8px;
    right: 8px;
    width: 44px;
    height: 44px;
    font-size: 24px;
  }

  .lightbox-thumb {
    width: 60px;
    height: 60px;
  }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  .lightbox-overlay,
  .lightbox-content img,
  .lightbox-close,
  .lightbox-prev,
  .lightbox-next,
  .lightbox-thumb,
  .lightbox-slide-enter-active,
  .lightbox-slide-exit-active {
    transition: none;
  }

  .lightbox-loading {
    animation: none;
  }
}
