/* ==========================================================================
   Galería de fotos — carrusel, composición y visor
   Usa las variables y el lenguaje visual del sitio.
   ========================================================================== */

.gallery-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   Carrusel de portada
   -------------------------------------------------------------------------- */

.gallery-carousel {
  position: relative;
}

html:not(.js) .gallery-carousel__controls {
  display: none;
}

.gallery-carousel__viewport {
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--ink);
  box-shadow: var(--shadow-md);
}

.gallery-carousel__track {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.gallery-carousel__track::-webkit-scrollbar {
  display: none;
}

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

.gallery-carousel__slide {
  position: relative;
  flex: 0 0 100%;
  min-width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: var(--ink);
}

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

.gallery-carousel__caption {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 46px 22px 18px;
  background: linear-gradient(transparent, rgba(7, 21, 51, 0.86));
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.gallery-carousel__caption span {
  display: block;
  color: var(--amber);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.gallery-carousel__controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.gallery-carousel__dots {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 38px;
}

.gallery-carousel__dot {
  position: relative;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.gallery-carousel__dot::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--paper);
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease),
    transform 0.2s var(--ease);
}

.gallery-carousel__dot:hover::after {
  border-color: var(--brand);
}

.gallery-carousel__dot[aria-current="true"]::after {
  border-color: var(--brand);
  background: var(--brand);
  transform: scale(1.25);
}

.gallery-carousel__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gallery-carousel__count {
  min-width: 44px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.gallery-carousel__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease),
    color 0.2s var(--ease);
}

.gallery-carousel__btn:hover {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.gallery-carousel__btn .icon {
  width: 17px;
  height: 17px;
}

.gallery-carousel__btn--prev .icon {
  transform: rotate(180deg);
}

.gallery-carousel__btn--toggle {
  width: auto;
  height: 38px;
  padding: 0 13px;
  border-radius: 999px;
  color: var(--body);
  font-size: 12px;
  font-weight: 700;
}

.gallery-carousel__btn:focus-visible,
.gallery-carousel__dot:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 3px;
}

/* --------------------------------------------------------------------------
   Composición de la galería
   -------------------------------------------------------------------------- */

.gallery-collage {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-auto-rows: clamp(84px, 9.5vw, 132px);
  grid-auto-flow: dense;
  gap: clamp(8px, 1.1vw, 14px);
}

.gallery-collage__item {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--cream-2);
  color: #fff;
  text-decoration: none;
}

.gallery-collage__item:nth-child(1) {
  grid-column: span 4;
  grid-row: span 2;
}

.gallery-collage__item:nth-child(2) {
  grid-column: span 2;
  grid-row: span 1;
}

.gallery-collage__item:nth-child(3) {
  grid-column: span 2;
  grid-row: span 1;
}

.gallery-collage__item:nth-child(4),
.gallery-collage__item:nth-child(5),
.gallery-collage__item:nth-child(6),
.gallery-collage__item:nth-child(9),
.gallery-collage__item:nth-child(10),
.gallery-collage__item:nth-child(11) {
  grid-column: span 2;
  grid-row: span 2;
}

.gallery-collage__item:nth-child(7),
.gallery-collage__item:nth-child(8) {
  grid-column: span 3;
  grid-row: span 2;
}

.gallery-collage__item:nth-child(12) {
  grid-column: span 6;
  grid-row: span 2;
}

.gallery-collage__item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.55s var(--ease);
}

.gallery-collage__item::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 58%;
  background: linear-gradient(transparent, rgba(7, 21, 51, 0.8));
  pointer-events: none;
  transition: opacity 0.25s var(--ease);
}

.gallery-collage__item:hover img,
.gallery-collage__item:focus-visible img {
  transform: scale(1.035);
}

.gallery-collage__item:hover::after,
.gallery-collage__item:focus-visible::after {
  opacity: 0.92;
}

.gallery-collage__label {
  position: absolute;
  right: 14px;
  bottom: 12px;
  left: 14px;
  z-index: 1;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  text-shadow: 0 1px 8px rgba(7, 21, 51, 0.35);
}

.gallery-collage__label span {
  display: block;
  color: var(--amber);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

/* --------------------------------------------------------------------------
   Visor de fotos
   -------------------------------------------------------------------------- */

.gallery-lightbox {
  width: min(94vw, 1120px);
  max-width: 1120px;
  max-height: 92vh;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-lg);
}

.gallery-lightbox::backdrop {
  background: rgba(7, 21, 51, 0.82);
  backdrop-filter: blur(5px);
}

.gallery-lightbox__figure {
  display: flex;
  flex-direction: column;
  margin: 0;
}

.gallery-lightbox__img {
  display: block;
  width: 100%;
  max-height: min(74vh, 760px);
  object-fit: contain;
  background: var(--ink-2);
}

.gallery-lightbox__caption {
  padding: 14px 18px;
  color: #c5d2de;
  font-size: 13px;
  line-height: 1.45;
}

.gallery-lightbox__caption span {
  display: block;
  color: var(--amber);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.gallery-lightbox__caption strong {
  color: #fff;
  font-weight: 600;
}

.gallery-lightbox__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(7, 21, 51, 0.7);
}

.gallery-lightbox__count {
  flex: 1;
  color: #aebfcd;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.gallery-lightbox__btn {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.gallery-lightbox__btn:hover {
  border-color: var(--brand);
  background: var(--brand);
}

.gallery-lightbox__btn .icon {
  width: 18px;
  height: 18px;
}

.gallery-lightbox__btn--prev .icon {
  transform: rotate(180deg);
}

.gallery-lightbox__btn--close {
  margin-left: 4px;
}

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

html.lightbox-open {
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .gallery-carousel__controls {
    padding-right: 58px;
  }
}

@media (max-width: 760px) {
  .gallery-carousel__slide {
    aspect-ratio: 4 / 3;
  }

  .gallery-carousel__caption {
    padding: 38px 16px 14px;
    font-size: 12px;
  }

  .gallery-carousel__count {
    display: none;
  }

  .gallery-carousel__btn {
    width: 36px;
    height: 36px;
  }

  .gallery-carousel__btn--toggle {
    width: auto;
    height: 36px;
    padding: 0 11px;
  }

  .gallery-collage {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: 110px;
  }

  .gallery-collage__item:nth-child(n) {
    grid-column: span 2;
    grid-row: span 2;
  }

  .gallery-collage__item:nth-child(1),
  .gallery-collage__item:nth-child(12) {
    grid-column: span 4;
  }

  .gallery-lightbox {
    width: 96vw;
    max-height: 94vh;
  }

  .gallery-lightbox__img {
    max-height: 64vh;
  }
}

@media (max-width: 600px) {
  .gallery-collage {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 118px;
    gap: 8px;
  }

  .gallery-collage__item:nth-child(n) {
    grid-column: span 1;
    grid-row: span 2;
  }

  .gallery-collage__item:nth-child(1),
  .gallery-collage__item:nth-child(12) {
    grid-column: span 2;
  }

  .gallery-collage__label {
    right: 10px;
    bottom: 9px;
    left: 10px;
    font-size: 11px;
  }

  .gallery-collage__label span {
    font-size: 9px;
  }

  .gallery-lightbox__caption {
    padding: 12px 14px;
  }

  .gallery-lightbox__bar {
    padding: 8px 10px;
  }

  .gallery-lightbox__btn {
    width: 38px;
    height: 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-carousel__track {
    scroll-behavior: auto;
  }

  .gallery-collage__item img,
  .gallery-collage__item::after,
  .gallery-carousel__dot {
    transition: none;
  }
}
