
$checkbox: (
  (1,1,1,1,1,1,1,1,0,0),
  (1,0,0,0,0,0,0,1,0,0),
  (1,0,0,0,0,0,0,1,0,0),
  (1,0,0,0,0,0,0,1,0,0),
  (1,0,0,0,0,0,0,1,0,0),
  (1,0,0,0,0,0,0,1,0,0),
  (1,0,0,0,0,0,0,1,0,0),
  (1,1,1,1,1,1,1,1,0,0),
);

$checkbox-checked: (
  (1,1,1,1,1,1,1,0,1,1),
  (1,0,0,0,0,0,0,1,1,1),
  (1,0,0,0,0,0,1,1,0,0),
  (1,1,0,0,0,1,1,0,0,0),
  (1,1,1,0,1,1,0,1,0,0),
  (1,0,1,1,1,0,0,1,0,0),
  (1,0,0,1,0,0,0,1,0,0),
  (1,1,1,1,1,1,1,1,0,0)
);

$checkbox-focus: (
  (2,2,2,2,2,2,2,2,0,0),
  (2,0,0,0,0,0,0,2,0,0),
  (2,0,0,0,0,0,0,2,0,0),
  (2,0,0,0,0,0,0,2,0,0),
  (2,0,0,0,0,0,0,2,0,0),
  (2,0,0,0,0,0,0,2,0,0),
  (2,0,0,0,0,0,0,2,0,0),
  (2,2,2,2,2,2,2,2,0,0),
);

$checkbox-checked-focus: (
  (2,2,2,2,2,2,2,0,1,1),
  (2,0,0,0,0,0,0,1,1,1),
  (1,0,0,0,0,0,1,1,0,0),
  (1,1,0,0,0,1,1,0,0,0),
  (2,1,1,0,1,1,0,2,0,0),
  (2,0,1,1,1,0,0,2,0,0),
  (2,0,0,1,0,0,0,2,0,0),
  (2,2,2,2,2,2,2,2,0,0)
);

.nes-ui-checkbox {
  
  $colors: ($base-color, map-get($default-colors, 'shadow'));

  user-select: none;
  margin-left: 28px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;

  @include visually-hidden();

  & + span {
    position: relative;
    user-select: none;
    padding-top: 3px;
    cursor: var(--cursor-click-url), pointer;
  }

  & + span::before,
  &:checked + span::before {
    position: absolute;
    top: -3px;
    left: -28px;
    content: '';
  }

  & + span::before { 
    @include pixelize(2px, $checkbox, $colors);
  }

  &:focus + span::before { 
    @include pixelize(2px, $checkbox-focus, $colors);
  }

  &:checked + span::before {
    @include pixelize(2px, $checkbox-checked, $colors);
  }

  &:checked:focus + span::before {
    @include pixelize(2px, $checkbox-checked-focus, $colors);
  }
}

.nes-ui-dark-mode {
  .nes-ui-checkbox {
    
    $colors-checkbox-dark: ($color-white, map-get($default-colors, 'shadow'));
    
    + span {
      color: $color-white;
    }

    + span::before {
      color: $color-white;
    }

    &:checked + span::before {
      @include pixelize(2px, $checkbox-checked, $colors-checkbox-dark);

      color: $color-white;
    }
    &:checked:focus + span::before {
      @include pixelize(2px, $checkbox-checked-focus, $colors-checkbox-dark);

      color: $color-white;
    }
  }
}


label.nes-ui-is-checkbox {
  margin-bottom: 5px;
  margin-right: 10px;
}

.nes-ui-checkbox {
  &.nes-ui-is-disabled {
    $color: map-get($disabled-colors, 'normal');
    $colors-radio-disabled: ($color, map-get($disabled-colors, 'shadow'));

    + span {
      color: $color;
      cursor: not-allowed;
    }

    + span::before {
      color: $color;
      cursor: not-allowed;
    }

    &:checked + span::before {
      @include pixelize(2px, $checkbox-checked-focus, $colors-radio-disabled);

      color: $color;
    }

    &:checked:focus + span::before {
      @include pixelize(2px, $checkbox-checked-focus, $colors-radio-disabled);

      color: $color;
    }
  }
}