/* ============================================================
   Gallery lightbox — fullscreen viewer with metadata side panel
   Design token reference: design-system.md §7.9
   ============================================================ */

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200; /* above the sticky header (100), same layer as news modal */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: var(--overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Photo and metadata panel form one seamless card: the panel stretches to
   the photo's full height and continues it with no gap in between. */
.gallery-lightbox__body {
  display: flex;
  align-items: stretch;
  max-width: min(1400px, 100%);
  max-height: 100%;
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.gallery-lightbox__stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  background: var(--bg); /* letterbox tint when the panel is taller than the photo */
}

.gallery-lightbox__stage img {
  display: block;
  max-width: 100%;
  max-height: 85vh;
}

/* ---------- Metadata panel ---------- */
.gallery-lightbox__panel {
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5);
  background: var(--surface);
  border-inline-start: 1px solid var(--border-soft);
}

.gallery-lightbox__author {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}

.gallery-lightbox__date {
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: var(--tracking-meta);
  color: var(--text-faint);
}

.gallery-lightbox__desc {
  margin-top: var(--space-2);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: var(--lh-base);
  white-space: pre-line;
  overflow-wrap: anywhere;
  overflow-y: auto;
  max-height: 40vh;
}

.gallery-lightbox__desc a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.gallery-lightbox__counter {
  margin-top: auto;
  padding-top: var(--space-3);
  font-size: var(--fs-xs);
  letter-spacing: var(--tracking-meta);
  color: var(--text-faint);
}

.gallery-lightbox__delete {
  align-self: flex-start;
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
}

.gallery-lightbox__delete:hover {
  background: var(--surface-2);
  border-color: var(--danger);
}

/* ---------- Controls ---------- */
.gallery-lightbox__close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
}

.gallery-lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
}

.gallery-lightbox__nav--prev { left: var(--space-4); }
.gallery-lightbox__nav--next { right: var(--space-4); }

.gallery-lightbox__close,
.gallery-lightbox__nav {
  background: var(--surface-2-glass);
  border: 1px solid var(--border);
  color: var(--text);
}

.gallery-lightbox__close:hover,
.gallery-lightbox__nav:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

/* ---------- Mobile: panel below the photo ---------- */
@media (max-width: 768px) {
  .gallery-lightbox {
    padding: var(--space-4);
  }

  .gallery-lightbox__body {
    flex-direction: column;
    align-items: stretch;
    overflow-y: auto;
  }

  .gallery-lightbox__stage img {
    max-height: 60vh;
  }

  .gallery-lightbox__panel {
    flex: none;
    width: 100%;
    padding: var(--space-4);
    border-inline-start: 0;
    border-top: 1px solid var(--border-soft);
  }

  .gallery-lightbox__nav {
    top: auto;
    bottom: var(--space-4);
    transform: none;
  }
}
