$product-card-picture-xs: 180px !default;
$product-card-picture-sm: 200px !default;
$product-card-picture-lg: 250px !default;

.product-card {
  position: relative;
  padding: var(--spacer-2);
  font-size: var(--font-size);
  border-radius: var(--border-radius);
  height: 100%;

  > section {
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  &__prices {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
  }

  &__offer-stamp {
    background-color: var(--success);
    color: var(--success-yiq);
    min-width: 55px;
    font-size: 80%;
    line-height: 2.2;
    text-align: center;
    position: absolute;
    z-index: 9;
    top: 1rem;
    right: 0;
    border-radius: var(--border-radius);
    transition: border-radius .3s;
    opacity: .9;

    i,
    svg {
      font-size: 85%;
      opacity: .8;
    }
  }

  &__link {
    outline: none;
  }

  &__pictures {
    position: relative;
    display: flex;
    align-items: center;
    text-align: center;
    overflow: hidden;
  }

  &__picture {
    position: absolute;
    display: block;
    flex: 0 0 100%;

    img {
      max-width: 100%;
    }

    &:not(:last-child) {
      opacity: 0;

      &.picture {
        background-color: none;
      }
    }

    &.loaded:last-child {
      transition: opacity .15s ease-out .1s;
      position: inherit;
      opacity: 1;
    }
  }

  @each $sel, $prop in ('__pictures': 'height', '__picture img': 'max-height') {
    &#{$sel} {
      #{$prop}: $product-card-picture-xs;

      @media (min-width: 576px) {
        #{$prop}: $product-card-picture-sm;
      }
      @media (min-width: 992px) {
        #{$prop}: $product-card-picture-lg;
      }
    }
  }

  &__name {
    --max-lines: 3;
    padding-top: var(--spacer-1);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-sm);
    overflow: hidden;
    font-weight: var(--font-normal);
    z-index: 1;
    display: -webkit-box;
    -webkit-line-clamp: var(--max-lines);
    -webkit-box-orient: vertical;

    @media (min-width: 992px) {
      --max-lines: 2;
    }
  }

  &__favorite {
    position: absolute;
    top: var(--spacer-1);
    font-size: var(--font-size-lg);
    z-index: 9;

    .active {
      color: var(--red);
    }
  }

  &__buy {
    position: relative;
    margin-top: var(--spacer-1);

    &-loading {
      position: absolute;
      left: var(--spacer-2);
      top: 50%;
      margin-top: -8px;
    }
  }

  @media (hover: hover) {
    &:hover {
      box-shadow: var(--box-shadow-sm);

      .product-card__offer-stamp {
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
      }

      .product-card__picture.loaded {
        position: inherit;
        opacity: 1;

        + .picture {
          position: absolute;
          opacity: 0;
          z-index: -1;
        }
      }

      .product-card__buy {
        opacity: 1;
      }

      .product-card__favorite {
        opacity: 0.7;
      }
    }
  }

  &--inactive,
  &--inactive img {
    opacity: .7;
  }

  &--small {
    @each $sel, $prop in ('__pictures': 'height', '__picture img': 'max-height') {
      .product-card#{$sel} {
        #{$prop}: $product-card-picture-xs * .5;

        @media (min-width: 576px) {
          #{$prop}: $product-card-picture-sm * .5;
        }
        @media (min-width: 992px) {
          #{$prop}: $product-card-picture-lg * .5;
        }
      }
    }

    .product-card__name {
      padding-top: var(--spacer-2);
      margin-bottom: 0;
      --max-lines: 2;
    }

    .product-card__buy {
      position: absolute;
      bottom: var(--spacer-3);
      right: var(--spacer-3);
    }
  }
}
