/* ============================================================
   Photo Grid Layout for Blog Posts
   ============================================================ */

.photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
  margin: 1.8rem 0 !important;
  padding: 0 !important;
  align-items: stretch; /* Cards in the same row stretch to equal height */
}

.photo-grid-item {
  flex: 1 1 calc(50% - 6px); /* Max 2 columns */
  display: flex;
  flex-direction: column;
  background: var(--card-bg, #1e1e2e);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  height: auto;
}

/* Hover effect on grid item */
.photo-grid-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16);
}

/* The link wrapping the image */
.photo-grid-item a {
  display: block;
  width: 100% !important;
  height: auto; /* let it scale naturally */
  margin: 0 !important;
  overflow: hidden;
  border-radius: 0 !important; /* reset wrapper radius */
  border-bottom: none !important; /* remove theme links underlines */
  flex-grow: 1; /* allow image link to stretch to fill card height */
}

.photo-grid-item img,
.photo-grid-item a img {
  width: 100% !important;
  height: auto !important; /* scale naturally to match aspect ratio */
  min-height: 100% !important; /* ensure it fills stretched parent */
  object-fit: cover !important; /* cover the card space if stretched */
  display: block !important;
  transition: transform 0.3s ease;
}

.photo-grid-item:hover a img {
  transform: scale(1.03);
}

/* Caption styling inside card */
.photo-grid-caption {
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--text-muted, #7a7a7a);
  text-align: center;
  font-style: italic;
  border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.05));
  background: rgba(255, 255, 255, 0.01);
  word-break: break-word;
  line-height: 1.4;
  margin-top: auto; /* push caption to the bottom of the card */
}

/* If there's an odd number of items, the last child spans full width */
.photo-grid-item:last-child:nth-child(odd) {
  flex: 1 1 100%;
}

/* If there is only one image, let it preserve aspect ratio and render nicely */
.photo-grid-item:only-child {
  flex: 1 1 100%;
}
.photo-grid-item:only-child a,
.photo-grid-item:only-child img {
  height: auto !important;
  max-height: 480px !important;
}
.photo-grid-item:only-child a img {
  height: auto !important;
  max-height: 480px !important;
}

/* Responsive adjustments */
@media (max-width: 576px) {
  .photo-grid {
    gap: 8px;
  }
  .photo-grid-item {
    flex: 1 1 100% !important; /* 1 column on mobile */
  }
}


