@use "../../base/space" as sp;
@use "../../base/mixins/meta-class" as mc;

@each $key, $value in sp.$spacers {
  // `--prc-gap-x` is published next to every column gap this file sets, so the
  // `.prc-cl-N` column system in procode-lowcode-core (>= 2.3.0) can subtract
  // the row's gap from each column's flex-basis. Without it a column is a flat
  // percentage of the row and the gap is added on top, so a full row overflows
  // and shrinks while a partial row does not — and the two rows stop lining up
  // the moment a gap is set. See ContainerRenderer/styles/index.scss for the
  // derivation. Anything that is not a column row ignores the property.
  //
  // A unitless 0 has to become `0px` first: the columns' `calc()` subtracts
  // this from a percentage, and a percentage minus a plain number is invalid,
  // which would drop the declaration and leave the column with no basis.
  $gap-x: $value;
  @if $value == 0 {
    $gap-x: 0px;
  }

  @include mc.meta("qo-gap-#{$key}", (gap: $value, "--prc-gap-x": $gap-x));
  @include mc.meta(
    "qo-gap-x-#{$key}",
    (column-gap: $value, "--prc-gap-x": $gap-x)
  );
  @include mc.meta("qo-gap-y-#{$key}", (row-gap: $value));
}
