.textmedia-masonry__grid {
  display: grid;
  grid-gap: var(--g-gap-s);
  padding: 0 1rem;
}

.textmedia-masonry_text {
  background-color: rgb(var(--c-primary));
  font-weight: var(--f-weight-ebl);
  font-size: var(--f-size-l-2);
  color: rgb(var(--c-neutral-lightest));
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-wrap: balance;
}

.textmedia-masonry_text a {
  color: rgb(var(--c-neutral-lightest));
  text-decoration: none;
}

.textmedia-masonry__image {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;

  &::after {
    content: "";
    background: -moz-linear-gradient(top, #000000 0%, #fff0 100%);
    background: -webkit-linear-gradient(top, #000000 0%, #fff0 100%);
    background: linear-gradient(to bottom, #000000 0%, #fff0 100%);
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#00000000', GradientType=0);
    height: 520px;
    position: absolute;
    bottom: -400px;
    width: calc(100% + 100px);
    left: -50px;
    right: -50px;
    z-index: 0;
    filter: blur(50px);
  }

  & img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.04);
    transition: all ease-out 1s;
    -webkit-backface-visibility: hidden;
  }

  & hr {
    border: 1px solid rgb(var(--c-neutral-lightest));
    height: 4rem;
    margin-right: 1rem;
    margin-left: 1rem;
  }

  & .gallery__caption_wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  & .gallery__title {
    position: absolute;
    z-index: 2;
    bottom: 1rem;
    right: var(--g-gap);
    color: rgb(var(--c-neutral-lightest));
    font-size: var(--f-size-l-3);
    font-weight: var(--f-weight-ebl);
    font-style: normal;
    line-height: 1.25;
  }

  & .gallery__caption {
    position: absolute;
    z-index: 2;
    bottom: 4rem;
    right: var(--g-gap);
    color: rgb(var(--c-neutral-lightest));
    font-style: normal;
    line-height: 1.25;
    display: flex;
    align-items: center;
  }

  & .gallery__caption h3,
  & .gallery__caption h4 {
    color: rgb(var(--c-neutral-lightest));
  }

  & .gallery__caption h3 {
    font-size: var(--f-size-l-5);
    font-weight: var(--f-weight-ebl);
    line-height: 0.8;
  }

  & .gallery__caption h4 {
    font-size: var(--f-size-l-3);
    font-weight: var(--f-weight-ebl);
    text-transform: uppercase;
  }
}

@media (hover: hover) {
  .textmedia-masonry__image:hover {
    & img {
      transform: scale(1);
    }
  }
}

/* =============================================================================
   Media Queries
   ========================================================================== */

@media (min-width: 640px) {
  .textmedia-masonry__grid {
    grid-template-columns: repeat(12, 1fr);
    grid-auto-flow: dense;
  }

  .textmedia-masonry_text {
    &:nth-child(1) {
      grid-column: span 6;
    }

    &:nth-child(2) {
      grid-column: span 6;
    }
  }

  .textmedia-masonry__image {
    min-height: 20vw;

    &:nth-child(3) {
      grid-column: span 6;
    }

    &:nth-child(4) {
      grid-column: span 6;
    }

    &:nth-child(5) {
      grid-column: 4 / 10;
    }
  }
}

@media (min-width: 1024px) {
  .textmedia-masonry__grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(12, 4vw);
    grid-gap: var(--g-gap-s);
    grid-auto-flow: dense;
    padding: 0 8.5rem;
  }

  .textmedia-masonry_text {
    &:nth-child(1) {
      grid-row: 10 / 12;
      grid-column: 1;
    }

    &:nth-child(2) {
      grid-row: 1 / 3;
      grid-column: 2;
    }
  }

  .textmedia-masonry__image {
    aspect-ratio: initial;
    min-height: auto !important;

    &:nth-child(3) {
      grid-row: 2 / 10;
      grid-column: 1;
    }

    &:nth-child(4) {
      grid-row: 3 / 9;
      grid-column: 2;
    }

    &:nth-child(5) {
      grid-row: 9 / 13;
      grid-column: 2;
    }
  }
}

@media (min-width: 1410px) {
  .textmedia-masonry__grid {
    grid-template-rows: repeat(12, 52px);
  }
}
