//
// Base styles
//

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0;
  word-wrap: break-word;
  background-color: $card-bg;
  background-clip: border-box;
  // border: $card-border-width solid $card-border-color;
  box-shadow: $card-box-shadow;
  @include border-radius($card-border-radius);

  & + .card {
    margin-top: 1.6rem;
  }
}

.card-annotation {
  padding-top: 2rem;
  padding-right: 2rem;
  padding-bottom: 2rem;

  .row.no-gutters & {
    padding-left: 2rem;
  
    @include media-breakpoint-up(sm) {
      padding-left: 0;
    }
  }

  p {
    margin: 0;
    margin-top: 1.2rem;
    font-size: 1.5rem;

    @include media-breakpoint-up(sm) {
      font-size: 1.4rem;
    }
  }
}

.card-body, .card-title, .card-prompt {
  // 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;

  img {
    display: block;
    width: 100%;
    max-width: 25rem;
    height: auto;
    margin: 1.6rem 0;

    &:first-child {
      margin-top: 0;
    }

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

.card-body, .card-title {
  p, .card-scrollable {
    margin-top: 0.8rem;
    margin-bottom: 0.8rem;

    &:first-child {
      margin-top: 0;
    }

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

.card-prompt {
  max-width: 50.5rem;
  margin: 0 auto;
  text-align: center;

  img {
    margin-left: auto;
    margin-right: auto;
  }
}

.card-header-actions + .card-body,
.card-body + .card-body {
  border-top: 1px solid $gray-300;
}

.card-body--muted {
  background-color: $gray-100;
}

.card-body-section {
  padding-bottom: 2rem;

  &:last-of-type {
    padding-bottom: 0;
  }
}

.card-action,
.card-action-start,
.card-action-center,
.card-action-end {
  display: flex;
  // 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: 0 $card-spacer-x $card-spacer-x;
}

.card-action { justify-content: flex-end; }
.card-action-start { justify-content: flex-start; }
.card-action-center { justify-content: center; }
.card-action-end { justify-content: flex-end; }

.card-title {
  // margin-bottom: $card-spacer-y;
}

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

.card-text:last-child {
  margin-bottom: 0;
}

.card-link {
  @include hover {
    text-decoration: none;
  }

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

.card-scrollable {
  height: 100px;
  box-shadow: inset 0 -2rem 2rem -2rem rgba(0,0,0,.1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.card {
  > .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-header {
  padding: $card-spacer-y $card-spacer-x 0 $card-spacer-x;
  margin-bottom: 0; // Removes the default margin-bottom of <hN>

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    margin: 0;
    font-size: 1.7rem;
    font-weight: 600;
    line-height: 2.4rem;

    @include media-breakpoint-up(sm) {
      font-size: 1.6rem;
    }
  }
}

.card-header-actions {
  padding: 0;
  margin-bottom: 0; // Removes the default margin-bottom of <hN>
}

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

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


//
// Header navs
//

.card-header-tabs {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card-header-tab {
  display: inline-block;
  margin-left: 1.6rem;

  > a {
    display: block;
    padding: 1.6rem 0;
    color: $gray-600;
    border-bottom: solid 3px transparent;

    &:hover {
      color: $gray-900;
      border-color: $gray-400;
    }

    &.active {
      color: $gray-900;
      border-color: $indigo;

      &:hover {
        border-color: $indigo;
      }
    }
  }
}


// Card deck

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

    .card {
      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-group {
    display: flex;
    flex-flow: row wrap;

    .card {
      flex: 1 0 0%;

      + .card {
        margin-left: 0;
        border-left: 0;
      }

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

          .card-img-top {
            border-top-right-radius: 0;
          }
          .card-img-bottom {
            border-bottom-right-radius: 0;
          }
        }
        &:last-child {
          @include border-left-radius(0);

          .card-img-top {
            border-top-left-radius: 0;
          }
          .card-img-bottom {
            border-bottom-left-radius: 0;
          }
        }

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

          .card-img-top,
          .card-img-bottom {
            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;

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