/* =========================================================
 Vanilla JavaScript Image Lightbox
 ========================================================= */

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 72px 80px 48px;

  background: rgba(5, 5, 5, 0.94);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);

  opacity: 0;
  visibility: hidden;
  pointer-events: none;

  transition:
    opacity 450ms ease,
    visibility 0s linear 450ms;
}

.image-lightbox.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;

  transition:
    opacity 450ms ease,
    visibility 0s linear 0s;
}

.lightbox-content {
  position: relative;

  display: flex;
  flex-direction: column;
  align-items: center;

  max-width: min(1100px, 88vw);
  max-height: 88vh;
  margin: 0;

  opacity: 0;
  transform: translateY(8px) scale(0.985);

  transition:
    opacity 500ms ease,
    transform 500ms ease;
}

.image-lightbox.is-open .lightbox-content.is-loaded {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.lightbox-image {
  display: block;

  max-width: 100%;
  max-height: 78vh;
  width: auto;
  height: auto;

  object-fit: contain;

  background: #000;
  border: 0;
  border-radius: 5px;
}

.lightbox-close {
  position: fixed;
  top: 20px;
  right: 22px;
  z-index: 10002;

  width: 58px;
  height: 58px;
  padding: 0;

  color: #ffffff;
  background: transparent;
  border: 0;
  box-shadow: none;

  cursor: pointer;

  transition:
    color 250ms ease,
    transform 250ms ease;
}

.lightbox-close span::before,
.lightbox-close span::after {
  content: "";

  position: absolute;
  top: 50%;
  left: 50%;

  width: 34px;
  height: 1px;

  background: currentColor;
  transform-origin: center;
}

.lightbox-close span::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.lightbox-close span::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.lightbox-arrow {
  position: fixed;
  top: 50%;
  z-index: 10001;

  display: grid;
  place-items: center;

  width: 54px;
  height: 74px;
  padding: 0;

  color: #ffffff;
  background: transparent;
  border: 0;
  box-shadow: none;

  cursor: pointer;
  transform: translateY(-50%);

  transition:
    color 250ms ease,
    transform 250ms ease;
}

.lightbox-previous {
  left: 22px;
  right: auto;
}

.lightbox-next {
  right: 22px;
  left: auto;
}

.lightbox-arrow span {
  display: block;
  width: 24px;
  height: 24px;

  border-top: 1px solid currentColor;
  border-left: 1px solid currentColor;
}

.lightbox-previous span {
  transform: translateX(4px) rotate(-45deg);
}

.lightbox-next span {
  transform: translateX(-4px) rotate(135deg);
}

.lightbox-close:hover,
.lightbox-close:focus-visible,
.lightbox-arrow:hover,
.lightbox-arrow:focus-visible {
  color: var(--color-gold);
  background: transparent;
}

.lightbox-close:hover,
.lightbox-close:focus-visible {
  transform: scale(1.08);
}

body.lightbox-open {
  overflow: hidden;
}

@media (max-width: 700px) {
  .image-lightbox {
    padding: 70px 18px 86px;
  }

  .lightbox-content {
    max-width: 100%;
  }

  .lightbox-image {
    max-height: 70vh;
  }

  .lightbox-arrow {
    top: auto;
    bottom: 18px;
    width: 46px;
    height: 46px;
    transform: none;
  }

  .lightbox-previous {
    left: calc(50% - 58px);
  }

  .lightbox-next {
    right: calc(50% - 58px);
  }

  .lightbox-close {
    top: 14px;
    right: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .image-lightbox,
  .lightbox-content,
  .lightbox-close,
  .lightbox-arrow {
    transition: none;
  }
}
