/* Image and video galleries */
.project-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 1.25rem;
  margin: 1.5rem auto 2rem;
}

/* Force two items side by side */
.project-gallery.project-pair {
  max-width: 760px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.project-gallery > figure,
.project-figure {
  min-width: 0;
  margin: 0;
}

/* Images */
.project-gallery img,
.project-figure img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 0.35rem;
}

.project-gallery img {
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

/* Preserve complete diagrams and portrait images within gallery cells */
.project-gallery.project-contain img {
  object-fit: contain;
}

.project-figure {
  max-width: 720px;
  margin: 1.5rem auto 2rem;
}

/* Optional sizes for detail photos and technical drawings */
.project-figure.project-compact {
  max-width: 540px;
}

.project-figure.project-wide {
  max-width: 900px;
}

/* Captions */
.project-caption {
  margin: 0.65rem 0 0;
  font-size: 0.875rem;
  line-height: 1.5;
  text-align: center;
}

/* Videos */
.project-video {
  width: 100%;
  max-width: 720px;
  margin: 1.5rem auto 2rem;
}

.project-gallery .project-video {
  max-width: none;
  margin: 0;
}

.project-video-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 0.35rem;
  background: #111;
}

.project-video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Collapsible details */
.project-details {
  margin: 1.5rem 0 2rem;
  padding: 1rem;
  border: 1px solid var(--global-divider-color, #ddd);
  border-radius: 0.35rem;
}

.project-details summary {
  cursor: pointer;
  font-weight: 500;
}

.project-details .project-gallery {
  margin-bottom: 0;
}

/* Three images side by side */
.project-gallery.project-trio {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 900px;
}

@media (max-width: 600px) {
  .project-gallery.project-trio {
    grid-template-columns: 1fr;
  }
}

/* Small screens */
@media (max-width: 600px) {
  .project-gallery.project-pair {
    grid-template-columns: 1fr;
  }
}
