/* ── GALERÍA ── Pantalla completa con imagen grande y miniaturas debajo */
html.gallery-open {
  overflow: hidden;
}

.gallery {
  --gallery-ink: #ffffff;
  --gallery-bg: #0c0a0d;
  --gallery-accent: #d43d41;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: var(--gallery-bg);
  color: var(--gallery-ink);
  font-family: "DM Sans", system-ui, sans-serif;
}

html[data-theme="light"] .gallery {
  --gallery-accent: #3b4fe0;
}

.gallery[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
}

.gallery::backdrop {
  background: #0c0a0d;
}

.gallery__bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem clamp(0.75rem, 2vw, 1.5rem);
}

.gallery__title {
  margin: 0;
  font-family: "Archivo Black", "DM Sans", sans-serif;
  font-size: clamp(1.05rem, 2vw, 1.5rem);
  font-weight: 400;
  line-height: 1.1;
  text-transform: uppercase;
}

.gallery__counter {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.gallery__close,
.gallery__nav {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 3px solid var(--gallery-ink);
  background: var(--gallery-bg);
  color: var(--gallery-ink);
  cursor: pointer;
  transition: background 120ms linear, color 120ms linear;
}

.gallery__close svg,
.gallery__nav svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: square;
}

.gallery__close:hover,
.gallery__nav:hover {
  background: var(--gallery-ink);
  color: var(--gallery-bg);
}

.gallery__close {
  width: 2.75rem;
  height: 2.75rem;
  margin-left: auto;
}

.gallery__stage {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(0.5rem, 1.5vw, 1rem);
  min-height: 0;
  padding: 0 clamp(0.75rem, 2vw, 1.5rem);
}

.gallery__nav {
  width: 3rem;
  height: 4.5rem;
}

.gallery__frame {
  position: relative;
  height: 100%;
  min-height: 0;
  touch-action: pan-y pinch-zoom;
}

.gallery__image,
.gallery__video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.gallery__image {
  object-fit: contain;
  opacity: 0;
  transition: opacity 220ms ease;
}

.gallery__image.is-visible {
  opacity: 1;
}

.gallery__caption {
  min-height: 1.4em;
  margin: 0;
  padding: 0.6rem 1rem 0;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
}

/* Carrusel: el relleno lateral permite centrar también la primera y la última */
.gallery__thumbs {
  --thumb-width: clamp(5.5rem, 9vw, 8rem);
  display: flex;
  gap: 0.5rem;
  margin: 0;
  padding: 0.75rem calc(50% - var(--thumb-width) / 2) 1rem;
  overflow-x: auto;
  list-style: none;
  scrollbar-width: none;
}

.gallery__thumbs::-webkit-scrollbar {
  display: none;
}

.gallery__thumbs li {
  flex: 0 0 auto;
}

.gallery__thumb {
  position: relative;
  display: block;
  width: var(--thumb-width);
  aspect-ratio: 16 / 10;
  padding: 0;
  overflow: hidden;
  border: 3px solid transparent;
  background: #1b181c;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 120ms linear, border-color 120ms linear;
}

.gallery__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery__thumb:hover,
.gallery__thumb:focus-visible {
  opacity: 1;
}

.gallery__thumb[aria-current="true"] {
  border-color: var(--gallery-ink);
  opacity: 1;
}

/* Triángulo de reproducir sobre la miniatura de un video */
.gallery__thumb--video::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  border-style: solid;
  border-width: 0.65rem 0 0.65rem 1.1rem;
  border-color: transparent transparent transparent var(--gallery-ink);
  transform: translate(-40%, -50%);
}

.gallery :focus-visible {
  outline: 3px solid var(--gallery-accent);
  outline-offset: 2px;
}

.gallery--single .gallery__nav,
.gallery--single .gallery__thumbs,
.gallery--single .gallery__counter {
  display: none;
}

@media (max-width: 700px) {
  .gallery__stage {
    position: relative;
    grid-template-columns: minmax(0, 1fr);
    padding: 0;
  }

  .gallery__frame {
    grid-column: 1;
    grid-row: 1;
  }

  .gallery__nav {
    position: absolute;
    top: 50%;
    z-index: 1;
    width: 2.75rem;
    height: 3.5rem;
    transform: translateY(-50%);
  }

  .gallery__nav--prev {
    left: 0.25rem;
  }

  .gallery__nav--next {
    right: 0.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery__image {
    transition: none;
  }
}
