//
// Base styles
//

.#{$card-prefix-cls} {
  @include border-radius($card-border-radius);
  position: relative;
  display: flex;
  flex-direction: column;
  background-color: $card-bg;
  // overflow: hidden;
}

.#{$card-prefix-cls}-has-shadowed {
  box-shadow: $shadow-card;
}

.#{$card-prefix-cls}-shadowed-hover {
  &:hover {
    box-shadow: $shadow-base;
  }
}
.#{$card-prefix-cls}-has-border {
  border: $card-border-width solid $card-border-color;
}

.#{$card-prefix-cls}-block {
  // Enable `flex-grow: 1` for decks and groups so that card blocks take up
  // as much space as possible, ensuring footers are aligned to the bottom.
  flex: 1 1 auto;
  padding: $card-spacer-x;
}

.#{$card-prefix-cls}-title {
  margin-bottom: $card-title-spacer-y;
  font-size: $card-title-font-size;
}

.#{$card-prefix-cls}-subtitle {
  margin-top: -($card-spacer-y / 2);
  margin-bottom: 0;
}

.#{$card-prefix-cls}-text {
  font-size: $cart-text-font-size;
  color: $cart-text-color;

  &:last-child {
    margin-bottom: 0;
  }
}

.#{$card-prefix-cls}-link {
  @include hover {
    text-decoration: none;
  }

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

.#{$card-prefix-cls} {
  > .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);
    }
  }
}


//
// Optional textual caps
//

.#{$card-prefix-cls}-header {
  display: flex;
  align-items: center;
  height: auto;
  padding: $card-header-spacer-y $card-spacer-x;
  margin-bottom: 0; // Removes the default margin-bottom of <hN>
  font-size: $card-header-font-size;
  line-height: inherit;
  border-bottom: $card-border-width solid $card-border-color;
  color: $card-header-color;
  // background-color: $card-cap-bg;

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

.#{$card-prefix-cls}-footer {
  padding: $card-footer-spacer-y $card-footer-spacer-x;
  font-size: $card-footer-font-size;
  line-height: 1;
  background-color: $card-bg;
  border-top: $card-border-width solid $card-border-color;

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


//
// Header navs
//

.#{$card-prefix-cls}-header-tabs {
  margin-right: -($card-spacer-x / 2);
  margin-bottom: -$card-header-spacer-y;
  margin-left: -($card-spacer-x / 2);
  border-bottom: 0;
}

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

.#{$card-prefix-cls}-header-pills .nav-item {
  margin-right: $card-header-pills-item-gutter-x;
}

.#{$card-prefix-cls}-header-pills .nav-link {
  height: $card-header-pills-link-height;
  font-size: $card-header-pills-link-font-size;
  line-height: $card-header-pills-link-height;
  color: $card-header-pills-link-color;
  background: $card-header-pills-link-bg;
  border-radius: $card-header-pills-link-height;

  &.active {
    color: $card-header-pills-link-active-color;
    background-color: $brand-primary;
  }

  &.disabled {
    color: $card-header-pills-link-disabled-color;
    background: transparent;
  }
}


//
// Background variations
//

.#{$card-prefix-cls}-primary {
  @include card-variant($brand-primary, $brand-primary);
}

.#{$card-prefix-cls}-success {
  @include card-variant($brand-success, $brand-success);
}

.#{$card-prefix-cls}-info {
  @include card-variant($brand-info, $brand-info);
}

.#{$card-prefix-cls}-warning {
  @include card-variant($brand-warning, $brand-warning);
}

.#{$card-prefix-cls}-danger {
  @include card-variant($brand-danger, $brand-danger);
}

// Remove all backgrounds
.#{$card-prefix-cls}-outline-primary {
  @include card-outline-variant($btn-primary-bg);
}

.#{$card-prefix-cls}-outline-secondary {
  @include card-outline-variant($btn-secondary-border);
}

.#{$card-prefix-cls}-outline-info {
  @include card-outline-variant($btn-info-bg);
}

.#{$card-prefix-cls}-outline-success {
  @include card-outline-variant($btn-success-bg);
}

.#{$card-prefix-cls}-outline-warning {
  @include card-outline-variant($btn-warning-bg);
}

.#{$card-prefix-cls}-outline-danger {
  @include card-outline-variant($btn-danger-bg);
}

//
// Inverse text within a card for use with dark backgrounds
//

.#{$card-prefix-cls}-inverse {
  @include card-inverse;
}

//
// Blockquote
//

.#{$card-prefix-cls}-blockquote {
  padding: 0;
  margin-bottom: 0;
  border-left: 0;
}

// Card image
.#{$card-prefix-cls}-img-overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  padding: $card-img-overlay-padding;
}

.#{$card-prefix-cls}-img {
  @include border-radius($card-border-radius-inner);
  width: 100%; // Required because we use flexbox and this inherently applies align-self: stretch
}

// Card image caps
.#{$card-prefix-cls}-img-top {
  @include border-top-radius($card-border-radius-inner);
  width: 100%; // Required because we use flexbox and this inherently applies align-self: stretch
}

.#{$card-prefix-cls}-img-bottom {
  @include border-bottom-radius($card-border-radius-inner);
  width: 100%; // Required because we use flexbox and this inherently applies align-self: stretch
}


// Card deck

@include media-breakpoint-up(sm) {
  .#{$card-prefix-cls}-deck {
    display: flex;
    flex-flow: row wrap;
    margin-right: -$card-deck-margin;
    margin-left: -$card-deck-margin;

    .#{$card-prefix-cls} {
      display: flex;
      flex: 1 0 0;
      flex-direction: column;
      margin-right: $card-deck-margin;
      margin-left: $card-deck-margin;
    }
  }
}


//
// Card groups
//

@include media-breakpoint-up(sm) {
  .#{$card-prefix-cls}-group {
    display: flex;
    flex-flow: row wrap;

    .#{$card-prefix-cls} {
      flex: 1 0 0;

      + .#{$card-prefix-cls} {
        margin-left: 0;
        border-left: 0;
      }

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

        .#{$card-prefix-cls}-img-top {
          border-top-right-radius: 0;
        }

        .#{$card-prefix-cls}-img-bottom {
          border-bottom-right-radius: 0;
        }
      }

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

        .#{$card-prefix-cls}-img-top {
          border-top-left-radius: 0;
        }

        .#{$card-prefix-cls}-img-bottom {
          border-bottom-left-radius: 0;
        }
      }

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

        .#{$card-prefix-cls}-img-top, .#{$card-prefix-cls}-img-bottom {
          border-radius: 0;
        }
      }
    }
  }
}


//
// Columns
//

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

    .#{$card-prefix-cls} {
      display: inline-block; // Don't let them vertically span multiple columns
      width: 100%; // Don't let their width change
      margin-bottom: $card-columns-margin;
    }
  }
}
