/* Visor de imágenes (dialog nativo) — pantalla completa, fondo translúcido, controles circulares.
   Lo mueve ds/js/lightbox.js: --lb-o (0–1) es la presencia del visor (fondo y controles) al abrir, cerrar o arrastrar. */
#imagePanel {
  --lb-o: 1;
  position: fixed; inset: 0;
  width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: transparent; color: #fff;
  overflow: hidden;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr);   /* columna = ancho de pantalla, nunca el de la foto */
  font-family: Arial, Helvetica, sans-serif;
}
#imagePanel:not([open]) { display: none; }
#imagePanel::backdrop { background: transparent; }
html.lb-open { overflow: hidden; }

/* material: capa oscura translúcida que desenfoca la página de detrás */
#imagePanel .lb-bg {
  position: absolute; inset: 0; z-index: -1;   /* detrás de todo, dentro del visor */
  background: rgba(14, 13, 15, .86);
  -webkit-backdrop-filter: blur(24px) saturate(140%); backdrop-filter: blur(24px) saturate(140%);
  opacity: var(--lb-o);
}
#imagePanel .lb-top, #imagePanel .ft { opacity: var(--lb-o); }   /* sin posicionar: las flechas se sitúan respecto al visor */

/* barra superior: contador | cerrar */
#imagePanel .lb-top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 4px max(20px, env(safe-area-inset-left));
}
#imagePanel .lb-count { font-size: .8125rem; letter-spacing: .02em; color: rgba(255,255,255,.72); font-variant-numeric: tabular-nums; }

/* escenario: la foto centrada, tan grande como quepa */
#imagePanel .bd {
  position: relative; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 8px 88px;
  overflow: hidden;
  touch-action: pinch-zoom;   /* el dedo mueve la foto (lightbox.js); el pellizco sigue siendo del navegador */
}
#imagePanel #bigimage {
  display: block; max-width: 100%; max-height: 100%;
  width: auto; height: auto; object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 24px 64px rgba(0,0,0,.55);
  transform-origin: 50% 50%;
  -webkit-user-drag: none; user-select: none;
  transition: opacity .2s;
}
#imagePanel.loading #bigimage { opacity: .3; }

.lb-spinner {
  position: absolute; left: 50%; top: 50%; width: 28px; height: 28px; margin: -14px 0 0 -14px;
  border: 3px solid rgba(255,255,255,.2); border-top-color: #fff; border-radius: 50%;
  animation: lbspin .8s linear infinite; display: none;
}
#imagePanel.loading .lb-spinner { display: block; }
@keyframes lbspin { to { transform: rotate(360deg); } }

/* pie: título + PDF, centrados */
#imagePanel .ft {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 10px 16px max(16px, env(safe-area-inset-bottom));
  min-height: 44px;
}
#imagetitle { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 14px; text-align: center; line-height: 1.3; }
#imagetitle .lb-name { font-family: Georgia, "Times New Roman", serif; font-size: 1.0625rem; color: #fff; }

/* controles: círculos de material claro sobre el fondo oscuro */
.lb-glass {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid rgba(255,255,255,.16); border-radius: 999px;
  background: rgba(255,255,255,.1); color: #fff;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  cursor: pointer; padding: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .15s, transform .12s ease-out;
}
.lb-glass svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.lb-glass:active { transform: scale(.94); background: rgba(255,255,255,.24); }
.lb-glass:focus-visible { outline: 2px solid #D4D444; outline-offset: 3px; }
@media (hover: hover) { .lb-glass:hover { background: rgba(255,255,255,.2); } }

.lb-close { width: 44px; height: 44px; }
.lb-nav { position: absolute; top: 50%; width: 52px; height: 52px; margin-top: -26px; }
.lb-nav svg { width: 24px; height: 24px; }
.lb-prev { left: max(20px, env(safe-area-inset-left)); }
.lb-next { right: max(20px, env(safe-area-inset-right)); }
.lb-nav[hidden] { display: none; }

#imagetitle a.lb-pill {   /* #imagetitle: gana a "#imagetitle a { padding: 0 0 0 5px }" de cisitalia.css */
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px; flex: none; white-space: nowrap;
  border: 1px solid rgba(255,255,255,.16); border-radius: 999px;
  background: rgba(255,255,255,.1); color: #fff;
  font: bold .75rem/1 Arial, Helvetica, sans-serif; letter-spacing: .06em; text-transform: uppercase; text-decoration: none;
  transition: background-color .15s, transform .12s ease-out;
}
a.lb-pill:link, a.lb-pill:visited { color: #fff; }
a.lb-pill svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
a.lb-pill:active { transform: scale(.96); background: rgba(255,255,255,.24); text-decoration: none; }
a.lb-pill:focus-visible { outline: 2px solid #D4D444; outline-offset: 3px; }
@media (hover: hover) { a.lb-pill:hover { background: rgba(255,255,255,.2); color: #fff; text-decoration: none; } }

/* móvil: foto a todo el ancho; anterior/siguiente pasan al pie, a los lados del título (no tapan la foto) */
@media (max-width: 767px), (pointer: coarse) {
  #imagePanel .bd { padding: 8px 0; }
  #imagePanel #bigimage { border-radius: 0; box-shadow: none; }
  .lb-nav { position: static; margin: 0; width: 44px; height: 44px; flex: none; }
  .lb-nav svg { width: 20px; height: 20px; }
  #imagePanel .ft { justify-content: space-between; }
  #imagetitle { flex: 1; min-width: 0; }
}

/* accesibilidad: menos transparencia = superficies opacas; más contraste = bordes definidos */
@media (prefers-reduced-transparency: reduce) {
  #imagePanel .lb-bg { background: rgb(14, 13, 15); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .lb-glass, a.lb-pill { background: #3a383c; -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  #imagePanel .lb-bg { background: #000; }
  .lb-glass, a.lb-pill { background: #222; border-color: #fff; }
}
