/*
 * plg_content_foldergallery - grid + lightbox styling.
 * Scoped entirely under .fg- classes so it can't leak into the rest of a page.
 */

.fg-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin: 1em 0;
}

.fg-item {
  display: block;
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 4px;
  background: #e9e9e9;
}

.fg-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}

.fg-item:hover .fg-thumb,
.fg-item:focus-visible .fg-thumb {
  transform: scale(1.05);
}

.fg-missing {
  padding: 0.6em 0.9em;
  border: 1px dashed #c99;
  border-radius: 4px;
  color: #944;
  background: #fdf2f2;
  font-size: 0.9em;
}

/* ---------- lightbox overlay (built once per page by foldergallery.js) --- */

.fg-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.88);
  padding: 3vh 3vw;
}

.fg-lightbox[hidden] {
  display: none;
}

.fg-lightbox__figure {
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5em;
}

.fg-lightbox__img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.fg-lightbox__caption {
  color: #eee;
  font-size: 0.95em;
  text-align: center;
  min-height: 1.2em;
}

.fg-lightbox__counter {
  color: #aaa;
  font-size: 0.8em;
}

.fg-lightbox__btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  border: 0;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  width: 2.4em;
  height: 2.4em;
  border-radius: 50%;
  cursor: pointer;
}

.fg-lightbox__btn:hover,
.fg-lightbox__btn:focus-visible {
  background: rgba(255, 255, 255, 0.25);
}

.fg-lightbox__prev {
  left: 2vw;
}

.fg-lightbox__next {
  right: 2vw;
}

.fg-lightbox__close {
  position: absolute;
  top: 2vh;
  right: 2vw;
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  width: 1.6em;
  height: 1.6em;
}

.fg-lightbox__close:hover,
.fg-lightbox__close:focus-visible {
  color: #ccc;
}

@media (max-width: 600px) {
  .fg-gallery {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 4px;
  }

  .fg-lightbox__btn {
    font-size: 1.5rem;
  }
}
