:root {
  --image-lightbox-z: 2147483000;
}

html[data-image-lightbox-open='true'],
html[data-image-lightbox-open='true'] body {
  overscroll-behavior: none;
}

img.is-lightbox-eligible {
  cursor: zoom-in;
}

img.is-lightbox-eligible:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 4px;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--image-lightbox-z);
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  color: #f7f5ef;
  background: rgba(5, 6, 7, 0.96);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  overflow: hidden;
  transition: opacity 220ms ease, visibility 0s 220ms;
}

.image-lightbox[data-open='true'] {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

.image-lightbox__top,
.image-lightbox__bottom {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 48px;
}

.image-lightbox__counter {
  margin: 0;
  color: rgba(247, 245, 239, 0.62);
  font: 700 11px/1.3 Arial, 'Noto Sans KR', sans-serif;
  letter-spacing: 0.14em;
}

.image-lightbox__close,
.image-lightbox__nav {
  min-width: 48px;
  min-height: 44px;
  border: 1px solid rgba(247, 245, 239, 0.35);
  border-radius: 0;
  color: #f7f5ef;
  background: rgba(5, 6, 7, 0.72);
  font: 700 11px/1 Arial, 'Noto Sans KR', sans-serif;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.image-lightbox__close {
  padding: 0 18px;
}

.image-lightbox__close:hover,
.image-lightbox__close:focus-visible,
.image-lightbox__nav:hover,
.image-lightbox__nav:focus-visible {
  border-color: #f7f5ef;
  color: #050607;
  background: #f7f5ef;
  outline: none;
}

.image-lightbox__stage {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 10px clamp(54px, 7vw, 104px);
}

.image-lightbox__figure {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  margin: 0;
}

.image-lightbox__image {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: calc(100dvh - 154px);
  object-fit: contain;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.38);
  opacity: 0;
  transform: scale(0.985);
  transition: opacity 200ms ease, transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.image-lightbox[data-open='true'] .image-lightbox__image[data-ready='true'] {
  opacity: 1;
  transform: scale(1);
}

.image-lightbox__nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 58px;
  padding: 0 8px;
  transform: translateY(-50%);
}

.image-lightbox__nav--previous {
  left: 0;
}

.image-lightbox__nav--next {
  right: 0;
}

.image-lightbox__nav[hidden] {
  display: none;
}

.image-lightbox__caption {
  max-width: min(760px, 72vw);
  margin: 0;
  color: rgba(247, 245, 239, 0.78);
  font: 500 13px/1.55 Arial, 'Noto Sans KR', sans-serif;
  letter-spacing: -0.01em;
}

.image-lightbox__hint {
  flex: 0 0 auto;
  margin: 0;
  color: rgba(247, 245, 239, 0.42);
  font: 700 10px/1.3 Arial, 'Noto Sans KR', sans-serif;
  letter-spacing: 0.12em;
}

@media (max-width: 640px) {
  .image-lightbox {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .image-lightbox__stage {
    padding: 8px 0 62px;
  }

  .image-lightbox__image {
    max-height: calc(100dvh - 176px);
  }

  .image-lightbox__nav {
    top: auto;
    bottom: 4px;
    width: calc(50% - 6px);
    transform: none;
  }

  .image-lightbox__nav--previous {
    left: 0;
  }

  .image-lightbox__nav--next {
    right: 0;
  }

  .image-lightbox__bottom {
    position: absolute;
    right: max(12px, env(safe-area-inset-right));
    bottom: max(68px, calc(env(safe-area-inset-bottom) + 56px));
    left: max(12px, env(safe-area-inset-left));
    z-index: 3;
    align-items: flex-start;
    min-height: auto;
    pointer-events: none;
  }

  .image-lightbox__caption {
    max-width: 100%;
    padding: 7px 9px;
    background: rgba(5, 6, 7, 0.68);
    font-size: 12px;
  }

  .image-lightbox__hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .image-lightbox,
  .image-lightbox__image,
  .image-lightbox__close,
  .image-lightbox__nav {
    transition: none;
  }
}
