.ufa-building-gallery {
  --ufa-gallery-orange: #f36f21;
  --ufa-gallery-border: #dedede;
  --ufa-gallery-text: #2f2f2f;
  width: 100%;
  max-width: 1220px;
  margin-right: auto;
  margin-left: auto;
  padding: 18px 14px 42px;
  color: var(--ufa-gallery-text);
}

.ufa-building-gallery,
.ufa-building-gallery *,
.ufa-building-gallery *::before,
.ufa-building-gallery *::after {
  box-sizing: border-box;
}

/* Bootstrap-compatible fallbacks keep restricted CMS previews usable. */
.ufa-building-gallery .row {
  display: flex;
  flex-wrap: wrap;
  margin-right: -12px;
  margin-left: -12px;
  row-gap: 24px;
}

.ufa-building-gallery .row > * {
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  padding-right: 12px;
  padding-left: 12px;
}

.ufa-building-gallery .row-cols-2 > * {
  width: 50%;
}

.ufa-building-gallery .visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.ufa-building-gallery .pagination {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  padding-left: 0;
  margin-bottom: 0;
  list-style: none;
}

.ufa-building-gallery .page-link {
  position: relative;
  display: block;
  min-width: 40px;
  padding: .375rem .75rem;
  border: 1px solid var(--ufa-gallery-border);
  color: var(--ufa-gallery-text);
  background: #fff;
  font: inherit;
  text-align: center;
  box-shadow: none !important;
}

.ufa-building-gallery .page-item:not(:first-child) .page-link {
  margin-left: -1px;
}

.ufa-building-gallery .page-item:first-child .page-link {
  border-radius: .375rem 0 0 .375rem;
}

.ufa-building-gallery .page-item:last-child .page-link {
  border-radius: 0 .375rem .375rem 0;
}

.ufa-building-gallery .page-item.disabled .page-link {
  color: #969696;
  pointer-events: none;
}

.ufa-gallery__filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 18px;
  margin-bottom: 34px;
}

.ufa-gallery__filter {
  min-height: 31px;
  padding: 5px 12px;
  border: 1px solid var(--ufa-gallery-border);
  border-radius: 0;
  color: var(--ufa-gallery-text);
  background: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .02em;
}

.ufa-gallery__filter.is-active {
  border-color: var(--ufa-gallery-orange);
  color: #fff;
  background: var(--ufa-gallery-orange);
}

.ufa-gallery__filter:hover,
.ufa-gallery__filter:focus-visible {
  border-color: var(--ufa-gallery-orange);
  color: var(--ufa-gallery-orange);
}

.ufa-gallery__filter.is-active:hover,
.ufa-gallery__filter.is-active:focus-visible {
  color: #fff;
}

.ufa-gallery__card {
  display: block;
  position: relative;
  aspect-ratio: 1.75 / 1;
  overflow: hidden;
  background: #f2f2f2;
}

.ufa-gallery__card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  transition: filter 180ms ease;
}

.ufa-gallery__card:hover img,
.ufa-gallery__card:focus-visible img {
  filter: brightness(.92);
}

.ufa-gallery__card:focus-visible {
  outline: 3px solid var(--ufa-gallery-orange);
  outline-offset: 3px;
}

.ufa-gallery__pagination {
  margin-top: 38px;
}

body.ufa-gallery-lightbox-open {
  overflow: hidden;
}

.ufa-building-gallery .ufa-gallery__lightbox[hidden] {
  display: none !important;
}

.ufa-building-gallery .ufa-gallery__lightbox {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: grid;
  place-items: center;
  padding: 32px 72px;
}

.ufa-gallery__lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .88);
  cursor: zoom-out;
}

.ufa-gallery__lightbox-dialog {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  position: relative;
  z-index: 1;
  width: min(100%, 1500px);
  max-height: 100%;
}

.ufa-gallery__lightbox-figure {
  min-width: 0;
  margin: 0;
  text-align: center;
}

.ufa-gallery__lightbox-image {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: calc(100vh - 150px);
  margin: 0 auto;
  object-fit: contain;
  background: #1a1a1a;
}

.ufa-gallery__lightbox-caption {
  max-width: 80ch;
  margin: 14px auto 0;
  color: #fff;
  font-size: 14px;
  line-height: 1.45;
}

.ufa-gallery__lightbox-counter {
  display: block;
  margin-top: 6px;
  color: #cfcfcf;
  font-size: 13px;
}

.ufa-gallery__lightbox-close,
.ufa-gallery__lightbox-previous,
.ufa-gallery__lightbox-next {
  border: 0;
  color: #fff;
  background: transparent;
  line-height: 1;
}

.ufa-gallery__lightbox-close:focus-visible,
.ufa-gallery__lightbox-previous:focus-visible,
.ufa-gallery__lightbox-next:focus-visible {
  outline: 3px solid var(--ufa-gallery-orange);
  outline-offset: 3px;
}

.ufa-gallery__lightbox-close {
  position: absolute;
  top: -28px;
  right: -44px;
  z-index: 2;
  padding: 8px;
  font-size: 42px;
}

.ufa-gallery__lightbox-previous,
.ufa-gallery__lightbox-next {
  padding: 20px;
  font-size: 58px;
}

.ufa-building-gallery .page-link:hover,
.ufa-building-gallery .page-link:focus {
  border-color: var(--ufa-gallery-orange);
  color: var(--ufa-gallery-orange);
  background: #fff7f2;
}

.ufa-building-gallery .page-item.active > .page-link {
  border-color: var(--ufa-gallery-orange);
  color: #fff;
  background: var(--ufa-gallery-orange);
}

@media (min-width: 576px) {
  .ufa-building-gallery .row-cols-sm-3 > * {
    width: 33.333333%;
  }
}

@media (min-width: 768px) {
  .ufa-building-gallery .row-cols-md-4 > * {
    width: 25%;
  }
}

@media (min-width: 992px) {
  .ufa-building-gallery .row-cols-lg-5 > * {
    width: 20%;
  }
}

@media (max-width: 575.98px) {
  .ufa-building-gallery {
    padding-right: 12px;
    padding-left: 12px;
  }

  .ufa-gallery__filters {
    justify-content: flex-start;
    gap: 8px;
    margin-bottom: 24px;
  }

  .ufa-gallery__filter {
    flex: 1 0 calc(50% - 8px);
  }

  .ufa-building-gallery .ufa-gallery__lightbox {
    padding: 54px 12px 24px;
  }

  .ufa-gallery__lightbox-dialog {
    grid-template-columns: 46px minmax(0, 1fr) 46px;
  }

  .ufa-gallery__lightbox-close {
    top: -48px;
    right: 0;
  }

  .ufa-gallery__lightbox-previous,
  .ufa-gallery__lightbox-next {
    padding: 8px;
    font-size: 48px;
  }

  .ufa-gallery__lightbox-image {
    max-height: calc(100vh - 190px);
  }

  .ufa-gallery__lightbox-caption {
    font-size: 12px;
  }
}
