/*
 * Image Lightbox — drop-in click-to-zoom for images.
 *
 * Theme-aware modal with keyboard nav, caption, and counter.
 * See /image-lightbox/README.md.
 */

/* Source images opted-in get the zoom cursor */
img[data-aed-lightbox] {
  cursor: zoom-in;
}

/* -- Modal -------------------------------------------------------- */
.aed-lb-scrim {
  position: fixed;
  inset: 0;
  z-index: 9400;
  background: rgba(8, 8, 12, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 56px;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.aed-lb-scrim.is-open { opacity: 1; }
.aed-lb-scrim[hidden] { display: none; }

.aed-lb-stage {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  /* No close-on-click cursor cue (v0.1.0 used `zoom-out`). Standard modal
     UX is "click backdrop / Esc / close button to close" — clicking the
     image itself does nothing, so the cursor stays neutral. */
  cursor: default;
  /* Touch-action: pan-y means horizontal swipes are claimed by our touch
     handler (for prev/next nav) while vertical scrolls pass through to the
     browser. Without this, mobile browsers may steal horizontal touches for
     page-back gestures before our handler sees them. */
  touch-action: pan-y;
  /* Prevent the browser's text-selection on touch-and-drag — the swipe
     gesture would otherwise highlight nearby text on long presses. */
  user-select: none;
  -webkit-user-select: none;
}

.aed-lb-image {
  max-width: 100%;
  max-height: 100%;
  display: block;
  border-radius: 8px;
  box-shadow: 0 24px 60px -16px rgba(0, 0, 0, 0.7);
  background: #18181b;
  transform: scale(0.97);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.18s ease;
  cursor: default;
  /* Disable native image drag/save-as preview on desktop so dragging the
     image triggers the swipe handler rather than a ghost-drag. */
  -webkit-user-drag: none;
  user-drag: none;
}
.aed-lb-scrim.is-open .aed-lb-image { transform: scale(1); }
.aed-lb-image.is-loading { opacity: 0; }

.aed-lb-spinner {
  position: absolute;
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  animation: aed-lb-spin 0.7s linear infinite;
  pointer-events: none;
}
@keyframes aed-lb-spin { to { transform: rotate(360deg); } }

/* -- Caption + counter ------------------------------------------- */
.aed-lb-meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 4px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.85rem;
  line-height: 1.45;
  pointer-events: none;
}
.aed-lb-caption { flex: 1; min-width: 0; }
.aed-lb-counter {
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.55);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

/* -- Buttons (close + nav) -------------------------------------- */
.aed-lb-btn {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.aed-lb-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.32);
}
.aed-lb-btn svg { width: 18px; height: 18px; }
.aed-lb-btn[hidden] { display: none; }

.aed-lb-close { top: 16px; right: 16px; }
.aed-lb-prev  { left: 12px; top: 50%; transform: translateY(-50%); }
.aed-lb-next  { right: 12px; top: 50%; transform: translateY(-50%); }

@media (max-width: 640px) {
  .aed-lb-scrim { padding: 16px 8px 56px; }
  .aed-lb-prev, .aed-lb-next {
    top: auto; bottom: 16px; transform: none;
    width: 40px; height: 40px;
  }
  .aed-lb-prev { left: 16px; }
  .aed-lb-next { right: 16px; }
  .aed-lb-meta { bottom: -28px; font-size: 0.78rem; }
}

@media print {
  .aed-lb-scrim { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  .aed-lb-scrim, .aed-lb-image { transition: opacity 0.15s ease; transform: none !important; }
  .aed-lb-spinner { animation: none; }
}
