@use "../../styles/variables";
@use "../../styles/utils";
@use "./variables" as locals;

@mixin modifier($variant, $scheme) {
  .Block--#{$variant}.Block--#{$scheme} {
    background: var(--cmm-color-#{$scheme}-#{$variant}-bg);
    color: var(--cmm-color-#{$scheme}-#{$variant}-font);
    border-color: var(--cmm-color-#{$scheme}-#{$variant}-border);
  }
}

@include utils.layer {
  %sizeDefaults {
    padding: 0 0.5rem;
    height: 1.5rem;
    font-size: var(--cmm-font-size-sm);
  }

  .Block {
    @extend %sizeDefaults;

    white-space: nowrap;
    border-radius: var(--cmm-radius-full);
    column-gap: 0.5rem;
    font-weight: var(--cmm-font-weight-semibold);
    display: inline-flex;
    align-items: center;

    > svg {
      @include utils.size(locals.$iconSize);
      margin: locals.$iconMargin;
    }
  }

  // Modifiers
  @each $variant in variables.$variants {
    @each $scheme in variables.$colorSchemes {
      @include modifier($variant, $scheme);
    }
  }

  .Block--outline {
    border-width: 1px;
    border-style: solid;
  }

  // Sizes

  .--sm {
    padding: 0 0.5rem;
    height: 1.25rem;
    font-size: var(--cmm-font-size-xs);
  }

  .--md {
    @extend %sizeDefaults;
  }

  .--lg {
    padding: 0 0.75rem;
    height: 1.75rem;
    font-size: var(--cmm-font-size-md);
  }
}
