/**
* Mixin to create aspect-ratio for images.
*/

@mixin image-aspect-ratio($maxWidth, $aspectRatio) {
  position: relative;
  width: 100%;
  max-width: $maxWidth;
  margin: 0;

  figure {
    width: 100%;
    height: 100%;

    figcaption {
      display: block;
      margin-top: 8px;
    }
  }

  div {
    position: relative;
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;

    &::before {
      display: block;
      padding-bottom: $aspectRatio;
      content: '';
    }
  }

  img,
  svg {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
  }
}
