.gallery {
  background: var(--bg-alt);
  padding: var(--spacing-2xl) clamp(1.25rem, 4vw, 4rem);
  overflow-x: clip;
}

.gallery__container {
  max-width: var(--max-width);
  margin: 0 auto;
}

.gallery__title {
  font-size: clamp(2.2rem, 4.5vw, 3.6rem);
  font-weight: 500;
  text-align: center;
  margin-bottom: clamp(3rem, 7vw, 5rem);
  color: var(--ink);
}
.gallery__title.ink-underline::after {
  left: 50%;
  transform: translateX(-50%);
}

/* ============ Photo wall — polaroid prints pinned with tape ============ */
.gallery__grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: clamp(1.5rem, 3vw, 2.5rem) clamp(1.25rem, 2.4vw, 2rem);
}

.gallery__item {
  position: relative;
  margin: 0;
  padding: 10px 10px 14px;
  background: var(--surface);
  border-radius: 4px;
  box-shadow: var(--shadow-soft);
  cursor: zoom-in;
  transition:
    transform 0.6s var(--ease-bounce),
    box-shadow var(--transition-pop);
}
/* alternating character tilts */
.gallery__item:nth-child(1) { grid-column: span 5; --tilt: -1.8deg; }
.gallery__item:nth-child(2) { grid-column: span 4; --tilt: 1.3deg; }
.gallery__item:nth-child(3) { grid-column: span 3; --tilt: -1deg; }
.gallery__item:nth-child(4) { grid-column: 1 / -1; --tilt: 0.9deg; }

.gallery__item:hover {
  transform: rotate(0deg) scale(1.03);
  box-shadow: var(--shadow-lift);
  z-index: 2;
}

/* Tape strips at the top corners of every print */
.gallery__item::before,
.gallery__item::after {
  content: '';
  position: absolute;
  width: 78px;
  height: 22px;
  background: repeating-linear-gradient(45deg, rgba(174, 139, 74, 0.35) 0 6px, rgba(255, 255, 255, 0.6) 6px 12px);
  border-left: 1px dashed rgba(255, 255, 255, 0.65);
  border-right: 1px dashed rgba(255, 255, 255, 0.65);
  box-shadow: 0 3px 8px -3px rgba(38, 37, 28, 0.35);
  pointer-events: none;
  z-index: 3;
}
.gallery__item::before {
  top: -10px;
  left: -16px;
  transform: rotate(-36deg);
}
.gallery__item::after {
  top: -10px;
  right: -16px;
  transform: rotate(36deg);
}

.gallery__image-wrapper {
  width: 100%;
  overflow: hidden;
  background: var(--line);
}

.gallery__image {
  width: 100%;
  height: clamp(220px, 24vw, 320px);
  object-fit: cover;
  filter: saturate(0.88);
  transform: scale(1.001);
  transition: filter 0.7s ease, transform 0.9s var(--ease-out-expo);
}
.gallery__item:nth-child(4) .gallery__image {
  height: clamp(240px, 36vw, 380px);
}

.gallery__item:hover .gallery__image {
  filter: saturate(1.05);
  transform: scale(1.05);
}

/* Caption — always visible, like handwriting under the print */
.gallery__caption {
  position: relative;
  display: block;
  padding-top: 0.7rem;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.02rem;
  color: var(--ink-dim);
  text-align: center;
  z-index: 1;
}
.gallery__caption::before {
  content: '\2014';
  color: var(--vermillion);
  margin-right: 8px;
}

@media (max-width: 860px) {
  .gallery__grid {
    grid-template-columns: repeat(6, 1fr);
  }
  .gallery__item:nth-child(1),
  .gallery__item:nth-child(2),
  .gallery__item:nth-child(3),
  .gallery__item:nth-child(4) {
    grid-column: span 3 !important;
  }
}

@media (max-width: 540px) {
  .gallery__grid {
    grid-template-columns: 1fr;
  }
  .gallery__item:nth-child(n) {
    grid-column: 1 / -1 !important;
  }
  .gallery__image,
  .gallery__item:nth-child(4) .gallery__image {
    height: 240px;
  }
  .gallery__item::before,
  .gallery__item::after {
    width: 58px;
    height: 18px;
  }
}

/* ============ Lightbox ============ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 3rem);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-fast), visibility 0s linear 0.35s;
}
.lightbox.lightbox--open {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 15, 12, 0.92);
  backdrop-filter: blur(10px);
}

.lightbox-figure {
  position: relative;
  max-width: min(1000px, 92vw);
  margin: 0;
}
.lightbox.lightbox--open .lightbox-figure {
  animation: lb-pop 0.5s var(--ease-bounce);
}

.lightbox-img {
  max-width: 100%;
  max-height: 74vh;
  object-fit: contain;
  border: 10px solid var(--bg);
  outline: 2px dashed rgba(174, 139, 74, 0.5);
  outline-offset: -12px;
  border-radius: var(--radius-md);
  box-shadow: 0 60px 120px -30px rgba(0, 0, 0, 0.9);
}

.lightbox-caption {
  margin-top: var(--spacing-sm);
  text-align: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.15rem;
  color: rgba(250, 247, 239, 0.85);
}

.lightbox-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  font-size: 1.15rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-soft);
  transition: transform var(--transition-pop), background-color var(--transition-fast), color var(--transition-fast);
}
.lightbox-btn:hover {
  background: #fff;
  transform: translateY(-50%) scale(1.12);
}
.lightbox-btn:active {
  transform: translateY(-50%) scale(0.9);
}

.lightbox-prev { left: clamp(0.5rem, 3vw, 2.5rem); }
.lightbox-next { right: clamp(0.5rem, 3vw, 2.5rem); }

.lightbox-close {
  position: absolute;
  top: clamp(1rem, 3vw, 2rem);
  right: clamp(1rem, 3vw, 2rem);
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: rgba(250, 247, 239, 0.8);
  font-size: 1.25rem;
  cursor: pointer;
  transition: color var(--transition-fast), transform var(--transition-pop);
}
.lightbox-close:hover {
  color: #fff;
  transform: rotate(90deg) scale(1.1);
}
