/* ==========================================================================
   LIGHTBOX & FULLSCREEN MEDIA VIEWER STYLES
   Ultra-responsive: Portrait/Landscape, Safe-area insets, Progressive reveal
   ========================================================================== */

.lightbox-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  background: rgba(4, 6, 9, 0.97);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.28s;
  user-select: none;
  touch-action: pan-y pinch-zoom;
}

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

/* Lightbox Header Bar */
.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(0.8rem + env(safe-area-inset-top, 0px)) calc(1.2rem + env(safe-area-inset-right, 0px)) 0.8rem calc(1.2rem + env(safe-area-inset-left, 0px));
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.85) 0%, transparent 100%);
  z-index: 20;
  transition: transform 0.2s ease;
}

.lightbox-counter {
  font-family: var(--font-heading, sans-serif);
  font-size: 0.95rem;
  color: var(--gold-light, #FFD580);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lightbox-toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.lightbox-btn {
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.lightbox-btn:hover, .lightbox-btn:active {
  background: var(--gold-primary, #F5A623);
  color: #000;
  transform: scale(1.06);
}

.lightbox-btn.active {
  background: var(--gold-primary, #F5A623);
  color: #000;
  box-shadow: 0 0 15px rgba(245, 166, 35, 0.6);
}

.lb-close-btn {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
}
.lb-close-btn:hover {
  background: #EF4444;
  color: #FFF;
}

/* Main Lightbox Stage */
.lightbox-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0.5rem;
}

.lightbox-media-container {
  max-width: 95vw;
  max-height: 82vh;
  max-height: 82dvh;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform, opacity;
}

/* Progressive Loading & Placeholder */
.lightbox-placeholder {
  max-width: 100%;
  max-height: 80vh;
  max-height: 80dvh;
  object-fit: contain;
  border-radius: 8px;
  filter: blur(12px);
  transform: scale(0.98);
  transition: filter 0.3s ease;
}

.lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  max-height: 80dvh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9);
  cursor: grab;
  transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.2s ease;
}

.lightbox-img.loading-fade {
  opacity: 0;
}

.lightbox-img.zoomed {
  cursor: grab;
}

.lightbox-video {
  max-width: 94vw;
  max-height: 78vh;
  max-height: 78dvh;
  border-radius: 8px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9);
  background: #000;
}

/* Loading Spinner */
.lightbox-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 5;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  backdrop-filter: blur(8px);
}

.lightbox-spinner.visible {
  display: flex;
}

.spinner-ring {
  width: 26px;
  height: 26px;
  border: 3px solid rgba(245, 166, 35, 0.25);
  border-top-color: var(--gold-primary, #F5A623);
  border-radius: 50%;
  animation: lb-spin 0.8s linear infinite;
}
@keyframes lb-spin {
  to { transform: rotate(360deg); }
}

/* Navigation Arrows */
.lightbox-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #FFF;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 15;
  -webkit-tap-highlight-color: transparent;
}

.lightbox-nav-btn:hover, .lightbox-nav-btn:active {
  background: var(--gold-primary, #F5A623);
  color: #000;
  transform: translateY(-50%) scale(1.08);
}

.lightbox-prev { left: calc(1rem + env(safe-area-inset-left, 0px)); }
.lightbox-next { right: calc(1rem + env(safe-area-inset-right, 0px)); }

/* Lightbox Info Drawer */
.lightbox-drawer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: linear-gradient(0deg, rgba(5, 7, 10, 0.98) 0%, rgba(7, 9, 13, 0.88) 85%, transparent 100%);
  padding: 0.5rem calc(1.5rem + env(safe-area-inset-right, 0px)) calc(1rem + env(safe-area-inset-bottom, 0px)) calc(1.5rem + env(safe-area-inset-left, 0px));
  z-index: 20;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.lightbox-drawer.collapsed {
  transform: translateY(calc(100% - 30px));
}

.lightbox-drawer-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0 10px;
  cursor: pointer;
}

.drawer-pill {
  width: 42px;
  height: 4px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 3px;
  transition: background 0.2s;
}
.lightbox-drawer:hover .drawer-pill {
  background: var(--gold-primary, #F5A623);
}

.lightbox-drawer-content {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
}

.lightbox-caption-box {
  max-width: 650px;
}

.lightbox-caption-title {
  font-family: var(--font-heading, sans-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: #FFF;
  margin-bottom: 0.3rem;
}

.lightbox-caption-text {
  font-size: 0.9rem;
  color: #CBD5E1;
  line-height: 1.45;
  margin-bottom: 0.5rem;
}

.lightbox-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.lightbox-tag {
  background: rgba(245, 166, 35, 0.15);
  color: var(--gold-light, #FFD580);
  border: 1px solid rgba(245, 166, 35, 0.3);
  padding: 0.2rem 0.55rem;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
}

.lightbox-exif-box {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: right;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.7rem 1.1rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.lightbox-exif-item {
  font-size: 0.78rem;
  color: #94A3B8;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
}
.lightbox-exif-item span {
  color: #FFFFFF;
  font-weight: 600;
}

/* Slideshow Ken Burns active mode */
.slideshow-active .lightbox-img {
  animation: kenBurnsLightbox 5s infinite alternate ease-in-out;
}
@keyframes kenBurnsLightbox {
  0% { transform: scale(1); }
  100% { transform: scale(1.07); }
}

/* ==========================================================================
   MOBILE & ROTATION (PORTRAIT & LANDSCAPE) RESPONSIVE STYLES
   ========================================================================== */

/* Mobile Portrait */
@media (max-width: 768px) {
  .lightbox-header {
    padding: calc(0.6rem + env(safe-area-inset-top, 0px)) 0.8rem 0.6rem;
  }
  .lightbox-btn {
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
  }
  .lightbox-drawer-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.8rem;
  }
  .lightbox-exif-box {
    text-align: left;
    width: 100%;
    padding: 0.6rem 0.8rem;
  }
  .lightbox-exif-item {
    justify-content: flex-start;
  }
  .lightbox-nav-btn {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }
  .lightbox-prev { left: 0.4rem; }
  .lightbox-next { right: 0.4rem; }
  .lightbox-caption-title {
    font-size: 1.1rem;
  }
  .lightbox-caption-text {
    font-size: 0.82rem;
  }
}

/* Mobile Landscape (Screen Rotation) */
@media (orientation: landscape) and (max-height: 550px) {
  .lightbox-header {
    padding: calc(0.3rem + env(safe-area-inset-top, 0px)) calc(1rem + env(safe-area-inset-right, 0px)) 0.3rem calc(1rem + env(safe-area-inset-left, 0px));
    background: linear-gradient(180deg, rgba(0,0,0,0.9) 0%, transparent 100%);
  }
  .lightbox-counter {
    font-size: 0.8rem;
  }
  .lightbox-btn {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
  }
  .lightbox-stage {
    padding: 0;
  }
  .lightbox-media-container {
    max-width: 98vw;
    max-height: 94vh;
    max-height: 94dvh;
  }
  .lightbox-img {
    max-height: 94vh;
    max-height: 94dvh;
    border-radius: 4px;
  }
  .lightbox-video {
    max-height: 92vh;
    max-height: 92dvh;
  }
  .lightbox-nav-btn {
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
    background: rgba(0, 0, 0, 0.45);
  }
  .lightbox-prev { left: calc(0.5rem + env(safe-area-inset-left, 0px)); }
  .lightbox-next { right: calc(0.5rem + env(safe-area-inset-right, 0px)); }
  .lightbox-drawer {
    padding: 0.3rem calc(1.5rem + env(safe-area-inset-right, 0px)) calc(0.6rem + env(safe-area-inset-bottom, 0px)) calc(1.5rem + env(safe-area-inset-left, 0px));
  }
  .lightbox-drawer.collapsed {
    transform: translateY(calc(100% - 22px));
  }
  .lightbox-drawer-handle {
    padding: 3px 0 6px;
  }
  .lightbox-drawer-content {
    flex-direction: row;
    align-items: flex-end;
    gap: 1rem;
  }
  .lightbox-caption-title {
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
  }
  .lightbox-caption-text {
    font-size: 0.78rem;
    margin-bottom: 0.3rem;
  }
  .lightbox-exif-box {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.6rem;
    padding: 0.4rem 0.8rem;
  }
  .lightbox-exif-item {
    font-size: 0.72rem;
  }
}
