/* Galería FHAyCS - plg_content_fhaycsgaleria */

.fhg {
  --fhg-cols: 4;
  --fhg-ratio: 4/3;
  --fhg-gap: .5rem;
  --fhg-accent: #b00060;
  display: grid;
  grid-template-columns: repeat(var(--fhg-cols), minmax(0, 1fr));
  gap: var(--fhg-gap);
  margin: 1.5rem 0;
}

/* En pantallas chicas se limitan las columnas */
@media (max-width: 767px) {
  .fhg { grid-template-columns: repeat(min(var(--fhg-cols), 3), minmax(0, 1fr)); }
}
@media (max-width: 479px) {
  .fhg { grid-template-columns: repeat(min(var(--fhg-cols), 2), minmax(0, 1fr)); }
}

.fhg__item {
  display: block;
  overflow: hidden;
  border-radius: 4px;
  background: #eee;
  line-height: 0;
}
.fhg__item:focus-visible {
  outline: 3px solid var(--fhg-accent);
  outline-offset: 2px;
}

.fhg__img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: var(--fhg-ratio);
  object-fit: cover;
  transition: transform .3s ease, opacity .3s ease;
}
.fhg--original .fhg__img { aspect-ratio: auto; }
.fhg__item:hover .fhg__img { transform: scale(1.04); opacity: .92; }

@media (prefers-reduced-motion: reduce) {
  .fhg__img { transition: none; }
  .fhg__item:hover .fhg__img { transform: none; }
}

/* Aviso de error (solo visible para editores) */
.fhg-error {
  padding: .75rem 1rem;
  border-left: 4px solid #b00060;
  background: #fdf0f6;
  color: #5a0030;
  font-size: .9rem;
}

/* ---------- Lightbox ---------- */

.fhg-lb {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(10, 10, 10, .94);
  color: #fff;
  overflow: hidden;
}
.fhg-lb::backdrop { background: rgba(0, 0, 0, .6); }
.fhg-lb[open] { display: flex; align-items: center; justify-content: center; }

.fhg-lb__img {
  max-width: calc(100vw - 7rem);
  max-height: calc(100dvh - 5rem);
  object-fit: contain;
  user-select: none;
  touch-action: pan-y;
  transition: opacity .2s ease;
}
.fhg-lb__img.is-loading { opacity: .3; }

.fhg-lb__btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font: 400 1.75rem/1 system-ui, sans-serif;
  cursor: pointer;
}
.fhg-lb__btn:hover { background: var(--fhg-accent, #b00060); }
.fhg-lb__btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

.fhg-lb__close { top: 1rem; right: 1rem; }
.fhg-lb__prev  { left: 1rem; top: 50%; transform: translateY(-50%); }
.fhg-lb__next  { right: 1rem; top: 50%; transform: translateY(-50%); }

.fhg-lb__count {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  font: .875rem/1 system-ui, sans-serif;
  opacity: .8;
}

.fhg-lb--single .fhg-lb__prev,
.fhg-lb--single .fhg-lb__next,
.fhg-lb--single .fhg-lb__count { display: none; }

@media (max-width: 600px) {
  .fhg-lb__img { max-width: 100vw; max-height: calc(100dvh - 8rem); }
  .fhg-lb__prev, .fhg-lb__next { top: auto; bottom: 1rem; transform: none; }
  .fhg-lb__count { bottom: 2rem; }
}

html.fhg-lock { overflow: hidden; }
