/* Image Lightbox */
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: var(--z-lightbox);
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease-out;
}

.lightbox-overlay.active {
  display: flex;
}

.lightbox-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 0 80px 60px;
}

.lightbox-image-container {
  max-width: 90%;
  max-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  /* Hover-aware stacking: image + bottom bar both sit above the
     overlay, but whichever the user is interacting with comes on
     top so neither permanently occludes the other where they meet. */
  z-index: 2;
}
.lightbox-image-container:hover {
  z-index: 4;
}

.lightbox-image-container img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s ease-out;
  cursor: zoom-in;
  user-select: none;
  touch-action: none;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 36px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  z-index: var(--z-lightbox-ui);
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 48px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  z-index: var(--z-lightbox-ui);
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-50%) scale(1.1);
}

.lightbox-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.lightbox-nav:disabled:hover {
  transform: translateY(-50%) scale(1);
}

.lightbox-prev {
  left: 20px;
}

.lightbox-next {
  right: 20px;
}

/* Unified bottom strip — replaces the three absolutely-positioned
   rows (info, tabs, toolbar) with a single panel. Title is compact,
   tabs row sits above quality controls so the visual hierarchy reads
   top→down. */
.lightbox-bottom-bar {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(15, 18, 25, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  /* Sits above the image overlay by default, jumps higher when
     hovered so it can never be permanently occluded by the image. */
  z-index: 3;
  max-width: calc(100vw - 32px);
  pointer-events: auto;
}
.lightbox-bottom-bar:hover,
.lightbox-bottom-bar--hd-open {
  z-index: 5;
}

.lightbox-info {
  position: relative;
  text-align: center;
  color: white;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  /* Reserve a small right margin so the absolute-positioned HD
     trigger doesn't overlap the title text. */
  padding-right: 28px;
}

/* HD/UHD/raw popover trigger anchored top-right of the info row. */
.lightbox-hd-trigger {
  position: absolute;
  top: -2px;
  right: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.lightbox-hd-trigger:hover {
  background: rgba(255, 255, 255, 0.14);
  color: white;
  border-color: rgba(255, 255, 255, 0.4);
}
.lightbox-hd-trigger[hidden] {
  display: none;
}
.lightbox-bottom-bar--hd-open .lightbox-hd-trigger {
  background: rgba(255, 255, 255, 0.18);
  color: white;
  border-color: rgba(255, 255, 255, 0.55);
}

.lightbox-card-name {
  font-size: 15px;
  font-weight: 600;
  color: white;
}

.lightbox-card-details {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
  letter-spacing: 0.02em;
}
.lightbox-card-details:not(:empty)::before {
  content: '•';
  margin-right: 8px;
  color: rgba(255, 255, 255, 0.35);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Lightbox Image Tabs — sit inside .lightbox-bottom-bar (no absolute
   positioning anymore). */
.lightbox-tabs {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
.lightbox-tabs:empty {
  display: none;
}

.lightbox-tab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.lightbox-tab:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.lightbox-tab.active {
  background: rgba(255, 255, 255, 0.25);
  color: white;
  border-color: rgba(255, 255, 255, 0.6);
  font-weight: 600;
}

.lightbox-tab.placeholder {
  opacity: 0.6;
  font-style: italic;
}

.tab-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 8px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.tab-badge.hd {
  background: #4caf50;
  color: white;
}

/* Lightbox quality toolbar — surfaced as a popover anchored above the
   bottom bar, NOT a row that pushes the rest of the menu down.
   Triggered by .lightbox-hd-trigger in the info row. */
.lightbox-toolbar {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding: 8px 10px;
  background: rgba(15, 18, 25, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 2;
}

.lightbox-toolbar[hidden] {
  display: none;
}

/* Segmented HD ↔ UHD switch — two pill buttons sharing a single
   rounded container so the toggle behaviour reads as a switch
   (not a status pill + separate action). The active segment is
   filled; clicking the inactive segment swaps the rendered image. */
.lightbox-toolbar .lb-qual-switch {
  display: inline-flex;
  align-items: stretch;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  overflow: hidden;
}
.lightbox-toolbar .lb-qual {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.7);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.lightbox-toolbar .lb-qual + .lb-qual {
  border-left: 1px solid rgba(255, 255, 255, 0.14);
}
.lightbox-toolbar .lb-qual:hover {
  color: white;
  background: rgba(255, 255, 255, 0.05);
}
.lightbox-toolbar .lb-qual.active {
  background: rgba(76, 175, 80, 0.85);
  color: white;
  cursor: default;
}
.lightbox-toolbar .lb-qual.active:hover {
  background: rgba(76, 175, 80, 0.85);
}
/* Solo HD pill — non-clickable status when there's no UHD variant. */
.lightbox-toolbar .lb-qual--solo {
  border-radius: 14px;
  border: 1px solid rgba(76, 175, 80, 0.6);
}

.lightbox-toolbar .lb-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.88);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}
/* Icon glyph in front of the raw-download action. */
.lightbox-toolbar .lb-action-raw::before {
  content: '↓';
  font-weight: 700;
  opacity: 0.9;
}

.lightbox-toolbar .lb-action:hover {
  background: rgba(255, 255, 255, 0.22);
  color: white;
  border-color: rgba(255, 255, 255, 0.55);
}

.lightbox-toolbar .lb-action.active {
  background: rgba(76, 175, 80, 0.85);
  border-color: rgba(76, 175, 80, 1);
  color: white;
}

.lightbox-toolbar .lb-action .lb-size {
  opacity: 0.7;
  font-weight: 400;
  font-size: 11px;
}

/* Compact bottom bar on small screens */
@media (max-width: 480px) {
  .lightbox-bottom-bar {
    bottom: 12px;
    padding: 8px 12px;
    gap: 6px;
  }
  .lightbox-toolbar .lb-action,
  .lightbox-tab {
    padding: 4px 8px;
    font-size: 11px;
  }
}

/* HD badge inside the modal pill tabs (under the card detail thumb) */
.modal-tab .tab-badge.hd {
  margin-left: 4px;
  font-size: 9px;
  padding: 0 5px;
}
