@use "../../foundations/helpers/forward.helpers.scss" as *;
@use "../../assets/teaser/teaser.scss" as *;

.ds-split-container {
  padding: ds-spacing($ds-s-075 $ds-s-100 $ds-s-100);
  display: flex;
  flex-wrap: wrap;
  position: relative;
  box-sizing: border-box;
  background: $ds-color-surface-primary;

  @at-root .ds-teaser-package > & + & {
    &:before {
      content: "";
      height: ds-border-width(xxs);
      background-color: $ds-color-border-primary;
      left: 0;
      right: 0;
      top: 0;
      position: absolute;
      margin: ds-spacing(0 $ds-s-100);
    }
  }

  &.ds-split-container--bauta {
    background-color: $ds-color-surface-breaking;
  }
}

.ds-teaser--split {
    box-sizing: content-box;
    display: block;
    position: relative;
    flex: 1;
    min-width: 0; // Keep teaser from becoming too wide when it contains long word.
    margin-right: ds-spacing($ds-s-100);

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

    @include ds-teaser-focus(4px);

    @include ds-hover(true) {
      .ds-teaser__title {
        @include ds-underline();
      }
    }

    @include ds-mq-largest-breakpoint(mobile) {
      width: calc(50% - ds-spacing($ds-s-100) / 2);
      flex: auto;
      // if a teaser is both third and last child it has the row by itself and should be full width
      &:nth-child(3):last-child {
        flex: 1;
      }
      &:nth-child(2) {
        margin-right: 0;
      }
    }

    &:nth-child(3)::before,
    &:nth-child(4)::before {
      display: block;
      content: "";
      margin-top: ds-spacing($ds-s-100);
      padding-top: ds-spacing($ds-s-075);
      border-top: ds-border-width(xxs) solid $ds-color-border-primary;

      @include ds-mq-smallest-breakpoint(tablet) {
        margin-top: 0;
        padding-top: 0;
        border-top: none;
      }
    }

    &:nth-child(3):not(:last-child)::before {
      margin-right: ds-spacing($ds-s-100, "px", true);
    }

    .ds-teaser__title {
      @include ds-typography($ds-typography-detail-teaser-twin);
    }

    .ds-teaser__text {
      overflow-wrap: break-word;
    }

    .ds-teaser__media {
      margin-top: ds-spacing($ds-s-025);

      .ds-teaser-image__byline {
        @include ds-typography($ds-typography-functional-meta-sm, $forcePx: true, $lineHeight: $ds-lineheight-lg);
      }

      @include ds-mq-largest-breakpoint(mobile) {
        margin-bottom: ds-spacing($ds-s-050);

        .ds-teaser-image__byline {
          display: none;
        }
      }

      @include ds-mq-smallest-breakpoint(tablet) {
        margin-bottom: ds-spacing($ds-s-075);
      }
    }
  }
