/*!
 * pelotapasto — pp-lightbox.css
 * Lightbox para galerías del Archivo.
 *
 * v5 — Marco negro integral + protección de fotos:
 * - Marco sólido contiene título, foto, caption, counter, toolbar
 * - Escudo transparente sobre la foto
 * - Blur al perder foco de ventana
 * - Mobile-first, fuera de @layer
 */

/* ── Overlay ── */

.pp-lb {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: none;
  align-items: center;
  justify-content: center;
}

.pp-lb--open {
  display: flex;
}

.pp-lb__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  cursor: pointer;
}

/* ── Stage ── */

.pp-lb__stage {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100vw;
  max-height: 100vh;
  padding: 40px 0 12px;
  box-sizing: border-box;
}

/* ── Frame (solid black, contains everything) ── */

.pp-lb__frame {
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  max-width: 100vw;
  max-height: calc(100vh - 52px);
  padding: 12px 12px 14px;
  box-sizing: border-box;
}

/* ── Title (event info, top of frame) ── */

.pp-lb__title {
  color: rgba(255, 255, 255, 0.55);
  font-family: var(--pp-font-ui, "Inter", sans-serif);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.4;
  padding-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
  text-align: left;
  flex-shrink: 0;
}

/* ── Image wrapper (holds img + shield) ── */

.pp-lb__img-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 1;
  min-height: 0;
}

/* Shield: transparent overlay blocking direct image interaction */
.pp-lb__shield {
  position: absolute;
  inset: 0;
  z-index: 1;
  cursor: default;
  /* Fully transparent but captures all pointer events */
  background: transparent;
  -webkit-touch-callout: none;
}

/* ── Image ── */

.pp-lb__img {
  display: block;
  max-width: calc(100vw - 24px);
  max-height: 66vh;
  object-fit: contain;
  opacity: 0;
  transition: opacity 200ms ease;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  pointer-events: none; /* shield handles interaction */
}

.pp-lb__img--loaded {
  opacity: 1;
}

/* ── Caption (IPTC description) ── */

.pp-lb__caption {
  color: rgba(255, 255, 255, 0.48);
  font-family: var(--pp-font-ui, "Inter", sans-serif);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.5;
  text-align: left;
  margin: 0;
  padding-top: 8px;
  user-select: none;
  flex-shrink: 0;
}

.pp-lb__caption:empty {
  display: none;
}

/* ── Counter ── */

.pp-lb__counter {
  color: rgba(255, 255, 255, 0.35);
  font-family: var(--pp-font-ui, "Inter", sans-serif);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-align: center;
  padding-top: 6px;
  user-select: none;
  flex-shrink: 0;
}

/* ── Toolbar ── */

.pp-lb__toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding-top: 8px;
  flex-shrink: 0;
}

.pp-lb__tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.85);
  font-family: var(--pp-font-ui, "Inter", sans-serif);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
  user-select: none;
  white-space: nowrap;
}

.pp-lb__tool-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
}

.pp-lb__tool-btn:active {
  background: rgba(255, 255, 255, 0.22);
}

.pp-lb__tool-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.pp-lb__tool-btn--active {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.32);
  color: #fff;
}

.pp-lb__tool-btn--disabled {
  opacity: 0.4;
  cursor: default;
}

.pp-lb__tool-btn--disabled:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.85);
}

.pp-lb__tool-icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.pp-lb__tool-icon svg {
  display: block;
}

.pp-lb__tool-label {
  display: inline;
}

/* ── Spinner ── */

.pp-lb__spinner {
  position: absolute;
  z-index: 0;
  width: 32px;
  height: 32px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  animation: ppLbSpin 0.7s linear infinite;
  top: 50%;
  left: 50%;
  margin: -16px 0 0 -16px;
}

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

/* ── Navigation + Close ── */

.pp-lb__btn {
  position: absolute;
  z-index: 2;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  line-height: 1;
  transition: color 160ms ease;
}

.pp-lb__btn:hover {
  color: #fff;
}

.pp-lb__close {
  top: 10px;
  right: 14px;
  font-size: 32px;
  z-index: 4;
}

.pp-lb__prev,
.pp-lb__next {
  display: none;
  top: 50%;
  transform: translateY(-50%);
  font-size: 48px;
  padding: 16px;
}

.pp-lb__prev { left: 8px; }
.pp-lb__next { right: 8px; }

/* ── Toast ── */

.pp-lb__toast {
  position: absolute;
  z-index: 5;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  padding: 10px 22px;
  background: rgba(38, 56, 46, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  color: #fff;
  font-family: var(--pp-font-ui, "Inter", sans-serif);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease, transform 200ms ease;
}

.pp-lb__toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Blurred state (anti-screenshot) ── */

.pp-lb--blurred .pp-lb__img {
  filter: blur(30px) brightness(0.3);
  transition: filter 80ms ease;
}

/* ════════════════════════════════════════════════
   Desktop (>820px)
   ════════════════════════════════════════════════ */

@media (min-width: 821px) {

  .pp-lb__stage {
    max-width: 94vw;
    padding: 32px 0 16px;
  }

  .pp-lb__frame {
    max-width: 92vw;
    max-height: calc(100vh - 48px);
    padding: 14px 16px 16px;
  }

  .pp-lb__img {
    max-width: calc(92vw - 32px);
    max-height: 70vh;
  }

  .pp-lb__title {
    font-size: 12px;
    padding-bottom: 10px;
  }

  .pp-lb__close {
    top: 14px;
    right: 20px;
    font-size: 36px;
  }

  .pp-lb__prev,
  .pp-lb__next {
    display: block;
  }

  .pp-lb__caption {
    font-size: 12px;
    padding-top: 10px;
  }

  .pp-lb__counter {
    font-size: 12px;
    padding-top: 8px;
  }

  .pp-lb__toolbar {
    gap: 10px;
    padding-top: 10px;
  }

  .pp-lb__tool-btn {
    padding: 9px 18px;
    font-size: 13px;
    gap: 8px;
  }

  .pp-lb__toast {
    font-size: 13px;
    padding: 9px 22px;
  }
}
