@use '~@moda/tokens';

@mixin stack($index: 4, $direction: vertical) {
  display: flex;
  justify-content: flex-start;

  @if $direction == vertical {
    flex-direction: column;

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

    > * + * {
      margin-top: tokens.space($index);
    }

    > .Overlay {
      margin-top: 0;
    }
  }

  @if $direction == horizontal {
    flex-direction: row;

    > * {
      margin-left: 0;
      margin-right: 0;
    }

    > * + * {
      margin-left: tokens.space($index);
    }

    > .Overlay {
      margin-left: 0;
    }
  }
}
