/* ==========================================================================
   MediaGallery + Lightbox — 07 §10.4, §10.5
   ========================================================================== */

/* --- MediaGallery ----------------------------------------------------------
   A static grid: every thumbnail and caption is visible at once, nothing sits
   behind a slider (07 §10.4). Real aspect ratio is kept — no forced crop. */

.media-gallery__list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr));
  gap: var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
}

.media-gallery__item {
  /* Same defense-in-depth reasoning as .review-card (reviews.css, 2026-08-04):
     the .visually-hidden "Ampliar imagen" span inside this button is
     position:absolute — not currently at risk since .media-gallery__list is
     a static wrapping grid (every item sits within the viewport, unlike the
     carousel's un-scrolled full-width row), but giving every button its own
     positioning context costs nothing and removes the precondition entirely
     rather than relying on this grid never changing shape. */
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  text-align: left;
  background: none;
  border: 0;
  cursor: zoom-in;
}

.media-gallery__thumb {
  width: 100%;
  height: auto;
  border-radius: var(--radius-image);
  transition: opacity var(--transition-fast);
}

.media-gallery__item:hover .media-gallery__thumb {
  opacity: 0.9;
}

.media-gallery__caption {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* --- Lightbox ---------------------------------------------------------------
   Dialog accessible pattern: backdrop + centered figure. Content is swapped
   by lightbox.js per activation rather than one dialog per image. */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox[hidden] {
  display: none;
}

.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background-color: rgb(46 35 26 / 88%); /* --color-tinta, not pure black (03 §7.1) */
}

.lightbox__dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: min(90vw, 70rem);
  max-height: 90vh;
  padding: var(--space-6);
}

.lightbox__figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
}

.lightbox__image {
  display: block;
  max-width: 100%;
  max-height: 74vh;
  width: auto;
  height: auto;
  border-radius: var(--radius-image);
}

.lightbox__caption {
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-on-dark-muted);
  text-align: center;
}

.lightbox__caption:empty {
  display: none;
}

.lightbox__close,
.lightbox__prev,
.lightbox__next {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--touch-target-primary);
  min-height: var(--touch-target-primary);
  font-size: var(--text-lg);
  color: var(--color-papel-oscuro);
  background-color: rgb(46 35 26 / 55%);
  border: 0;
  border-radius: var(--radius-pill);
}

.lightbox__close:hover,
.lightbox__prev:hover,
.lightbox__next:hover {
  background-color: rgb(46 35 26 / 75%);
}

.lightbox__close {
  top: var(--space-4);
  right: var(--space-4);
}

.lightbox__prev,
.lightbox__next {
  top: 50%;
  transform: translateY(-50%);
}

.lightbox__prev {
  left: var(--space-4);
}

.lightbox__next {
  right: var(--space-4);
}

.lightbox__position {
  margin: var(--space-4) 0 0;
  font-size: var(--text-xs);
  color: var(--text-on-dark-muted);
}

@media (max-width: 36rem) {
  .lightbox__dialog {
    max-width: 100vw;
    padding: var(--space-4);
  }

  .lightbox__prev,
  .lightbox__next {
    min-width: var(--touch-target);
    min-height: var(--touch-target);
  }
}
