.textmedia-masonry__text {
  margin-bottom: 2rem;
  max-width: 600px;
  text-wrap: balance;
}

.textmedia-masonry__arrow {
  display: none;
}

.textmedia-masonry__imagelist {
  display: grid;
  grid-gap: var(--g-gap-s);
}

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

  &::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    bottom: 0;
    left: 0;
    z-index: 1;
    background: linear-gradient(180deg, rgba(var(--c-neutral-darkest), 0) 0%, rgba(var(--c-neutral-darkest), 0.2) 80%, rgba(var(--c-neutral-darkest), 0.4) 100%);
    pointer-events: none;
  }

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

  & .gallery__caption {
    position: absolute;
    z-index: 2;
    bottom: var(--g-gap-s);
    left: var(--g-gap-s);
    right: var(--g-gap-s);
    color: rgb(var(--c-neutral-lightest));
    font-style: normal;
    font-family: var(--f-family-h);
    font-size: var(--f-size-l-2);
    line-height: 1.25;
  }
}

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

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

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

  .textmedia-masonry__image {
    aspect-ratio: initial;
    min-height: 20vw;

    &:nth-child(1) {
      grid-row: span 2;
      grid-column: 1;
      min-height: 30vw;
    }

    &:nth-child(5) {
      grid-row: span 2;
      grid-column: 2;
      min-height: 30vw;
    }

    &:nth-child(2),
    &:nth-child(3) {
      grid-column: 2;
    }

    &:nth-child(6),
    &:nth-child(7) {
      grid-column: 1;
    }

    &:nth-child(4),
    &:nth-child(8) {
      grid-column: span 2;
    }
  }
}

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

  .textmedia-masonry__arrow {
    display: block;
    grid-column: 4 / 6;
    margin-right: 1rem;
    margin-top: -0.5rem;
    width: 6vw;
    height: 6vw;
    max-width: 100px;
    max-height: 100px;
    align-self: end;
    justify-self: end;
  }

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

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

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

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

    &:nth-child(4) {
      grid-row: 8 / 10;
      grid-column: 1 / 6;
    }

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

    &:nth-child(6) {
      grid-row: 4 / 8;
      grid-column: 11 / 16;
    }

    &:nth-child(7) {
      grid-row: 8 / 11;
      grid-column: 11 / 15;
    }

    &:nth-child(8) {
      grid-row: 10 / 13;
      grid-column: 4 / 11;
    }
  }
}

@media (min-width: 1410px) {
  .textmedia-masonry__imagelist {
    grid-template-columns: repeat(15, 72px);
    grid-template-rows: repeat(12, 72px);
    margin-left: -94px;
    margin-right: -94px;
  }

  .textmedia-masonry__image {
    & .gallery__caption {
      font-size: var(--f-size-l-3);
    }
  }
}