// Name:            Card
//
// Component:       `card`
// ========================================================================

// Variables
// ========================================================================
$card-shadow: 0 1px 1px rgba(0, 0, 0, .05) !default;
$card-actions-link-color: $gray-400 !default;
$card-actions-link-hover-color: $gray-300 !default;
$card-posts-horizontal-border: $border-color-base !default;

// $card-margin-bottom:             2.143rem !default;
$card-margin-bottom: pxtorem(30px) !default;
// $card-header-padding:            $card-spacer-x;

// Component: Card
// ========================================================================

.card {
  margin-bottom: $card-margin-bottom;
  border: none;
  box-shadow: none;

  .cover {
    width: 100%;
    padding: 0;
    border-bottom: none;
  }

  [class*="blocks-"] > li > & {
    margin-bottom: 0;
  }
}

.card-title {
  margin-top: 0;
}

.card-header, .card-footer {
  border: none;
  box-shadow: none;
}

// Modifier: `card-inverse`
// -------------------------
.card-inverse {
  @include card-inverse;
}

// Modifier: `card-bordered`
// -------------------------
.card-bordered {
  border: $card-border-width solid $card-border-color;
}

// .card-header-no-border {
//   border: none;
// }

// .card-footer-no-border {
//   border: none;
// }

.card-header-bordered {
  border-bottom: $card-border-width solid $card-border-color;
}

.card-footer-bordered {
  border-top: $card-border-width solid $card-border-color;
}

// Modifier: `card transparent`
// -------------------------
.card-transparent {
  background-color: transparent;
}

.card-header-transparent {
  background-color: transparent;
}

.card-footer-transparent {
  background-color: transparent;
}

// Modifier: `card-shadow`
// -------------------------

.card-shadow {
  box-shadow: $card-shadow;
}

// .card-header-shadow {
//   box-shadow: 0 $card-border-width 0 0 $card-border-color;
// }

// .card-footer-shadow {
//   box-shadow: 0 (-$card-border-width) 0 0 $card-border-color;
// }

// Component: Card block
// ========================================================================

.card-block {
  position: relative;
  // 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;
}

// Strucutes
// ========================================================================

.card-text {
  &.type-link {
    a {
      position: relative;
      display: inline-block;
      padding: 3px 5px;
      color: $gray-400;

      &:first-child {
        padding-left: 0;
      }

      &:hover {
        color: $gray-300;
      }

      + a::before {
        position: absolute;
        top: 10px;
        left: -2px;
        width: 3px;
        height: 3px;
        content: "";
        background-color: $gray-400;
        border-radius: 50%;
      }
    }
  }
}

// Card Watermark
// ========================================================================

.card-watermark {
  position: absolute;
  right: 0;
  bottom: 0;
  line-height: 1;
  opacity: .1;

  &.darker {
    color: $black;
  }

  &.lighter {
    color: $white;
  }
}

// Card divider
// ========================================================================

.card-divider {
  &::after {
    display: block;
    width: 20px;
    height: 2px;
    margin: 15px auto;
    content: "";
    background-color: $inverse;
  }
}

// card Actions
// ========================================================================

.card-actions {
  margin-top: 10px;
  text-align: right;

  a {
    display: inline-block;
    margin-right: 10px;
    color: $card-actions-link-color;
    vertical-align: middle;

    &.icon, & .icon {
      text-decoration: none;

      & + span {
        margin-left: 2px;
      }
    }

    &.active, &:hover, &:focus {
      color: $card-actions-link-hover-color;
      text-decoration: none;
    }

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

.card-actions-sidebar {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 60px;

  a {
    display: inline-block;
    width: 100%;
    height: 60px;
    margin-right: 0;
    text-align: center;
    border-right: 1px solid $card-posts-horizontal-border;

    &::before {
      display: inline-block;
      height: 100%;
      vertical-align: middle;
      content: "";
    }

    + a {
      border-top: 1px solid $card-posts-horizontal-border;
    }
  }

  + .card-content {
    margin-left: 80px;
  }
}

// Card image
.card-img {
  border-radius: 0;
}

// Card Two Column
// ========================================================================
$card-img-left-width-percent: 40% !default;
$card-img-left-mobile-height: 320px !default;

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

  // stylelint-disable
  @include media-breakpoint-down(sm) {
    position: relative;
    width: 100%;
    height: $card-img-left-mobile-height;

    ~ .card-block {
      width: 100%;
      margin-left: 0;
    }
  }
  position: absolute;
  top: 0;
  left: 0;
  width: $card-img-left-width-percent;
  height: 100%;

  ~ .card-block {
    width: (100% - $card-img-left-width-percent);
    margin-left: $card-img-left-width-percent;
  }
  // stylelint-enable
}

// Background variations
// ========================================================================

.card-default {
  @include card-variant($brand-default, $brand-default);
}

.card-columns {
  .card {
    margin-bottom: $card-margin-bottom;
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

.card-sm {
  .card-header {
    padding: $card-sm-spacer-y $card-sm-spacer-x;
  }

  .card-block {
    padding: $card-sm-spacer-x;
  }

  .card-footer {
    padding: $card-sm-spacer-y $card-sm-spacer-x;
  }
}

.card-md {
  .card-header {
    padding: $card-md-spacer-x $card-md-spacer-y;
  }

  .card-block {
    padding: $card-md-spacer-x;
  }

  .card-footer {
    padding: $card-md-spacer-y $card-md-spacer-x;
  }
}

.card-lg {
  .card-header {
    padding: $card-lg-spacer-x;
  }

  .card-block {
    padding: $card-lg-spacer-x;
  }

  .card-footer {
    padding: $card-lg-spacer-x;
  }
}

.card-header-actions {
  float: right;
  margin: 0;
}

// @include media-breakpoint-down(xs) {
//   .card-header-actions {
//     float: none;
//     margin: 10px 0;
//   }
// }

// fix listgroup in card next card-header & card-footer
.card {
  > .list-group:not(:first-child) > .list-group-item:first-child {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
  }

  > .list-group:not(:last-child) > .list-group-item:last-child {
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 0;
  }
}

// fix card-block + card-block
.card {
  .card-block + .card-block {
    padding-top: 0;
  }
}
