/*================================
Cards - Co-op front-end components
================================== */

.coop-c-card {
  @include spacing('margin', 'bottom', 'base');
}

.coop-c-card__content {
  padding: 12px;
  color: $text;
  background: $page;
  box-shadow: 0 5px 0 0 rgba(0,0,0,0.05);

  > :first-child {
    margin-top: 0;
    padding-top: 0;
  }

  > :last-child {
    margin-bottom: 0;
    padding-bottom: 0;
  }

  @include media(medium) {
    padding: 24px;
  }
}


.coop-c-card__image {
  display: block;
  width: 100%;
}

// Only apply the content offset if an image is present
.coop-c-card__image + .coop-c-card__content {
  position: relative;
  z-index: 101;
  margin: -32px $eighth-spacing-unit 0 0;

  @include media(small) {
    margin-right: $quarter-spacing-unit;
  }

  @include media(medium) {
    margin: -50px $half-spacing-unit 0 0;
  }
}


.coop-c-card__title {
  color: $text;
}

.coop-c-card-heading {
  position: absolute;
  top: -20px;
  left: 20px;
  z-index: 110;
  display: block;
  padding: 20px 24px;
  background: $page;
  font-family: $medium;
  font-size: em-calc(16px);
  padding: 8px 12px;

  @include media(medium) {
    top: -24px;
    left: 40px;
    padding: 8px 12px;
    font-size: em-calc(20px);
  }

  @include media(large) {
    top: -35px;
    padding: 18px 24px;
  }
}

.coop-c-card-heading__link {
  display: block;
  color: $text;
  text-decoration: underline;
  border-bottom: 0;

  &:hover {
    color: $text;
    text-decoration: none;
  }
}

// Some styles are only applied if the card is a link
.coop-c-card__link {
  display: block;
  border-bottom: 0;

  .coop-c-card__content {

    .coop-c-card__title {
      text-decoration: underline;
    }

    &:hover {

      .coop-c-card__title {
        text-decoration: none;
      }
    }
  }
}

@mixin cardBackground($link, $backgroundColour) {
  background-color: $backgroundColour;
  box-shadow: none;

  a {
    color: $link;
    border-color: $link;
  }
}

.coop-c-card__content--background {
  @include cardBackground($text, $yellow-mid);
}
