/* ============================
   Masonry Gallery Wrapper
============================ */
.masonry-gallery-wrapper {
  width: 80%;
  max-width: 1440px;
  margin-left: 16%;
  margin-right: 0;
  padding-top: 20px;
}

/* ============================
   Masonry Heading & Subheading
============================ */
.masonry-heading {
  text-align: left;
  margin: 10px 0;
  font-size: 2rem;
  font-weight: 400;
  font-variant: small-caps;
  color: black;
  width: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.masonry-subheading {
  text-align: left;
  margin-bottom: 20px;
  font-size: 1rem;
  color: black;
  width: 100%;
}

.masonry-gallery-container::after {
  content: '';
  display: block;
  height: 40px;
  background: linear-gradient(to bottom, transparent, #f8f8f8);
}

/* ============================
   Item Styling
============================ */
.item {
  margin-bottom: 1rem;
  break-inside: avoid;
  position: relative;
}

.item img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  display: block;
  cursor: zoom-in;
  transition: opacity 0.3s ease;
  border: none;
  border: 1px solid #666;
}

.item .title {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 1rem;
  padding: 5px 10px;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.3s linear;
}

.item:hover .title {
  opacity: 1;
}

.item:hover img {
  opacity: 0.8;
}

/* ============================
   Lightbox Styling
============================ */
.lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.lightbox img {
  max-width: 90%;
  max-height: 90%;
  border: 1px solid white;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
}

.lightbox img.show {
  opacity: 1;
}

.lightbox .close-btn,
.lightbox .nav-btn {
  position: absolute;
  font-size: 2rem;
  color: white;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 1000;
  padding: 10px;
  border-radius: 50%;
  background-color: rgba(128, 128, 128, 0.25);
  width: 50px;
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.lightbox .close-btn {
  top: 20px;
  right: 20px;
}

.lightbox .prev-btn {
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox .next-btn {
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox .close-btn:hover,
.lightbox .nav-btn:hover {
  background-color: rgba(0, 0, 0, 0.8);
}
.lightbox-counter {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-size: rem;
  z-index: 10;
  user-select: none;
}
.lightbox img.visible {
  opacity: 1;
}

.lightbox-caption {
  position: absolute;
  bottom: 50px;
  color: white;
  font-size: 0.75rem;
  text-align: center;
  width: 100%;
  pointer-events: none;
}

/* ============================
   Gallery Columns
============================ */
.masonry-gallery-container {
  column-count: 4;
  column-gap: 1rem;
  width: 100%;
  margin-top: 20px;
  flex: 2;

  /* ✅ Fix for mobile clipping */
  box-sizing: border-box;
  padding-bottom: env(safe-area-inset-bottom, 2rem);
}
.image-count-style {
  margin: 0.5rem 0;
  font-weight: bold;
  font-size: 0.8rem;
}

/* ✅ Fix for parent container clipping */
.page-wrapper {
  box-sizing: border-box;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom, 2rem);
}

/* ============================
   Responsive Columns
============================ */
@media (max-width: 1024px) {
  .masonry-gallery-container {
    column-count: 3;
  }
}

@media (max-width: 768px) {
  .masonry-gallery-container {
    column-count: 2;
  }
}

@media (max-width: 480px) {
  .masonry-gallery-container {
    column-count: 2;
  }
}
@media screen and (orientation: portrait) {
  .page-wrapper {
    padding-bottom: env(safe-area-inset-bottom, 5rem);
  }
}
@media screen and (max-width: 480px), (orientation: portrait) {
  .lightbox img {
    max-width: 100%;
    max-height: 80%;
  }
}