#gallery {
  position: relative;
  /* allow pseudo-element overlay */
  background: #111;
  color: #fff;
  font-family: "Orbitron", sans-serif;
  margin: 0;
  padding: 120px 50px 50px;
  display: flex;
  justify-content: flex-start;
  /* keep items left-aligned */
  align-items: flex-start;
  flex-wrap: nowrap;
  /* keep them side by side */
  gap: 50px;
  overflow: hidden;
  /* ensure pseudo-element is clipped */
}

#gallery::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;

  background-image: radial-gradient(circle, #fff 2px, transparent 2px),
    radial-gradient(circle, #fff 2px, transparent 2px);
  background-size: 50px 50px;
  background-position: 0 0, 25px 25px;

  opacity: 0.15;
  /* subtle white dot grid */
  pointer-events: none;
  /* allow clicks through */
  z-index: 0;
}

/* Header / title on the right */
#gallery h1 {
  flex: 0 0 auto;
  /* only take the space it needs */
  font-size: 4rem;
  margin: 0;
  opacity: 0;
  transform: translateY(50px);
  transition: all 0.8s ease-out;
  order: 2;
  /* move header to the right */
}

#gallery h1.show {
  opacity: 1;
  transform: translateY(0);
}

/* Gallery images on the left */
#gallery .polaroid-stage {
  flex: 1 1 70%;
  /* take more space on the left */
  min-width: 600px;
  min-height: 500px;
  position: relative;
  order: 1;
  /* ensure images are first */
}

/* Polaroid style images */
#gallery .polaroid {
  position: absolute;
  width: 200px;
  height: 250px;
  /* taller to fit the classic bottom border */
  background: #fff;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
  border: 1px solid #fff;
  padding: 5px 5px 45px;
  /* longer bottom padding for Polaroid effect */
  transition: all 0.8s ease;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

#gallery .polaroid img {
  width: 100%;
  height: auto;
  flex-grow: 1;
  /* fill available space but leave bottom padding */
  object-fit: cover;
  display: block;
}

#gallery .gallery-controls {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 1.3rem;
}

#gallery .gallery-controls button {
  background: #000;
  border: 1px solid #fff;
  color: #fff;
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
}

#gallery .gallery-controls button:hover {
  background: #fff;
  color: #000;
}

/* Lightbox */
#gallery .lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 1000;
}

#gallery .lightbox img {
  max-width: 90%;
  max-height: 90%;
  border: 4px solid #fff;
  border-radius: 12px;
}

#gallery .lightbox.show {
  opacity: 1;
  pointer-events: all;
}

@media (max-width: 900px) {
  #gallery {
    flex-direction: column;
    text-align: center;
  }

  #gallery h1 {
    font-size: 3rem;
    order: 0;
    /* stack normally on mobile */
    margin-top: 50px;
  }

  #gallery .polaroid-stage {
    order: 0;
    width: 100%;
    min-width: auto;
  }
}

#gallery .lightbox .arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 3rem;
  font-weight: bold;
  color: #fff;
  cursor: pointer;
  user-select: none;
  z-index: 1001;
  padding: 10px;
}

#gallery .lightbox .arrow.left {
  left: 30px;
  /* distance from left edge */
}

#gallery .lightbox .arrow.right {
  right: 30px;
  /* distance from right edge */
}

#gallery .lightbox .arrow:hover {
  color: #bbb;
}
