.row {
  $component-name: ".row";
  $row-spacing: -1;


  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: space-between;

  margin: 0 spacing($row-spacing, $times: -1) spacing($row-spacing, $times: -1) 0; //TODO: remove this when  safari has wide spread suport for gap i flexbox, use gap property instead

  //TODO using $component-name instead of & to support usage in typo3. Can be deleted when typo3 is fully delphinus
  & > #{$component-name}__item {
    @include content-container;
    padding: 0 spacing($row-spacing) spacing($row-spacing) 0; //TODO: remove this when  safari has wide spread suport for gap i flexbox

    @for $i from 2 through 16 {
      &--basis-#{$i * 5} {
        flex-basis: spacing(-1, $add: #{$i * 5rem});
        flex-grow: 1;
        flex-shrink: 1;
      }
    }

    &--basis-default-line-width {
      flex-basis: spacing(-1, $add: $line-width-max);
      flex-grow: 0;
      flex-shrink: 1;
    }

    &--stretch {
      flex-grow: 1;
    }

    &--no-grow {
      flex-grow: 0;
    }

    &--no-shrink {
      flex-shrink: 0;
    }
  }

  //TODO: remove this when  safari has wide spread suport for gap i flexbox
  &.processing-state {
    &::after {
      left: calc(50% - .5em - (#{spacing(-1)} / 2));
    }
  }
  //TODO: remove this when  safari has wide spread suport for gap i flexbox
  &__item.processing-state--init-box {
    border-right: spacing($row-spacing) solid color("background");
    border-bottom: spacing($row-spacing) solid color("background");

    &::after {
      left: calc(50% - .5em - (#{spacing(-1)} / 2));
    }
  }

  &.row--1-2-1 {
    flex: flex;
    > .row__item:first-child, > .row__item:last-child {
      flex: 1 0 25%;
      overflow: hidden; 
    }

    > .row__item:nth-child(2) {
      flex: 1 0 50%;
      overflow: hidden; 
    }
  }

  &.row--1-2 {
    display: flex;
    > .row__item:first-child {
      flex: 1 0 33%;
      overflow: hidden; 
    }
  
    > .row__item:last-child {
      flex: 1 0 66%;
      overflow: hidden;
    }
  }

  &.row--2-1 {
    flex: flex;
    > .row__item:first-child {
      flex: 1 0 66%;
      overflow: hidden; 
    }

    > .row__item:last-child {
      flex: 1 0 33%;
      overflow: hidden; 
    }
  }

  &.row--2 {
    flex: flex;
    > .row__item:first-child {
      flex: 1 0 50%;
      overflow: hidden; 
    }

    > .row__item:last-child {
      flex: 1 0 50%;
      overflow: hidden; 
    }
  }

  &.row--3 {
    flex: flex;
    > .row__item:first-child {
      flex: 1 0 33%;
      overflow: hidden; 
    }
    > .row__item:nth-child(2) {
      flex: 1 0 33%;
      overflow: hidden; 
    }
    > .row__item:nth-child(3) {
      flex: 1 0 33%;
      overflow: hidden; 
    }
  }

  &.row--4 {
    flex: flex;
    > .row__item:first-child {
      flex: 1 0 25%;
      overflow: hidden; 
    }
    > .row__item:nth-child(2) {
      flex: 1 0 25%;
      overflow: hidden; 
    }
    > .row__item:nth-child(3) {
      flex: 1 0 25%;
      overflow: hidden; 
    }
    > .row__item:nth-child(4) {
      flex: 1 0 25%;
      overflow: hidden; 
    }
  }

  @include breakpoint("wide", $mobile-last: true) { 
     &.row--1-2-1, &.row--1-2, &.row--2-1, &.row--3, &.row--4{
      flex-direction: column;
    }
  }

  &--align-left {
    justify-content: flex-start;
  }

  &--align-right {
    justify-content: flex-end;
  }

  &--align-center-horizontal {
    justify-content: center;
  }

  &--align-evenly {
    justify-content: space-around; //for browsers not supporting space-evenly
    justify-content: space-evenly;
  }

  &--align-bottom {
    align-items: flex-end;
  }

  &--align-center-vertical {
    align-items: center;
  }

  &--wrap-reverse {
    flex-wrap: wrap-reverse;

    &.row--align-bottom {
      align-items: flex-start;
    }
  }

  &--no-wrap {
    flex-wrap: nowrap;

    & > * .row__item {
      flex: 1 1 auto;
    }
  }

  &--with-padding {
    margin: 0;
    padding: spacing($row-spacing, $divideby: 2);

    & > .row__item {
      padding: spacing($row-spacing, $divideby: 2);
    }
  }

  &--equal-width-items {
    & > .row__item {
      flex-basis: spacing(-1, $add: 20rem);
      flex-grow: 1;
      flex-shrink: 1;
    }
  }

  &--equal-height-items {
    & > .row__item {
      display: flex;
      flex-direction: column;

      .row__item-content {
        flex: 1 0 auto;
      }
    }
  }

  &--vertical-margin {
    &.row--with-padding {
      margin-top: spacing(0);
      margin-bottom: spacing(0);
    }

    &.row-no-padding-wrapper {
      margin-top: spacing(0);
      border-bottom: spacing(0) solid color("background");

      & + * {
        margin-top: 0;
      }
    }
  }

  &-no-padding-wrapper {
    border-bottom: 1px solid transparent;
    margin-bottom:  -1px;
  }
}
