/* Gallery page: varied masonry tiles + full-image lightbox */

#ehd-gallery-grid.ehd-gallery-grid {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 0.75rem !important;
  grid-auto-flow: dense;
  align-items: start;
}

@media (min-width: 768px) {
  #ehd-gallery-grid.ehd-gallery-grid {
    grid-template-columns: repeat(6, 1fr) !important;
    gap: 0.9rem !important;
  }
}

@media (min-width: 1200px) {
  #ehd-gallery-grid.ehd-gallery-grid {
    grid-template-columns: repeat(12, 1fr) !important;
    gap: 1rem !important;
  }
}

#ehd-gallery-grid .ehd-gallery-item {
  position: relative;
  display: flex !important;
  flex-direction: column;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent !important;
  aspect-ratio: auto !important;
  overflow: visible !important;
  cursor: zoom-in;
  color: inherit;
  text-align: left;
  grid-column: span 1;
}

@media (min-width: 768px) {
  #ehd-gallery-grid .ehd-gallery-item {
    grid-column: span 2;
  }

  #ehd-gallery-grid .ehd-gallery-item--wide {
    grid-column: span 4;
  }

  #ehd-gallery-grid .ehd-gallery-item--feature {
    grid-column: span 4;
  }

  #ehd-gallery-grid .ehd-gallery-item--tall {
    grid-column: span 2;
  }
}

@media (min-width: 1200px) {
  #ehd-gallery-grid .ehd-gallery-item {
    grid-column: span 3;
  }

  #ehd-gallery-grid .ehd-gallery-item--wide {
    grid-column: span 6;
  }

  #ehd-gallery-grid .ehd-gallery-item--feature {
    grid-column: span 6;
  }

  #ehd-gallery-grid .ehd-gallery-item--tall {
    grid-column: span 3;
  }
}

#ehd-gallery-grid .ehd-gallery-item.is-hidden {
  display: none !important;
}

#ehd-gallery-grid .ehd-gallery-item__media {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #ece8e2;
  aspect-ratio: 1 / 1;
}

#ehd-gallery-grid .ehd-gallery-item--wide .ehd-gallery-item__media {
  aspect-ratio: 16 / 10;
}

#ehd-gallery-grid .ehd-gallery-item--tall .ehd-gallery-item__media {
  aspect-ratio: 3 / 4;
}

#ehd-gallery-grid .ehd-gallery-item--feature .ehd-gallery-item__media {
  aspect-ratio: 4 / 3;
}

#ehd-gallery-grid .ehd-gallery-item__media img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  object-position: center center;
  display: block;
  transition: transform 0.5s ease;
}

/* Bare imgs (before JS wraps / if script fails) must not collapse to 0 height */
#ehd-gallery-grid .ehd-gallery-item > img {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 1 / 1;
  object-fit: cover !important;
  object-position: center center;
  display: block;
  transition: transform 0.5s ease;
  background: #ece8e2;
}

#ehd-gallery-grid .ehd-gallery-item:hover .ehd-gallery-item__media img,
#ehd-gallery-grid .ehd-gallery-item:focus-visible .ehd-gallery-item__media img {
  transform: scale(1.045);
}

#ehd-gallery-grid .ehd-gallery-item:focus-visible {
  outline: 2px solid #c4a574;
  outline-offset: 3px;
}

#ehd-gallery-grid .ehd-gallery-item figcaption {
  position: static !important;
  background: transparent !important;
  color: rgba(244, 244, 242, 0.88) !important;
  padding: 0.5rem 0.1rem 0;
  font-size: 0.72rem;
  line-height: 1.35;
}

/* Lightbox */
.ehd-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10080;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(8, 8, 8, 0.93);
}

.ehd-lightbox.is-open {
  display: flex;
}

body.ehd-lightbox-open {
  overflow: hidden !important;
}

.ehd-lightbox__dialog {
  position: relative;
  width: min(1120px, 100%);
  max-height: min(94vh, 100%);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.ehd-lightbox__stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  background: #0d0d0d;
}

.ehd-lightbox__img {
  max-width: 100%;
  max-height: min(76vh, 920px);
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.ehd-lightbox__caption {
  margin: 0;
  color: rgba(255, 255, 255, 0.94);
  text-align: center;
  font-size: clamp(0.95rem, 1.7vw, 1.15rem);
  line-height: 1.45;
}

.ehd-lightbox__meta {
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ehd-lightbox__close,
.ehd-lightbox__prev,
.ehd-lightbox__next {
  appearance: none;
  border: 0;
  cursor: pointer;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  line-height: 1;
  z-index: 3;
  transition: background 0.2s ease, color 0.2s ease;
}

.ehd-lightbox__close:hover,
.ehd-lightbox__prev:hover,
.ehd-lightbox__next:hover,
.ehd-lightbox__close:focus-visible,
.ehd-lightbox__prev:focus-visible,
.ehd-lightbox__next:focus-visible {
  background: #c4a574;
  color: #0d0d0d;
  outline: none;
}

.ehd-lightbox__close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
}

.ehd-lightbox__prev,
.ehd-lightbox__next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.ehd-lightbox__prev {
  left: 0.85rem;
}

.ehd-lightbox__next {
  right: 0.85rem;
}

@media (max-width: 767px) {
  .ehd-lightbox {
    padding: 0.75rem;
  }

  .ehd-lightbox__img {
    max-height: min(60vh, 640px);
  }

  .ehd-lightbox__prev,
  .ehd-lightbox__next {
    top: auto;
    bottom: 5.75rem;
    transform: none;
  }
}
