.gallery-photo-viewer {
  --gallery-text-shadow: 0 2px 4px rgba(37, 19, 56, .75);
  position: fixed;
  inset: 0;
  width: min(calc(100vw - 24px), calc((100vh - 120px) * var(--gallery-frame-aspect, 1.4)), 1120px);
  width: min(calc(100vw - 24px), calc((100dvh - 120px) * var(--gallery-frame-aspect, 1.4)), 1120px);
  height: fit-content;
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: #f6edf1;
  overflow: visible;
}
.gallery-photo-viewer::backdrop { background: transparent; }
body:has(.gallery-photo-viewer[open]) .controls { visibility: hidden; }
.gallery-photo-figure { margin: 0; }
.gallery-photo-frame { position: relative; width: 100%; aspect-ratio: var(--gallery-frame-aspect, 1.4); margin: 0; }
.gallery-photo-caption {
  box-sizing: border-box;
  min-height: 48px;
  margin: 0;
  padding: 24px calc(2% + 52px) 0 calc(var(--gallery-image-left, 7.1428571429%) * .45 + 6px);
  color: #f6edf1;
  font: 500 20px/24px "Segoe UI", sans-serif;
  text-align: left;
  letter-spacing: .025em;
  text-shadow: var(--gallery-text-shadow);
}
.gallery-photo-border { position: relative; display: block; width: 100%; height: 100%; pointer-events: none; }
.gallery-photo-original {
  position: absolute;
  left: var(--gallery-image-left, 7.1428571429%);
  top: var(--gallery-image-top, 10%);
  width: var(--gallery-image-width, 85.7142857143%);
  height: var(--gallery-image-height, 80%);
  display: block;
  object-fit: contain;
}
/* Croix (15 nov., demande de l'utilisateur) : à droite du coin supérieur droit du cadre, un peu au-dessus, comme
   sur les fiches de l'arcade. Sur un écran étroit, elle reste dans la fenêtre et passe au-dessus du coin. */
.gallery-photo-viewer .gallery-photo-close {
  position: absolute;
  z-index: 1;
  left: min(calc(100% - var(--gallery-frame-edge-x, 3.2142857%) + 4px), calc((100vw + 100%) / 2 - 52px));
  top: calc(var(--gallery-frame-edge-y, 4.5%) - 39px);
  visibility: visible;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #f6edf1;
  box-shadow: none;
  text-shadow: var(--gallery-text-shadow);
  font: 300 42px/1 "Segoe UI", sans-serif;
}
.gallery-photo-viewer .gallery-photo-close:hover { background: transparent; color: #fff; }
.gallery-photo-viewer .gallery-photo-close:focus-visible { outline: 2px solid #9be6f2; outline-offset: 3px; }
/* Survol d’un tableau : halo jaune dégradé (src/render/highlight-glow.js), le même que les PNJ. */
[data-gallery-photo] { outline: none; }
[data-gallery-glow] { display: none; }
[data-gallery-photo][data-gallery-hovered] + [data-gallery-glow],
[data-gallery-photo][data-gallery-selected] + [data-gallery-glow] { display: inline; }
/* Pendant le décodage, seule la croix reste visible ; au-delà de 700 ms, le cadre
   s’affiche avec un message plutôt qu’une ouverture vide. */
.gallery-photo-viewer[data-gallery-loading] .gallery-photo-figure { visibility: hidden; }
.gallery-photo-viewer[data-gallery-loading="slow"] .gallery-photo-figure { visibility: visible; }
.gallery-photo-loading {
  display: none;
  position: absolute;
  inset: 45% 12% auto;
  margin: 0;
  color: #f6edf1;
  font: 500 16px/20px "Segoe UI", sans-serif;
  text-align: center;
  text-shadow: var(--gallery-text-shadow);
}
.gallery-photo-viewer[data-gallery-loading="slow"] .gallery-photo-loading { display: block; }
.gallery-photo-error { position: absolute; inset: 35% 12% auto; margin: 0; padding: 16px; background: #30243c; text-align: center; }
@media (max-width: 760px) {
  .gallery-photo-viewer .gallery-photo-close { top: calc(var(--gallery-frame-edge-y, 4.5%) - 50px); }
}
