/*
 * NitroLiteBox — Stylesheet v1.0.0
 * Zero external dependencies. All animations use GPU-composited properties.
 * Scoped entirely to #nlb-* to avoid conflicts with any theme or builder.
 */

/* ── Overlay ─────────────────────────────────────────────────────────────── */
#nlb-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Hidden by default */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

#nlb-overlay.nlb-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── Backdrop ────────────────────────────────────────────────────────────── */
#nlb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.94);
  cursor: zoom-out;
}

/* ── Stage (contains image) ──────────────────────────────────────────────── */
#nlb-stage {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: calc(100vw - 120px);
  max-height: calc(100vh - 80px);
}

@media (max-width: 600px) {
  #nlb-stage {
    max-width: 100vw;
    max-height: calc(100vh - 120px);
  }
}

/* ── Image ───────────────────────────────────────────────────────────────── */
#nlb-img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 120px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 3px;
  box-shadow:
    0 4px 6px -1px rgba(0,0,0,0.3),
    0 20px 60px -10px rgba(0,0,0,0.7);
  opacity: 0;
  transition:
    opacity 0.3s ease,
    transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  /* Start slightly scaled down for zoom-in effect */
  transform: scale(0.93);
  will-change: opacity, transform;
  cursor: default;
  /* Prevent default drag */
  -webkit-user-drag: none;
  user-select: none;
}

#nlb-img.nlb-loaded {
  opacity: 1;
  transform: scale(1);
}

/* Disable zoom animation when option is off */
#nlb-overlay:not(.nlb-zoom-enabled) #nlb-img {
  transform: none !important;
}

/* ── Spinner ─────────────────────────────────────────────────────────────── */
#nlb-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.2s;
}

#nlb-spinner.nlb-hidden {
  opacity: 0;
}

.nlb-spin-ring {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  animation: nlb-spin 0.75s linear infinite;
}

@keyframes nlb-spin {
  to { transform: rotate(360deg); }
}

/* ── Buttons (close / prev / next) ──────────────────────────────────────── */
#nlb-overlay button {
  /* Reset all browser styles */
  all: unset;
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px) saturate(1.5);
  -webkit-backdrop-filter: blur(8px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  transition:
    background  0.18s ease,
    transform   0.18s ease,
    border-color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

#nlb-overlay button:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.3);
}

#nlb-overlay button:active {
  transform: scale(0.93);
}

#nlb-overlay button svg {
  display: block;
  pointer-events: none;
}

/* ── Close button ────────────────────────────────────────────────────────── */
#nlb-close {
  top: 18px;
  right: 18px;
  width: 44px;
  height: 44px;
}

#nlb-close svg {
  width: 20px;
  height: 20px;
}

/* ── Prev / Next ─────────────────────────────────────────────────────────── */
#nlb-prev,
#nlb-next {
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
}

#nlb-prev:hover,
#nlb-next:hover {
  transform: translateY(-50%) scale(1.06);
}

#nlb-prev:active,
#nlb-next:active {
  transform: translateY(-50%) scale(0.94);
}

#nlb-prev { left: 16px; }
#nlb-next { right: 16px; }

#nlb-prev svg,
#nlb-next svg {
  width: 22px;
  height: 22px;
}

@media (max-width: 600px) {
  #nlb-prev { left: 8px; }
  #nlb-next { right: 8px; }
  #nlb-prev, #nlb-next { width: 44px; height: 44px; }
}

/* ── Caption ─────────────────────────────────────────────────────────────── */
#nlb-caption-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, transparent 100%);
  padding: 28px 20px 14px;
  border-radius: 0 0 3px 3px;
  pointer-events: none;
}

#nlb-caption {
  margin: 0;
  color: rgba(255, 255, 255, 0.92);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  letter-spacing: 0.01em;
}

/* ── Counter ─────────────────────────────────────────────────────────────── */
#nlb-counter {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  color: rgba(255, 255, 255, 0.6);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  white-space: nowrap;
  pointer-events: none;
}

/* Counter at bottom */
#nlb-overlay.nlb-counter-bottom #nlb-counter {
  top: auto;
  bottom: 20px;
}

/* Counter hidden */
#nlb-overlay.nlb-counter-hidden #nlb-counter {
  display: none !important;
}

/* ── Focus ring (accessibility) ──────────────────────────────────────────── */
#nlb-overlay button:focus-visible {
  outline: 2px solid rgba(255,255,255,0.8);
  outline-offset: 2px;
}

/* ── Reduced motion ──────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #nlb-overlay,
  #nlb-img,
  #nlb-overlay button {
    transition: none !important;
    animation: none !important;
  }
  .nlb-spin-ring {
    animation: none !important;
    border-top-color: rgba(255,255,255,0.85);
  }
}
