$base-class: '.sui-AtomCheckbox';
$class-icon: '#{$base-class}--Icon';

#{$base-class} {
  display: inline-block;
  vertical-align: middle;
  box-sizing: border-box;
  color: $c-atom-checkbox;

  &#{$base-class}--native-disabled {
    #{$class-icon} {
      align-items: center;
      border-radius: 0.15em;
      border-style: solid;
      border-width: 1.5px;
      cursor: $cur-atom-checkbox;
      display: inline-flex;
      height: 100%;
      justify-content: center;
      outline-offset: 2px;
      padding: 0;
      text-align: center;
      vertical-align: top;
      width: 100%;

      &:focus {
        outline: none;
      }

      &:focus-visible {
        outline: 2px solid transparentize($c-primary, 0.2);
      }

      span {
        /* Center custom icons */
        align-items: center;
        display: flex;
        justify-content: center;
      }
    }

    input[type='checkbox'] {
      display: none;
    }
  }

  @each $size-name, $size-values in $sz-icon {
    $width: map-get($size-values, width);
    $height: map-get($size-values, height);

    &#{$base-class}--size-#{$size-name} {
      width: $width;
      height: $height;
      &#{$base-class}--native-enabled {
        input[type='checkbox'] {
          width: $width;
          height: $height;
        }
      }
    }
  }

  // semantic status
  &#{$base-class}--native-disabled #{$class-icon},
  &#{$base-class}--native-enabled input[type='checkbox'] {
    border-color: $bdc-atom-checkbox;
    background-color: $c-atom-checkbox;

    &::before {
      box-shadow: inset 1em 1em $c-primary;
    }

    &.is-checked,
    &.is-indeterminate,
    &:checked,
    &:indeterminate {
      border-color: $bdc-atom-checkbox--checked;
      color: $c-atom-checkbox--checked;
      background-color: $bgc-atom-checkbox--checked;
      &::before {
        box-shadow: inset 1em 1em $c-atom-checkbox;
      }
    }

    &:disabled {
      background-color: $bgc-checked-atom-checkbox-is-disabled;
      border-color: $bdc-atom-checkbox-is-disabled;
      color: $c-atom-checkbox-is-disabled;
      cursor: $cur-atom-checkbox--disabled;
      &::before {
        background-color: $bdc-atom-checkbox-is-disabled;
        box-shadow: none;
      }
    }

    @each $status, $color in $status-atom-checkbox {
      &[data-status='#{$status}']:not(:disabled) {
        border-color: $color;
        color: $color;
        background-color: $c-atom-checkbox;

        &::before {
          box-shadow: inset 1em 1em $c-atom-checkbox;
        }

        &.is-checked,
        &.is-indeterminate,
        &:checked,
        &:indeterminate {
          color: $c-atom-checkbox;
          border-color: $color;
          background-color: $color;
          &::before {
            box-shadow: inset 1em 1em $c-atom-checkbox;
          }
        }
      }
    }
  }

  &#{$base-class}--native-enabled {
    input[type='checkbox'] {
      appearance: none;
      background-color: $c-atom-checkbox;
      margin: 0;
      font: inherit;
      border-width: 1.5px;
      border-style: solid;
      border-radius: 0.15em;
      display: flex;

      &::before {
        margin: 10%;
        content: '';
        width: 80%;
        height: 80%;
        transform: scale(0);
        transition: 120ms transform ease-in-out;
        transform-origin: bottom left;
      }

      &:checked {
        &::before {
          transform: scale(1);
          clip-path: polygon(10% 40%, 0% 55%, 50% 90%, 100% 10%, 85% 0%, 46% 65%);
        }
      }

      &:indeterminate {
        &::before {
          transform: scale(1);
          clip-path: polygon(0% 44%, 100% 44%, 100% 56%, 0% 56%);
        }
      }

      &:focus {
        outline: none;
      }

      &:focus-visible {
        outline: 2px solid transparentize($c-primary, 0.2);
      }
    }
  }
}
