/* Container & Section Styling */
.wp-singular .wrapper {
  z-index: auto;
}

.image-gallery-section {
  max-width: 1200px;
  margin: 3rem auto;
  padding: 0 1.5rem;
  font-family: 'David Libre', Georgia, serif;
  color: #2C221E;
}

.gallery-title {
  text-align: center;
  font-family: 'Simonetta', Georgia, serif;
  font-size: 2.25rem;
  font-weight: 900;
  color: #2C221E;
  margin-bottom: 2rem;
  letter-spacing: -0.01em;
}

/* Gallery Grid */
.image-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.75rem;
}

/* Gallery Card Container */
.gallery-item {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 340px;
  /* Fixed height so thumbnail expands when no caption */
  background: #FAF8F5;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid #EAE3D9;
  box-shadow: 0 4px 15px rgba(44, 34, 30, 0.05);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.gallery-item:hover,
.gallery-item:focus {
  transform: translateY(-4px);
  box-shadow: 0 10px 25px rgba(44, 34, 30, 0.12);
  border-color: #A3783E;
  outline: none;
}

/* Image Wrapper (Flex-Grows to 100% when no caption sibling) */
.image-wrapper {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #EAE3D9;
}

.image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.image-wrapper.top img {
  object-position: top;
}

.gallery-item:hover .image-wrapper img {
  transform: scale(1.05);
}

/* Hover Overlay */
.item-overlay {
  position: absolute;
  inset: 0;
  background: rgba(44, 34, 30, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.gallery-item:hover .item-overlay,
.gallery-item:focus .item-overlay {
  opacity: 1;
}

.zoom-icon {
  color: #FFFFFF;
  font-size: 2.25rem;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Caption Bar */
.item-caption-preview {
  flex: 0 0 auto;
  padding: 0.9rem 1.25rem;
  background: #FAF8F5;
  color: #2C221E;
  font-family: 'Simonetta', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  border-top: 1px solid #EAE3D9;
}

/* Lightbox Modal */
.lightbox-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox-modal.is-active {
  opacity: 1;
  visibility: visible;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(44, 34, 30, 0.88);
  backdrop-filter: blur(5px);
}

.modal-content-wrapper {
  position: relative;
  max-width: 1000px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 10;
}

.lightbox-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-height: 82vh;
  width: 100%;
}

.lightbox-body img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.lightbox-caption {
  margin-top: 1.25rem;
  color: #FAF8F5;
  font-family: 'David Libre', Georgia, serif;
  font-size: 1.1rem;
  text-align: center;
  max-width: 750px;
  line-height: 1.6;
}

/* Modal Controls */
.modal-close {
  position: absolute;
  /* top: -45px; */
  right: 0;
  background: transparent;
  border: none;
  font-size: 2.5rem;
  line-height: 1;
  color: #A3783E;
  cursor: pointer;
  z-index: 20;
  transition: color 0.2s ease, transform 0.2s ease;
  width: 70px;
  box-sizing: border-box;
  top: -70px;
}

.modal-close:hover {
  color: #FFFFFF;
  transform: scale(1.1);
}

.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: #FAF8F5;
  color: #A3783E;
  border: 1px solid #EAE3D9;
  font-size: 1.25rem;
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  border-radius: 4px;
  z-index: 20;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  width: 50px;
}

.modal-nav:hover {
  background: #A3783E;
  color: #FFFFFF;
  border-color: #A3783E;
}

.prev-btn {
  left: -12px;
}

.next-btn {
  right: -12px;
}

body.modal-open {
  overflow: hidden;
}