@use '../base/variable';
@use '../base/token';
@use '../abstract';
@use '../sprite';

.cds-media {
  $this: &;
  $padding: 32px;
  $max-img-size: 560px;
  display: flex;
  flex-direction: column-reverse;
  gap: 40px;
  // contents
  // ===========================
  &__content {
    padding-left: variable.$gap-sm;
    padding-right: variable.$gap-sm;
    margin-bottom: 40px;
  }

  &__icon {
    margin-bottom: 24px;
  }

  &__title {
    margin-bottom: 8px;
    color: var(--gray-700);
    font-weight: abstract.font-weight-to-number(token.$font-weights-commerce-sans-2);
    font-size: token.$font-size-5;
    white-space: break-spaces;
  }

  &__text {
    margin-bottom: 32px;
    white-space: break-spaces;
    color: var(--gray-400);
    line-height: #{token.$line-heights-8}px;
  }

  // image
  // ===========================
  &__img {
    overflow: hidden;

    img {
      width: 100%;
      -o-object-fit: cover;
      object-fit: cover;
      vertical-align: top;
    }
  }

  @include abstract.media-bp-up('md') {
    $center-gap: calc(96px / variable.$max-width * 100%);

    display: flex;
    gap: 0;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0 $padding;
    max-width: variable.$max-width;
    margin-left: auto;
    margin-right: auto;

    &__title {
      font-size: abstract.rem(token.$font-size-6);
    }

    &__text {
      @include abstract.font-18-line-height-28;
    }

    &__content,
    &__img {
      width: calc($max-img-size / (variable.$max-width - ($padding * 2)) * 100%);
    }

    &__content {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: flex-start;
      padding-left: 0;
      padding-right: 0;
      margin-bottom: 0;
      word-break: break-all;
    }

    &__title {
      margin-bottom: 16px;
    }

    &__img {
      margin-left: $center-gap;
      border-radius: 24px;

      img {
        height: 100%;
      }
    }

    &--reverse {
      #{$this}__content {
        order: 2;
      }
      #{$this}__img {
        margin-right: $center-gap;
        margin-left: 0;
        order: 1;
      }
    }
  } // md

  // common
  // ======================
  &__content > *:last-child {
    margin-bottom: 0;
  }
}
