/**
 * Component: Card
 */
@include comp('card') {
  position: relative;
  flex: 1 1 100%;
  max-width: 100%;
  min-width: 0;

  font-size: rem($card-font-size);
  line-height: $card-line-height;

  border-radius: rem($card-radius);
  overflow: hidden;

  transition: $raise-shadow-transition;

  &::before {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    content: ' ';
    display: block;
  }

  & > img,
  & > video {
    position: relative;
    max-width: 100%;
    min-height: 0;
    max-height: 100%;
  }

  @include elem('header', 'footer', 'content', 'title', 'sub-content', 'divider') {
    position: relative;
    max-width: 100%;

    line-height: inherit;
  }

  @include elem('header', 'footer', 'content') {
    display: block;
    max-width: 100%;
    min-width: 0;
    max-height: 100%;
    min-height: rem($card-header-height + $border-base);
    padding: 0;
    margin: 0;
  }

  @include elem('header', 'footer') {
    display: flex;
    flex-flow: row nowrap;
    justify-content: flex-start;
    align-content: center;
    align-items: center;
  }

  @include elem('header') {
    height: rem($card-header-height);
    padding: 0 rem($gap-base);
    border-bottom: rem($border-base) solid transparent;
    line-height: rem($card-header-height - $gap-base * 2);
  }
  @include elem('footer') {
    padding: rem($gap-base);
    border-top: rem($border-base) solid transparent;
  }

  @include elem('content') {
    display: flex;
    flex-flow: column nowrap;
    justify-content: flex-start;
    align-content: stretch;
    align-items: stretch;
    padding: rem($gap-base);
    @include when('no-gap') {
      padding: rem($gap-base) 0;
    }
  }

  @include elem('title', 'summary') {
    padding: 0;
    margin: 0;
    font-weight: normal;

    &:not(:last-child) {
      margin-bottom: rem($gap-base / 2);
    }
  }

  @include elem('header', 'title') {
    font-weight: normal;
    font-size: rem($card-header-font-size);
  }

  @include elem('summary') {
    font-size: inherit;
  }

  @include elem('divider') {
    width: 100%;
    height: rem($border-base);
    margin: rem($gap-base / 2) 0;
  }

  // status & properties

  @include when('bordered') {
    border: rem($border-base) solid;
  }

  @include when('raise') {
    box-shadow: $raise-base;
    &:hover {
      box-shadow: $raise-hover;
    }
  }

  @each $raise, $value in $raise-shadow-map {
    @include prop(
      (
        'raise': $raise,
      )
    ) {
      box-shadow: $value;
    }
  }

  @each $raise, $value in $raise-shadow-map {
    @include prop(
      (
        'hover-raise': $raise,
      )
    ) {
      &:hover {
        box-shadow: $value;
      }
    }
  }

  @include when('transparent') {
    &::before {
      opacity: 0;
    }
  }
  @include when('translucent') {
    &::before {
      opacity: $opacity-translucent;
    }
  }

  @include when('center') {
    text-align: center;
    @include elem('header') {
      justify-content: center;
    }
  }

  @each $theme in $type-theme {
    @include prop(
      (
        'theme': $theme,
      )
    ) {
      color: theme($theme);
      border-color: theme($theme, 'bd');

      &::before {
        background-color: theme($theme, 'bg');
      }
      @include when('translucent') {
        &::before {
          background-color: theme($theme, 'bg', 'lower');
        }
      }

      @include elem('header') {
        color: theme($theme, 'fg', 'emphasize');
      }
      @include elem('footer', 'content') {
        color: theme($theme);
      }

      @include elem('title') {
        color: theme($theme, 'fg', 'emphasize');
      }
      @include elem('summary') {
        color: theme($theme, 'fg', 'sub');
      }

      @include elem('header', 'footer') {
        border-color: theme($theme, 'bd');
      }

      @include elem('divider') {
        background-color: theme($theme, 'bd');
      }
    }
  }

  @each $direction in $type-direction {
    @include prop(
      (
        'direction': $direction,
      )
    ) {
      display: flex;
      flex-wrap: nowrap;
      justify-content: flex-start;
      align-content: flex-start;
      align-items: flex-start;
    }
    @include prop(
      (
        'direction': $direction,
      )
    ) {
      flex-direction: $direction;

      & > img,
      & > video {
        flex: none;
      }

      @include elem('divider') {
        flex: none;
      }

      @if $direction == row or $direction == row-reverse {
        align-content: flex-start;
        align-items: flex-start;

        @include elem('header', 'footer', 'content') {
          flex: 1;
        }
        @include elem('divider') {
          width: rem($border-base);
          height: 100%;
        }
      } @else {
        & > img,
        & > video {
          flex: none;
        }
        @include elem('header', 'footer', 'content') {
          flex: none;
        }
        @include elem('divider') {
          width: 100%;
          height: rem($border-base);
        }
      }
    }
  }
}
