.gallery-page {
  background: #ffffff;
  padding-block: clamp(2rem, 4vw, 3rem);
}

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

.gallery-grid__item {
  margin: 0;
  overflow: hidden;
  background: #f5f6f8;
}

.gallery-grid__item img {
  width: 100%;
  height: 100%;
  min-height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.gallery-grid__item--wide {
  grid-column: span 8;
}

.gallery-grid__item--narrow {
  grid-column: span 4;
}

.gallery-grid__item--tall {
  min-height: clamp(300px, 36vw, 440px);
}

.gallery-grid__item--short {
  min-height: clamp(220px, 24vw, 320px);
}

.gallery-slider-controls {
  display: none;
}

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

  .gallery-grid__item--wide,
  .gallery-grid__item--narrow {
    grid-column: span 1;
  }

  .gallery-grid__item--tall,
  .gallery-grid__item--short {
    min-height: 260px;
  }
}

@media (max-width: 640px) {
  .gallery-grid {
    display: flex;
    gap: 0.85rem;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 1rem;
    -webkit-overflow-scrolling: touch;
    padding-inline: 1rem;
    padding-bottom: 0.35rem;
  }

  .gallery-grid__item--wide,
  .gallery-grid__item--narrow {
    grid-column: auto;
  }

  .gallery-grid__item {
    flex: 0 0 84%;
    scroll-snap-align: start;
  }

  .gallery-grid__item--tall,
  .gallery-grid__item--short {
    min-height: 220px;
  }

  .gallery-slider-controls {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.65rem;
    margin-top: 0.7rem;
    padding-inline: 1rem;
  }

  .gallery-slider-controls__btn {
    border: 1px solid #d4d9df;
    background: #ffffff;
    color: #1e2733;
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
  }

  .gallery-slider-controls__btn[disabled] {
    opacity: 0.45;
    cursor: default;
  }

  .gallery-slider-controls__dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.35rem;
  }

  .gallery-slider-controls__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 0;
    padding: 0;
    background: #c4cbd4;
    cursor: pointer;
  }

  .gallery-slider-controls__dot.is-active {
    background: #1e2733;
  }
}

.gallery-modal-open {
  overflow: hidden;
}

.gallery-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: rgba(10, 12, 16, 0.82);
  padding: 1.25rem;
}

.gallery-modal[hidden] {
  display: none;
}

.gallery-modal__dialog {
  width: min(100%, 1080px);
  max-height: calc(100vh - 2.5rem);
  display: grid;
  gap: 0.65rem;
  justify-items: center;
}

.gallery-modal__close {
  justify-self: end;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
}

.gallery-modal__image {
  max-width: 100%;
  max-height: calc(100vh - 9rem);
  object-fit: contain;
  border-radius: 2px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.4);
}

.gallery-modal__caption {
  margin: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.95);
  font-size: 0.98rem;
  line-height: 1.5;
}