

.switch {
  position: relative;
  margin: 1em;
}

.switch [type="checkbox"],
.switch [type="radio"] {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  cursor: pointer;
  height: 34px;
  margin: 0;
  padding: 0;
  vertical-align: middle;
  width: 54px;
  opacity: 0;
  font-size: 1em;
}

.switch-placeholder {
  background: #ddd;
  border-radius: 30px;
  border: 1px solid rgba(0,0,0,0.2);
  box-shadow: inset 0 2px 2px rgba(0,0,0,.07);
  display: inline-block;
  height: 30px;
  left: 0;
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  top: 0;
  transition: all ease-in-out 0.1s;
  vertical-align: middle;
  width: 50px;
}

.switch-placeholder:before {
  background: #fff;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0);
  box-shadow: -45px 0 0 34px #005F91;
  content: "";
  display: block;
  height: calc(34px - 4px);
  left: 0;
  margin-left: 0;
  position: absolute;
  top: 0;
  transition: margin-left ease-in-out 0.1s;
  width: calc(34px - 4px);
}

/* :HOVER CONTROL */
.switch [type="checkbox"]:hover ~ .switch-placeholder:before,
.switch [type="radio"]:hover ~ .switch-placeholder:before {
  border-color: rgba(0,0,0,0.2);
}

/* :FOCUS CONTROL */
.switch [type="checkbox"]:focus,
.switch [type="radio"]:focus {
  outline: 0;
}

.switch [type="checkbox"]:focus ~ .switch-placeholder,
.switch [type="radio"]:focus ~ .switch-placeholder {
  border-color: #66afe9;
  box-shadow: inset 0 2px 2px rgba(0,0,0,.07), 0 0 8px rgba(102,175,233,.6);
  outline: 0;
}

/* :CHECKED CONTROL */
.switch [type="checkbox"]:checked ~ .switch-placeholder:before,
.switch [type="radio"]:checked ~ .switch-placeholder:before {
  margin-left: 20px;
}

/* :INDETERMINATE CONTROL */
.switch [type="checkbox"]:indeterminate ~ .switch-placeholder:before,
.switch [type="radio"]:indeterminate ~ .switch-placeholder:before {
  margin-left: 10px;
}
