.nu-checkbox {
  width: 20px;
  height: 20px;
  border: none;
  outline: none;
  cursor: pointer;
  user-select: none;
  position: relative;
  border-radius: 4px;
  box-sizing: border-box;
  -webkit-appearance: none;
  box-shadow: var(--box-shadow);
  background-color: var(--bg-color);
  transition: all 200ms ease-in-out;
}

.nu-checkbox.nu-checkbox--light {
  --bg-color: var(--light-bg);
  --selector-bg: var(--text-color);
  --text-color: var(--g-text-color-light);
  --text-disabled: var(--g-text-color-disabled-light);
  --box-shadow: 2px 2px 4px var(--light-bg-dark-shadow),
    -2px -2px 4px var(--light-bg-light-shadow);
  --box-shadow-inset: inset -2px -2px 3px var(--light-bg-light-shadow),
    inset 2px 2px 3px var(--light-bg-dark-shadow);
}

.nu-checkbox.nu-checkbox--dark {
  --bg-color: var(--dark-bg);
  --selector-bg: var(--text-color);
  --text-color: var(--g-text-color-dark);
  --text-disabled: var(--g-text-color-disabled-dark);
  --box-shadow: 2px 2px 4px var(--dark-bg-dark-shadow),
    -2px -2px 4px var(--dark-bg-light-shadow);
  --box-shadow-inset: inset -2px -2px 3px var(--dark-bg-light-shadow),
    inset 2px 2px 3px var(--dark-bg-dark-shadow);
}

.nu-checkbox:before,
.nu-checkbox:after {
  content: "";
  top: 9px;
  left: 4.5px;
  position: absolute;
  pointer-events: none;
  transform-origin: 0% 100%;
}

.nu-checkbox:before {
  z-index: 2;
  width: 20px;
  height: 20px;
  transform: rotate(45deg);
  border-right: 2px solid transparent;
  border-bottom: 2px solid transparent;
}

.nu-checkbox:after {
  width: 3px;
  height: 8px;
  border-right: 2px solid var(--text-color);
  border-bottom: 2px solid var(--text-color);
  transform: translate3d(0, -8px, 0) rotate(45deg);
}

.nu-checkbox:checked {
  box-shadow: var(--box-shadow-inset);
}

.nu-checkbox:hover:before,
.nu-checkbox:checked:not(:hover):before {
  animation: checkbox-check 200ms cubic-bezier(.4, .0, .23, 1) forwards;
}

.nu-checkbox:not(:hover):before {
  animation: checkbox-uncheck 150ms cubic-bezier(.4, .0, .23, 1) forwards;
}

.nu-checkbox.nu-checkbox--disabled,
.nu-checkbox-label.nu-checkbox-label--disabled {
  pointer-events: none !important;
  --selector-bg: var(--text-disabled) !important;
  --text-color: var(--text-disabled) !important;
}

.nu-checkbox.nu-checkbox--disabled:checked:before,
.nu-checkbox.nu-checkbox--disabled:checked:after {
  left: 4.5px !important;
  border-right: 2px solid transparent;
  border-bottom: 2px solid transparent;
}

.nu-checkbox-label {
  font-size: 16px;
  margin-top: -2px;
  user-select: none;
  padding-left: 8px;
  color: var(--text-color);
}


@keyframes checkbox-check {
  0% {
    width: 0;
    height: 0;
    border-color: var(--selector-bg);
    transform: translate3d(0, 0, 0) rotate(45deg);
  }

  70% {
    width: 3px;
    height: 0;
    transform: translate3d(0, 0, 0) rotate(45deg);
  }

  100% {
    width: 3px;
    height: 8px;
    border-color: var(--selector-bg);
    transform: translate3d(0, -8px, 0) rotate(45deg);
  }
}

@keyframes checkbox-uncheck {
  0% {
    width: 3px;
    height: 8px;
    border-color: var(--selector-bg);
    transform: translate3d(0, -8px, 0) rotate(45deg);
  }

  60% {
    width: 3px;
    height: 0;
    transform: translate3d(0, 0, 0) rotate(45deg);
  }

  90% {
    width: 0;
    height: 0;
    border-color: var(--selector-bg);
    transform: translate3d(0px, 0, 0) rotate(45deg);
  }

  100% {
    border-color: transparent;
    transform: translate3d(0px, 0, 0) rotate(45deg);
  }
}
