/* ───────── LIGHTBOX ───────── */
#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

#lightbox.show {
  opacity: 1;
  pointer-events: auto;
}

#lightbox.hidden {
  display: none;
}

#lightboxContent {
  position: relative;
  background: #111;
  color: #fff;
  border-radius: 14px;
  padding: 1rem;
  display: grid;
  grid-template-columns: 260px var(--fsPanelLine) 1fr var(--fsPanelLine) 320px;

  gap: 1rem;
  height: 85vh;
  max-width: 95vw;
  transform: scale(0.96);
  opacity: 0;
  transition:
    transform 0.35s cubic-bezier(.22,.61,.36,1),
    opacity 0.25s ease;
}

#lightbox.show #lightboxContent {
  transform: scale(1);
  opacity: 1;
}

#closeBtn {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 22px;
  background: none;
  color: #fff;
  border: none;
  cursor: pointer;
  z-index: 10;
}

#lightboxMedia {
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ───────── LIGHTBOX LOADING (spinner + fade-in) ───────── */
#lightboxMedia{ position: relative; } /* allow absolute spinner */

#lightbox .lb-spinner{
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease;
}

#lightbox.loading .lb-spinner{ opacity: 1; }

#lightbox .lb-spinner .spin{
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 3px solid rgba(255,255,255,0.22);
  border-top-color: rgba(255,255,255,0.90);
  animation: lbspin 900ms linear infinite;
}

@keyframes lbspin{ to{ transform: rotate(360deg); } }

/* media fades in only when ready */
#lightbox .lightbox-media-wrap{
  opacity: 0;
  transition: opacity 240ms ease;
}
#lightbox .lightbox-media-wrap.ready{
  opacity: 1;
}


.lightbox-media-wrap {
  max-width: 100%;
  max-height: calc(85vh - 2rem);
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;          /* canvas clips the zoomed media */
  border-radius: 10px;       /* canvas border radius */
  border: 1px solid rgba(255,255,255,0.14);
  background: #000;
  cursor: grab;

}

/* breakout mode: let zoomed media escape the canvas */
.lightbox-media-wrap.breakout{
  overflow: visible;
  border: none;
  background: transparent;
}

/* breakout must override ALL lightbox modes (lb:minimal too) */
#lightbox.lb-breakout #lightboxContent,
#lightbox.lb-breakout #lightboxMedia{
  overflow: visible !important;
}

#lightbox.lb-breakout .lightbox-media-wrap{
  overflow: visible !important;
  border: none !important;
  background: transparent !important;
}



.lightbox-media-wrap img,
.lightbox-media-wrap video {
  height: 100%;
  width: auto;
  object-fit: contain;
  border-radius: 0;
  will-change: transform;
  transform-origin: center center;

}

.lightbox-media-wrap.dragging{ cursor: grabbing; }


.lightbox-media-wrap audio {
  width: 100%;
}

#lightboxCaption {
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#lightboxCaption h3 {
  margin: 0;
  font-size: 18px;
}

#lightboxCaption p {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
}


#lightbox.lb-full #lightboxCaption{
  display: none;
}

#lightbox.lb-full #lightboxContent{
  height: 100vh;
  max-width: 100vw;
  width: 100vw;
  border-radius: 0;
  padding: 0;
  grid-template-columns: 1fr;
}

#lightbox.lb-full #lightboxMedia{
  height: 100vh;
}

#lightbox.lb-full .lightbox-media-wrap{
  max-height: 100vh;
}

#lightbox.lb-full .lightbox-media-wrap img,
#lightbox.lb-full .lightbox-media-wrap video{
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
}

#lightbox.lb-full #closeBtn{
  position: fixed;
  top: 14px;
  right: 16px;
}


/* ───────── LIGHTBOX MODE: MINIMAL ───────── */
/* lb:minimal: always fit media inside the lightbox */
#lightbox.lb-minimal #lightboxCaption{
  display: none;
}

#lightbox.lb-minimal #lightboxContent{
  grid-template-columns: 1fr;
  width: min(92vw, 1100px);
  height: min(85vh, 760px);
  padding: 0.75rem;
}

#lightbox.lb-minimal #lightboxMedia{
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden; /* important */
}

#lightbox.lb-minimal .lightbox-media-wrap{
  width: 100%;
  height: 100%;
  max-height: 100%;
  max-width: 100%;
}

/* override your base "height:100%; width:auto" so it never spills */
#lightbox.lb-minimal .lightbox-media-wrap img,
#lightbox.lb-minimal .lightbox-media-wrap video{
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* lb:minimal: always fit media inside the lightbox */
#lightbox.lb-minimal #lightboxCaption{
  display: none;
}

#lightbox.lb-minimal #lightboxContent{
  grid-template-columns: 1fr;
  width: min(92vw, 1100px);
  height: min(85vh, 760px);
  padding: 0.75rem;
}

#lightbox.lb-minimal #lightboxMedia{
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden; /* important */
}

#lightbox.lb-minimal .lightbox-media-wrap{
  width: 100%;
  height: 100%;
  max-height: 100%;
  max-width: 100%;
}

/* override your base "height:100%; width:auto" so it never spills */
#lightbox.lb-minimal .lightbox-media-wrap img,
#lightbox.lb-minimal .lightbox-media-wrap video{
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}


