/* ============================================
   Art Gallery - Lightbox Styles
   ============================================
   Fullscreen Lightbox Viewer with Navigation
   ============================================ */

/* ===== Lightbox Container ===== */
.lightbox {
  position: fixed;
  inset: 0;
  background-color: rgba(2,6,12,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
}

.lightbox.hidden {
  display: none;
}

.lightbox .box {
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 210;
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 600px) {
  .lightbox .box {
    max-height: 90vh;
    justify-content: flex-start;
    padding-top: 20px;
  }

  .lightbox {
    padding: 10px;
  }

  /* Default reduced height when carousel is present */
  .lightbox .box.has-carousel img {
    max-height: calc(70vh - 120px); 
  }

  /* Larger height for images without carousel */
  .lightbox .box:not(.has-carousel) img {
    max-height: calc(80vh - 80px); 
  }
  
  .alt-carousel {
    margin-top: 8px; 
    margin-bottom: 6px;
  }
  
  .lightbox .caption {
    margin-top: 0;
    margin-bottom: 16px;
    padding: 12px 16px; 
    font-size: 14px; 
    max-width: 85vw; 
  }
}

/* ===== Alt Images Carousel ===== */
.alt-carousel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px; 
  margin-bottom: 8px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.carousel-container {
  display: flex;
  gap: 8px;
  justify-content: center;
  overflow: hidden;
}

.carousel-navigation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.carousel-arrow {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.carousel-arrow:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.carousel-arrow:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

.image-indicator {
  text-align: center;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  margin: 0;
}

.alt-carousel::-webkit-scrollbar {
  display: none;
}

.alt-thumb {
  flex-shrink: 0;
  width: 70px;
  height: 52px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.alt-thumb:hover {
  border-color: rgba(255, 255, 255, 0.7);
  transform: scale(1.05);
}

.alt-thumb.active {
  border-color: white;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3), 0 4px 12px rgba(0, 0, 0, 0.4);
  transform: scale(1.08);
}

.alt-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Mobile styles for alt carousel */
@media (max-width: 768px) {
  .lightbox {
    padding: 10px;
  }

  .lightbox .box {
    max-width: 100vw;
    max-height: 100vh;
  }

  .lightbox .chev {
    width: 50px;
    height: 50px;
    opacity: 0.8;
  }

  .lightbox .chev svg {
    width: 24px;
    height: 24px;
  }

  .lightbox .close {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }

  .alt-carousel {
    padding: 16px 12px;
    gap: 12px;
    margin-top: 16px;
  }

  .carousel-navigation {
    gap: 12px;
  }

  .alt-thumb {
    width: 80px;
    height: 60px;
    border-radius: 10px;
  }

  .alt-thumb:hover {
    transform: none; /* Disable hover transform on touch devices */
  }

  .alt-thumb.active {
    transform: scale(1.05);
  }

  .image-indicator {
    font-size: 12px;
  }
}

.lightbox img {
  max-width: calc(100vw - 140px);
  max-height: calc(80vh - 120px); 
  object-fit: contain;
  display: block;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  transition: opacity 0.28s ease, transform 0.28s ease;
  z-index: 200;
}

.lightbox img.fade-out {
  opacity: 0;
  transform: scale(0.995) translateX(0);
}

.lightbox img.fade-in {
  opacity: 1;
  transform: scale(1) translateX(0);
}

/* ===== Caption ===== */
.lightbox .caption {
  margin-top: 0;
  margin-bottom: 8px;
  color: #fff;
  background: rgba(0,0,0,0.6);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  max-width: 80vw;
  text-align: center;
}

:root[data-theme="light"] .lightbox .caption {
  color: #fff;
  background: rgba(0,0,0,0.6);
}

/* ===== Close & Caption Toggle Buttons ===== */
.lightbox .close {
  position: absolute;
  right: 12px;
  top: 12px;
  background: rgba(255,255,255,0.9);
  color: #111;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 999px;
  padding: 6px 8px;
  cursor: pointer;
  font-size: 14px;
  z-index: 400;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.12s ease;
}

.caption-toggle {
  position: absolute;
  right: 56px;
  top: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.9);
  color: #111;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.12s ease;
  z-index: 400;
  font-size: 12px;
}

:root[data-theme="dark"] .lightbox .close {
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.04);
}

:root[data-theme="dark"] .caption-toggle {
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.04);
}

:root[data-theme="high-contrast"] .lightbox .close,
:root[data-theme="high-contrast"] .caption-toggle {
  background: #fff;
  color: #000;
  border: 2px solid #000;
}

/* ===== Navigation Arrows ===== */
.chev {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: rgba(0,0,0,0.45);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.08);
  z-index: 220;
  transition: all 0.2s ease;
}

.chev:hover:not(:disabled) {
  background: rgba(0,0,0,0.65);
  transform: translateY(-50%) scale(1.1);
}

.chev:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

.chev.left {
  left: 18px;
}

.chev.right {
  right: 18px;
}

:root[data-theme="light"] .chev {
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.06);
}

:root[data-theme="light"] .chev:hover:not(:disabled) {
  background: rgba(0,0,0,0.75);
}

/* ===== Chevron Preview Hover ===== */
.chev-preview {
  position: fixed;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--card-border);
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  border-radius: 8px;
  z-index: 230;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chev-preview img {
  width: 220px;
  height: 140px;
  object-fit: cover;
  border-radius: 6px;
}

.chev-preview.hidden {
  display: none;
}

/* ===== Slide Animations ===== */
.slide-left {
  animation: slideLeft 0.36s ease;
}

.slide-right {
  animation: slideRight 0.36s ease;
}

@keyframes slideLeft {
  from {
    opacity: 0;
    transform: translateX(-18px) scale(0.995);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes slideRight {
  from {
    opacity: 0;
    transform: translateX(18px) scale(0.995);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

/* ===== Mobile Responsive ===== */
@media (max-width: 700px) {
  .lightbox .close {
    opacity: 0.7; 
    padding: 8px 10px;
    font-size: 16px;
  }
  
  .caption-toggle {
    opacity: 0.7; 
    padding: 6px 10px;
    font-size: 13px;
  }
  
  .lightbox img {
    max-width: calc(100vw - 48px);
    max-height: calc(70vh - 140px); 
  }
  
  .chev {
    display: block;
    width: 40px;
    height: 40px;
    font-size: 20px;
  }
  
  .alt-carousel {
    padding: 16px 12px;
    gap: 12px;
    margin-top: 12px; 
    margin-bottom: 6px;
  }
  
  .lightbox .caption {
    margin-bottom: 16px; 
    max-width: 90vw;
    padding: 10px 14px; 
    font-size: 14px; 
  }
}

/* ===== Mobile Portrait Navigation ===== */
@media (max-width: 700px) and (orientation: portrait) {
  .chev {
    top: auto;
    bottom: 20px;
    transform: none;
    width: 44px;
    height: 44px;
    font-size: 20px;
    background: rgba(0,0,0,0.5);
    opacity: 0.9;
    border-radius: 50%;
  }
  
  .chev:hover:not(:disabled) {
    background: rgba(0,0,0,0.7);
    transform: scale(1.05); 
  }
  
  .chev.left {
    left: 20px;
  }
  
  .chev.right {
    right: 20px;
  }
}

