/// Adjusts the spacing for the stack and contained items.
/// @param {String} $spacing - The spacing variant to use.

@mixin stack-spacing($spacing: base) {
  margin-top: -1 * spacing($spacing);
  margin-left: -1 * spacing($spacing);

  > .Polaris-Stack__Item {
    margin-top: spacing($spacing);
    margin-left: spacing($spacing);
    max-width: calc(100% - #{spacing($spacing)});
  }
}

.Polaris-Stack {
  @include stack-spacing;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
}

.Polaris-Stack--noWrap {
  flex-wrap: nowrap;
}

.Polaris-Stack--vertical {
  flex-direction: column;
}

.Polaris-Stack--spacingNone {
  @include stack-spacing(none);
}

.Polaris-Stack--spacingExtraTight {
  @include stack-spacing(extra-tight);
}

.Polaris-Stack--spacingTight {
  @include stack-spacing(tight);
}

.Polaris-Stack--spacingLoose {
  @include stack-spacing(loose);
}

.Polaris-Stack--spacingExtraLoose {
  @include stack-spacing(extra-loose);
}

.Polaris-Stack--distributionLeading {
  justify-content: flex-start;
}

.Polaris-Stack--distributionTrailing {
  justify-content: flex-end;
}

.Polaris-Stack--distributionCenter {
  justify-content: center;
}

.Polaris-Stack--distributionEqualSpacing {
  justify-content: space-between;
}

.Polaris-Stack--distributionFill > .Polaris-Stack__Item {
  flex: 1 1 auto;
}

.Polaris-Stack--distributionFillEvenly > .Polaris-Stack__Item {
  flex: 1 1 auto;

  @supports (min-width: fit-content) {
    flex: 1 0 0%;
    min-width: fit-content;
  }
}

.Polaris-Stack--alignmentLeading {
  align-items: flex-start;
}

.Polaris-Stack--alignmentTrailing {
  align-items: flex-end;
}

.Polaris-Stack--alignmentCenter {
  align-items: center;
}

.Polaris-Stack--alignmentFill {
  align-items: stretch;
}

.Polaris-Stack--alignmentBaseline {
  align-items: baseline;
}

.Polaris-Stack__Item {
  flex: 0 0 auto;
  min-width: 0;
}

.Polaris-Stack__Item--fill {
  flex: 1 1 auto;
}
