.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  color: var(--black);
}

.lightbox[hidden] {
  display: none;
}

.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: var(--white);
  opacity: 0;
  transition: opacity 600ms var(--ease-out);
}

.lightbox.is-shown .lightbox__backdrop {
  opacity: 1;
}

.lightbox__viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.lightbox__frame {
  position: absolute;
  overflow: visible;
}

.lightbox__media {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: 50% 50%;
  will-change: transform;
  -webkit-user-drag: none;
}

video.lightbox__media {
  object-fit: contain;
  background: var(--black);
}

.lightbox__bar {
  position: absolute;
  inset: 0 0 auto;
  height: var(--header-h);
  align-items: center;
  background: var(--white);
  opacity: 0;
  transition: opacity 500ms var(--ease-out);
}

.lightbox.is-shown .lightbox__bar {
  opacity: 1;
}

.lightbox__bar button {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  background: linear-gradient(currentColor, currentColor) no-repeat 0 calc(100% - 11px) / 0 1px;
  transition: background-size var(--dur) var(--ease-out);
}

.lightbox__bar button[hidden] {
  display: none;
}

@media (hover: hover) {
  .lightbox__bar button:hover {
    background-size: 100% 1px;
  }
}

.lightbox__close {
  grid-column: 1;
  justify-self: start;
}

.lightbox__counter {
  grid-column: 2;
  color: var(--accent);
}

.lightbox__caption,
.lightbox__zoom {
  display: none;
}

.lightbox__prev {
  grid-column: 3;
  justify-self: end;
}

.lightbox__next {
  grid-column: 4;
  justify-self: end;
}

@media (min-width: 768px) {
  .lightbox__close {
    grid-column: 1 / span 2;
  }

  .lightbox__counter {
    grid-column: 3;
  }

  .lightbox__caption {
    display: block;
    grid-column: 4 / span 5;
    overflow: hidden;
    color: var(--gray);
    text-overflow: ellipsis;
    text-transform: none;
    letter-spacing: normal;
    white-space: nowrap;
  }

  .lightbox__zoom {
    display: inline-flex;
    grid-column: 9;
  }

  .lightbox__prev {
    grid-column: 10 / span 2;
    justify-self: start;
  }

  .lightbox__next {
    grid-column: 12;
  }
}
