//
// Base styles
//

.card {
  background-color: $card-bg;
  border: none;

  @include border-radius($card-border-radius);
  @include box-shadow($card-box-shadow);

  > .list-group:first-child {
    .list-group-item:first-child {
      @include border-top-radius($card-border-radius);
    }
  }

  > .list-group:last-child {
    .list-group-item:last-child {
      @include border-bottom-radius($card-border-radius);
    }
  }

  .list-group-item {
    padding: $card-list-group-item-padding;
  }

  // Fix paragraph margins inside cards
  .card-text {
    margin-bottom: $card-paragraph-margin-bottom;
  }

  // Remove text decoration.
  a:hover {
    text-decoration: none;
  }

  // Small card modifier.
  &-small {
    .card-header,
    .card-body,
    .card-footer {
      padding: $card-small-spacer-y $card-small-spacer-x;
    }

    box-shadow: $card-small-box-shadow;
  }
}

.card-body {
  padding: $card-spacer-x;

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

.card-title {
  font-weight: $card-title-font-weight;
  margin-bottom: $card-title-margin-bottom;
}

.card-subtitle {
  margin-top: -($card-spacer-y / 2);
}

.card-link {
  font-family: $card-link-font-family;

  + .card-link {
    margin-left: $card-spacer-x;
  }
}

//
// Optional textual caps
//

.card-header {
  padding: $card-header-spacer-y $card-header-spacer-x;
  background-color: $card-cap-bg;
  border-bottom: none;

  &:first-child {
    @include border-radius($card-inner-border-radius $card-inner-border-radius 0 0);
  }
}

.card-footer {
  padding: $card-footer-spacer-y $card-footer-spacer-x;
  background-color: $card-cap-bg;
  border-top: none;

  &:last-child {
    @include border-radius(0 0 $card-inner-border-radius $card-inner-border-radius);
  }
}


//
// Header navs
//

.card-header-tabs {
  margin-bottom: -1rem;
  border-bottom: 0;

  .nav-link,
  .nav-link:hover {
    border-bottom: transparent;
  }
}

.card-header-pills {
  margin-right: -($card-spacer-x / 2);
  margin-left: -($card-spacer-x / 2);

  &:hover {
    background: transparent;
  }
}

// Card image
.card-img-overlay {
  padding: $card-img-overlay-padding;
  background: rgba($blueish-grey, .5);
  border-radius: $card-border-radius;

  .card-title {
    color: $white;
  }
}

.card-img {
  @include border-radius($card-inner-border-radius);
}

// Card image caps
.card-img-top {
  @include border-top-radius($card-inner-border-radius);
}

.card-img-bottom {
  @include border-bottom-radius($card-inner-border-radius);
}


// Card deck

.card-deck {
  .card {
    margin-bottom: $card-deck-margin;
  }

  @include media-breakpoint-up(sm) {
    margin-right: -$card-deck-margin;
    margin-left: -$card-deck-margin;

    .card {
      margin-right: $card-deck-margin;
      margin-left: $card-deck-margin;
    }
  }
}


//
// Card groups
//

.card-group {
  // The child selector allows nested `.card` within `.card-group`
  // to display properly.
  > .card {
    @include box-shadow($card-box-shadow);

    &:last-child .card-body,
    &:last-child .card-footer {
      border-right: none;
    }
  }

  .card-body,
  .card-footer {
    border-right: $card-group-card-border;
  }

  @include media-breakpoint-up(sm) {
    @include box-shadow($card-box-shadow);
    @include border-radius($card-border-radius);

    > .card {
      box-shadow: none;

      // Handle rounded corners
      @if $enable-rounded {
        &:first-child {
          @include border-right-radius(0);
        }

        &:last-child {
          @include border-left-radius(0);
        }

        &:only-child {
          @include border-radius($card-border-radius);

          .card-img-top,
          .card-header {
            @include border-top-radius($card-border-radius);
          }
          .card-img-bottom,
          .card-footer {
            @include border-bottom-radius($card-border-radius);
          }
        }

        &:not(:first-child):not(:last-child):not(:only-child) {
          @include border-radius(0);

          .card-img-top,
          .card-img-bottom,
          .card-header,
          .card-footer {
            @include border-radius(0);
          }
        }
      }
    }
  }
}

//
// Columns
//

.card-columns {
  .card {
    margin-bottom: $card-columns-margin;
  }

  @include media-breakpoint-up(sm) {
    column-count: $card-columns-count;
    column-gap: $card-columns-gap;
  }
}
