.gallery-page {
  width: min(1280px, calc(100% - 48px));
  margin: 0 auto;
  padding: 80px 0 96px;
}

.gallery-header {
  max-width: 760px;
  margin: 0 auto 48px;
  text-align: center;
}

.gallery-header > span {
  display: inline-block;
  margin-bottom: 12px;
  color: #e4a213;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gallery-header h1 {
  margin-bottom: 16px;
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-size: clamp(2.6rem, 6vw, 5rem);
  line-height: 1;
}

.gallery-header p {
  color: #5f5a50;
  font-size: 1.05rem;
  line-height: 1.7;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.gallery-item {
  position: relative;
  min-height: 280px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 20px;
  background: #f3efe7;
  cursor: zoom-in;
}

.gallery-item:nth-child(7n + 1),
.gallery-item:nth-child(7n + 5) {
  grid-row: span 2;
  min-height: 578px;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: block;
  object-fit: cover;
  transition: transform 260ms ease, filter 260ms ease;
}

.gallery-item::after {
  content: "+";
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: #2a271f;
  font-size: 1.5rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.gallery-item:hover img,
.gallery-item:focus-visible img {
  filter: brightness(0.84);
  transform: scale(1.035);
}

.gallery-item:hover::after,
.gallery-item:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.gallery-item:focus-visible {
  outline: 3px solid #e4a213;
  outline-offset: 3px;
}

.gallery-empty {
  padding: 80px 24px;
  border: 1px dashed #d9ccb3;
  border-radius: 20px;
  color: #746c5e;
  text-align: center;
}

.gallery-lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 56px 88px 36px;
  border: 0;
  background: rgba(18, 18, 18, 0.74);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #ffffff;
  overflow: hidden;
  box-sizing: border-box;
}

.gallery-lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-lightbox::backdrop {
  background: rgba(0, 0, 0, 0.42);
}

.gallery-lightbox figure {
  width: 100%;
  height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.gallery-lightbox figure img {
  max-width: 100%;
  max-height: calc(100vh - 132px);
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  -webkit-user-drag: none;
  transition: transform 180ms ease, opacity 180ms ease;
}

.gallery-lightbox figure img.is-dragging {
  transition: none;
}

.gallery-lightbox figcaption {
  min-height: 1.4em;
  color: rgba(255, 255, 255, 0.82);
  text-align: center;
}

.lightbox-close,
.lightbox-nav {
  position: fixed;
  z-index: 3;
  width: 46px;
  height: 46px;
  min-width: 46px;
  min-height: 46px;
  padding: 0;
  display: grid;
  place-items: center;
  flex: 0 0 46px;
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  box-shadow: none;
  line-height: 1;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.lightbox-close {
  top: 20px;
  right: 22px;
  font-size: 1.75rem;
  font-weight: 300;
}

.lightbox-nav {
  top: 50%;
  font-size: 1.35rem;
  transform: translateY(-50%);
}

.lightbox-prev {
  left: 24px;
}

.lightbox-next {
  right: 24px;
}

.lightbox-nav:hover,
.lightbox-nav:focus-visible,
.lightbox-close:hover,
.lightbox-close:focus-visible {
  border-color: rgba(255, 255, 255, 0.42);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.lightbox-nav:hover {
  transform: translateY(-50%) scale(1.04);
}

.lightbox-close:hover {
  transform: scale(1.04);
}

.lightbox-nav:focus-visible,
.lightbox-close:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: 3px;
}

@media (max-width: 900px) {
  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gallery-lightbox {
    padding: 58px 62px 28px;
  }

  .gallery-lightbox figure {
    height: 100%;
  }

  .lightbox-prev {
    left: 12px;
  }

  .lightbox-next {
    right: 12px;
  }

  .lightbox-close,
  .lightbox-nav {
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    flex-basis: 42px;
  }

  .lightbox-close {
    top: 14px;
    right: 14px;
  }
}

@media (max-width: 600px) {
  .gallery-page {
    width: min(100%, calc(100% - 24px));
    padding: 48px 0 64px;
  }

  .gallery-header {
    margin-bottom: 30px;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .gallery-item,
  .gallery-item:nth-child(7n + 1),
  .gallery-item:nth-child(7n + 5) {
    min-height: 0;
    aspect-ratio: 4 / 3;
    grid-row: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-item img,
  .gallery-item::after,
  .gallery-lightbox figure img {
    transition: none;
  }
}
