/* Gallery Section */
.gallery {
  padding: 4rem 0;
  max-height: 100vh;
  overflow: hidden;
  position: relative;
}

.gallery-container {
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--white);
  max-height: calc(100vh - 12rem);
  max-width: 900px;
  width: 100vw;
  overflow: auto; /* Changed from overflow-y: auto to only show scrollbar when needed */
  scrollbar-width: thin;
  scrollbar-color: var(--primary) var(--bg-dark);
  padding-bottom: 2rem;
}

body.dark-mode .gallery-container {
  background-color: var(--bg-dark);
}

.gallery-container::-webkit-scrollbar {
  width: 8px;
}

.gallery-container::-webkit-scrollbar-track {
  background: var(--bg-dark);
  border-radius: 4px;
}

.gallery-container::-webkit-scrollbar-thumb {
  background-color: var(--primary);
  border-radius: 4px;
}

body:not(.dark-mode) .gallery-container::-webkit-scrollbar-track {
  background: var(--gray-200);
}

/* Hide scrollbar when not needed for Firefox */
.gallery-container {
  scrollbar-width: auto;
}

/* Hide scrollbar when not needed for Webkit browsers */
.gallery-container::-webkit-scrollbar {
  display: auto;
}

.gallery-grid {
  gap: 0.5rem;
  margin: 0 auto;
  padding: 0 1rem;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 0;
  cursor: pointer;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gallery-item:hover img {
  transform: scale(1.05);
}

.gallery-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 0.5rem;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  font-size: 0.85rem;
  text-align: center;
}

.gallery-item:hover .gallery-caption {
  transform: translateY(0);
}

@media (max-width: 768px) {
  .gallery {
    padding: 3rem 0;
  }

  .gallery-container {
    max-height: calc(100vh - 9rem);
  }

  .gallery-grid {
    gap: 0.25rem;
  }
}
