@use '../core' as *;

.#{$prefix}-card {
  position: relative;
  display: flex;
  flex-direction: column;
  flex-grow: 1;

  &--raised {
    background-color: $color-white-base;
    border-radius: $spacing-xs;
    box-shadow: $shadow-heavy;
  }

  &__image img {
    display: block;
    width: 100%;
    border-radius: $spacing-xs;
  }

  &--raised &__image img {
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 0;
  }

  &__body {
    padding-top: $spacing-sm;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
  }

  &--raised &__body {
    padding: $spacing-sm;
  }

  &__eyebrow {
    color: $color-crimson-500;
    font-size: $ts-14;
    text-decoration: none;
  }

  &__eyebrow[href]:hover {
    text-decoration: underline;
  }

  &__title {
    font-size: $ts-20;
    padding-right: $spacing-xl;
    line-height: 1.3;
  }

  &__title a {
    display: block;
    text-decoration: none;
    color: $color-black-500;
  }

  &__title a::before {
    content: '';
    border-radius: 999rem;
    display: block;
    width: $spacing-sm;
    height: $spacing-sm;
    background-color: $color-blue-000;
    padding: $spacing-xs;
    position: absolute;
    right: $spacing-xs;
    background-size: $spacing-sm $spacing-sm;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="%23006298" viewBox="0 0 16 16"><path d="M1 7h10.844L7.737 2.146 9.263.854 15.31 8l-6.047 7.146-1.526-1.292L11.844 9H1V7Z"></path></svg>');
    background-repeat: no-repeat;
    background-position: center;
    transition: all .2s ease;
  }

  &--raised &__title a::before {
    right: $spacing-md;
  }

  &--clickable &__title a::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
  }

  &__title a:hover {
    color: $color-blue-500;
    text-decoration: underline;
  }

  &__title a:hover::before {
    transform: translate($spacing-xs, 0);
    background-color: $color-blue-100;
  }

  &__content {
    border-top: 1px solid $color-black-100;
    flex-grow: 1;
    margin-top: $spacing-md;
    color: $color-black-400;
    padding-top: $spacing-md;
  }

  &__meta {
    font-size: $ts-14;
    padding-top: $spacing-md;
  }

  &__meta > * {
    margin-top: 0;
    margin-bottom: 0;
  }
}

@media screen and (min-width: $breakpoint-sm) {
  .#{$prefix}-card {
    &__body {
      padding-top: $spacing-md;
    }

    &--raised &__body {
      padding: $spacing-md;
    }
  }
}

// Horizontal variant

.#{$prefix}-card {
  &--horizontal {
    flex-direction: row;
    gap: $spacing-md;
  }

  &--horizontal &__image {
    flex-shrink: 0;
    width: 25%;
    max-width: var(--image-max-width, 180px);

    @media screen and (min-width: $breakpoint-md) {
      width: 33%;
    }
  }

  &--horizontal &__body,
  &--horizontal &__meta {
    padding-top: 0;
  }

  &--horizontal &__content {
    flex-grow: 0;
    padding-top: 0;
  }

  @media screen and (max-width: $breakpoint-md) {
    &--horizontal &__title {
      font-size: $ts-18;
      padding-right: $spacing-xxl;

      & a::before {
        margin-top: -$spacing-sm;
      }
    } 
  }
}

.#{$prefix}-card--horizontal.#{$prefix}-card--raised {
  padding: $spacing-md;

  .#{$prefix}-card__image img {
    border-radius: $border-radius-md;
  }

  .#{$prefix}-card__body {
    padding: 0;
  }
}