/* Galería justificada: cada imagen crece en proporción a su relación de aspecto (--cc-r = ancho/alto),
   así todas las de una fila quedan a la misma altura y la fila ocupa todo el ancho. */
.cc-galeria {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cc-margen, 2px);
  margin: 0 0 1.5em;
}

.cc-galeria::after {
  /* La última fila no se estira */
  content: "";
  flex-grow: 999999;
}

.cc-galeria a {
  display: block;
  flex: calc(var(--cc-r) * 100) 1 calc(var(--cc-r) * var(--cc-altura, 300px));
  overflow: hidden;
  background: #e6e6e6;
}

/* "a img" para ganar a .item-page img de la plantilla (flotado, márgenes, borde y sombra) */
.cc-galeria a img {
  display: block;
  float: none;
  width: 100%;
  max-width: none;
  height: auto;
  aspect-ratio: var(--cc-r);
  object-fit: cover;
  margin: 0;
  border: 0;
  box-shadow: none;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.cc-galeria a:hover img,
.cc-galeria a:focus-visible img {
  /* (misma especificidad que la regla anterior, va después) */
  transform: scale(1.04);
  opacity: 0.9;
}

/* Visor de imágenes ampliadas */
.cc-visor {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: hidden;
}

.cc-visor::backdrop {
  background: rgba(0, 0, 0, 0.88);
}

.cc-visor figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  margin: 0;
}

.cc-visor img {
  max-width: calc(100vw - 120px);
  max-height: calc(100vh - 80px);
  object-fit: contain;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.6);
  user-select: none;
}

.cc-visor figcaption {
  margin-top: 10px;
  color: #ddd;
  font-family: "Lato", sans-serif;
  font-size: 14px;
}

.cc-visor button {
  position: absolute;
  border: 0;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 42px;
  line-height: 1;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  cursor: pointer;
}

.cc-visor button:hover,
.cc-visor button:focus-visible {
  background: rgba(41, 136, 189, 0.85);
  outline: none;
}

.cc-visor__cerrar { top: 14px; right: 14px; font-size: 34px; }
.cc-visor__ant { top: 50%; left: 14px; transform: translateY(-50%); }
.cc-visor__sig { top: 50%; right: 14px; transform: translateY(-50%); }

@media (max-width: 640px) {
  .cc-galeria a { flex-basis: calc(var(--cc-r) * 140px); }
  .cc-visor img { max-width: 100vw; }
  .cc-visor__ant, .cc-visor__sig { top: auto; bottom: 14px; transform: none; }
}
