.gallery-page .portfolio {
  padding: 150px 8% 80px;
}

.gallery-kicker {
  display: block;
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}

.gallery-showcase h2 {
  font-size: clamp(2.2rem, 4vw, 3.5rem);
  line-height: 0.95;
  font-weight: 300;
}

.gallery-showcase > p:last-of-type {
  max-width: 68ch;
  margin: 18px auto 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

.gallery-masonry {
  column-count: 3;
  column-gap: 18px;
  margin-top: 52px;
}

.gallery-card {
  position: relative;
  break-inside: avoid;
  margin: 0 0 18px;
  overflow: hidden;
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 8px 28px rgba(28,26,22,0.08);
  cursor: zoom-in;
  transition: box-shadow 300ms ease;
}

.gallery-card:hover {
  box-shadow: 0 20px 52px rgba(28,26,22,0.16);
}

.gallery-card img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.gallery-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10,10,16,0.02) 25%, rgba(10,10,16,0.70) 100%);
  opacity: 0;
  transition: opacity 280ms ease;
}

.gallery-card-caption {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 24px 20px;
  color: #ffffff;
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 280ms ease, transform 280ms ease;
  z-index: 1;
  pointer-events: none;
}

.gallery-card:hover img { transform: scale(1.04); }
.gallery-card:hover::after,
.gallery-card:hover .gallery-card-caption { opacity: 1; }
.gallery-card:hover .gallery-card-caption { transform: translateY(0); }

/* Lightbox */
.popup-container[hidden] { display: none; }

.popup-container {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 6, 10, 0.94);
  z-index: 2000;
}

.popup-backdrop {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.popup-close {
  position: absolute;
  top: 12px;
  right: 18px;
  font-size: 38px;
  font-weight: bold;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  line-height: 1;
  transition: color 200ms;
}

.popup-close:hover { color: #fff; }

.popup-container img {
  max-width: min(1100px, 100%);
  max-height: 88vh;
  width: auto;
  height: auto;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.55);
  object-fit: contain;
  cursor: auto;
}

/* Scroll-to-top */
.scroll-top-button {
  position: fixed;
  right: 28px;
  bottom: 28px;
  width: 50px;
  height: 50px;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
  box-shadow: 0 8px 24px rgba(28,26,22,0.12);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 200ms ease, transform 200ms ease, visibility 200ms ease, background 200ms, border-color 200ms;
  z-index: 1500;
}

.scroll-top-button.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-top-button:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 768px) {
  .gallery-page .portfolio { padding-top: 130px; }
  .gallery-masonry { column-count: 2; column-gap: 12px; }
  /*Show overlay on images when on mobile*/
  .gallery-card::after { opacity: 1; }
  .gallery-card-caption {
    opacity: 1;
    transform: translateY(0);
  }
  .gallery-card img { transform: none; }
}

@media (max-width: 540px) {
  .gallery-masonry { column-count: 1; }
  .gallery-card-caption { padding: 16px; font-size: 0.625rem; }
}
