.mansysgallery {
  --mg-columns-desktop: 5;
  --mg-columns-tablet: 3;
  --mg-columns-mobile: 2;
  --mg-gap: 8px;
  --mg-radius: 8px;
  --mg-ratio: 1 / 1;
  width: 100%;
}

.mansysgallery--home {
  padding: 48px 0;
}

.mansysgallery__container {
  width: min(1320px, calc(100% - 30px));
  margin: 0 auto;
}

.mansysgallery__header {
  max-width: 760px;
  margin: 0 auto 22px;
  text-align: center;
}

.mansysgallery__title {
  margin: 0;
  font-size: clamp(1.55rem, 2.2vw, 2.15rem);
  line-height: 1.2;
  font-weight: 700;
}

.mansysgallery__subtitle,
.mansysgallery__page-intro {
  margin: 8px 0 0;
  color: #606060;
  font-size: 1rem;
  line-height: 1.55;
}

.mansysgallery__page-intro {
  max-width: 780px;
  margin: 0 auto 28px;
  text-align: center;
}

.mansysgallery__grid {
  display: grid;
  grid-template-columns: repeat(var(--mg-columns-desktop), minmax(0, 1fr));
  gap: var(--mg-gap);
}

.mansysgallery__item {
  position: relative;
  aspect-ratio: var(--mg-ratio);
  overflow: hidden;
  border-radius: var(--mg-radius);
  background: #f1f1f1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  isolation: isolate;
}

.mansysgallery__item:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 3px;
}

.mansysgallery__item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1);
  transition: transform 320ms ease;
}

.mansysgallery__item:hover img,
.mansysgallery__item:focus-visible img {
  transform: scale(1.045);
}

.mansysgallery__footer {
  margin-top: 22px;
  text-align: center;
}

.mansysgallery__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 11px 20px;
  border: 1px solid #111;
  border-radius: 4px;
  background: #111;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.03em;
  text-decoration: none;
  text-transform: uppercase;
  transition: background-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.mansysgallery__button:hover,
.mansysgallery__button:focus-visible {
  background: #fff;
  color: #111;
  text-decoration: none;
  transform: translateY(-1px);
}

.mansysgallery--page {
  width: 100%;
}

.mansysgallery__empty {
  padding: 30px;
  border: 1px dashed #cfcfcf;
  border-radius: 8px;
  text-align: center;
}

.mansysgallery-lightbox[hidden] {
  display: none !important;
}

.mansysgallery-lightbox {
  position: fixed;
  z-index: 100000;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(52px, 1fr) minmax(0, 1100px) minmax(52px, 1fr);
  align-items: center;
  padding: 30px 12px;
  background: rgba(0, 0, 0, 0.92);
  opacity: 0;
  visibility: hidden;
  transition: opacity 210ms ease, visibility 0s linear 210ms;
}

.mansysgallery-lightbox.is-open {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

.mansysgallery-lightbox__figure {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  max-height: calc(100vh - 60px);
  margin: 0;
  opacity: 0;
  transform: translateY(4px) scale(0.985);
  transition: opacity 220ms ease, transform 240ms ease;
}

.mansysgallery-lightbox.is-open .mansysgallery-lightbox__figure {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.mansysgallery-lightbox__image {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 110px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 180ms ease;
}

.mansysgallery-lightbox__image.is-loaded {
  opacity: 1;
}

.mansysgallery-lightbox__caption {
  min-height: 20px;
  margin-top: 12px;
  color: #fff;
  text-align: center;
  line-height: 1.4;
}

.mansysgallery-lightbox__close,
.mansysgallery-lightbox__nav {
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  opacity: 0.82;
  transition: opacity 160ms ease, transform 160ms ease;
}

.mansysgallery-lightbox__close:hover,
.mansysgallery-lightbox__close:focus-visible,
.mansysgallery-lightbox__nav:hover,
.mansysgallery-lightbox__nav:focus-visible {
  opacity: 1;
  transform: scale(1.08);
}

.mansysgallery-lightbox__close {
  position: absolute;
  top: 12px;
  right: 16px;
  padding: 5px 10px;
  font-size: 2.4rem;
  line-height: 1;
}

.mansysgallery-lightbox__nav {
  padding: 20px;
  font-size: 2.1rem;
  line-height: 1;
}

.mansysgallery-lightbox__nav--prev {
  grid-column: 1;
  justify-self: end;
}

.mansysgallery-lightbox__nav--next {
  grid-column: 3;
  justify-self: start;
}

body.mansysgallery-lightbox-open {
  overflow: hidden;
}

@media (max-width: 991px) {
  .mansysgallery--home {
    padding: 40px 0;
  }

  .mansysgallery__grid {
    grid-template-columns: repeat(var(--mg-columns-tablet), minmax(0, 1fr));
  }
}

@media (max-width: 575px) {
  .mansysgallery__grid {
    grid-template-columns: repeat(var(--mg-columns-mobile), minmax(0, 1fr));
  }
}

@media (max-width: 575px) {
  .mansysgallery--home {
    padding: 32px 0;
  }

  .mansysgallery__header {
    margin-bottom: 18px;
  }

  .mansysgallery__subtitle,
  .mansysgallery__page-intro {
    font-size: 0.94rem;
  }

  .mansysgallery-lightbox {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    padding: 45px 4px 20px;
  }

  .mansysgallery-lightbox__nav {
    padding: 8px;
    font-size: 1.6rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mansysgallery__item img,
  .mansysgallery__button,
  .mansysgallery-lightbox,
  .mansysgallery-lightbox__figure,
  .mansysgallery-lightbox__image,
  .mansysgallery-lightbox__close,
  .mansysgallery-lightbox__nav {
    transition: none;
  }
}
