.grid {
  display: grid;
  grid-gap: 0px;
  grid-auto-flow: dense;
  position: relative;
}

.grid-borders {
  position: absolute;
  z-index: -1;
  width: 100%;
  height: 100%;
  border: 2px solid black;
}

.grid-item {
  position: relative;
  background-color: transparent;
}
.grid-item figure {
  height: 100%;
  overflow: hidden;
}
.grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.grid-item .overlay {
  position: absolute;
  top: 0;
  width: 100%;
  height: 100%;
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: transparent;
  border: var(--ui_stroke_width) solid black;
  visibility: hidden;
}
.grid-item:active .overlay {
  visibility: visible;
}
.grid-item_video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@keyframes spinner--infinite {
  to {
    transform: rotateZ(360deg);
  }
}
.grid-item__loader {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: transparent;
  background-color: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
}
.grid-item__loader__spinner {
  border: 2px solid #00f;
  border-left-color: transparent;
  border-bottom-color: transparent;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  animation: spinner--infinite 0.8s linear infinite;
}

.grid-item_loaded .grid-item__loader {
  display: none;
}

.grid {
  grid-template-columns: repeat(1, 100%);
  grid-template-rows: calc((100vw - 4.5rem) / 1 * 0.625);
  grid-auto-rows: calc((100vw - 4.5rem) / 1 * 0.625);
}

@media only screen and (min-width: 768px) {
  .grid {
    grid-template-columns: repeat(2, 50%);
    grid-template-rows: calc((100vw - 4.5rem) / 2 * 0.5625);
    grid-auto-rows: calc((100vw - 4.5rem) / 2 * 0.5625);
  }
}
@media only screen and (min-width: 769px) {
  .grid {
    grid-template-columns: repeat(3, 33.3333333333%);
    grid-template-rows: calc((100vw - 4.5rem) / 3 * 0.5625);
    grid-auto-rows: calc((100vw - 4.5rem) / 3 * 0.5625);
  }
}
@media only screen and (min-width: 1025px) {
  .grid-item:hover .overlay {
    visibility: visible;
  }

  .grid-item:hover figure {
    opacity: 0;
  }
}
