/* -------------------------------- 

File#: _1_switch
Title: Switch
Descr: Custom ON/OFF checkbox toggle
Usage: codyhouse.co/license

-------------------------------- */
/* reset */
*, *::after, *::before {
  box-sizing: border-box;
}

* {
  font: inherit;
  margin: 0;
  padding: 0;
  border: 0;
}

body {
  background-color: hsl(0, 0%, 100%);
  font-family: system-ui, sans-serif;
  color: hsl(230, 7%, 23%);
  font-size: 1rem;
}

h1, h2, h3, h4 {
  line-height: 1.2;
  color: hsl(230, 13%, 9%);
  font-weight: 700;
}

h1 {
  font-size: 2.0736rem;
}

h2 {
  font-size: 1.728rem;
}

h3 {
  font-size: 1.25rem;
}

h4 {
  font-size: 1.2rem;
}

ol, ul, menu {
  list-style: none;
}

button, input, textarea, select {
  background-color: transparent;
  border-radius: 0;
  color: inherit;
  line-height: inherit;
  appearance: none;
}

textarea {
  resize: vertical;
  overflow: auto;
  vertical-align: top;
}

a {
  color: hsl(250, 84%, 54%);
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

img, video, svg {
  display: block;
  max-width: 100%;
}

@media (min-width: 64rem) {
  body {
    font-size: 1.25rem;
  }

  h1 {
    font-size: 3.051rem;
  }

    h2 {
    font-size: 2.44rem;
  }

    h3 {
    font-size: 1.75rem;
  }

    h4 {
    font-size: 1.5625rem;
  }
}

/* variables */
:root {
  /* colors */
  --sk7-color-primary-hsl: 250, 84%, 54%;
  --sk7-color-bg-hsl: 0, 0%, 100%;
  --sk7-color-contrast-high-hsl: 230, 7%, 23%;
  --sk7-color-contrast-higher-hsl: 230, 13%, 9%;
  --sk7-color-bg-darker-hsl: 240, 4%, 90%;
  --sk7-color-white-hsl: 0, 0%, 100%;
}

/* component */
:root {
  /* style */
  --switch-width: 64px;
  --switch-height: 32px;
  --switch-padding: 3px;
  /* animation */
  --switch-animation-duration: 0.2s;
}

.switch {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  width: var(--switch-width);
  height: var(--switch-height);
  border-radius: 50em;
  padding: var(--switch-padding) 0;
}

.switch__input, .switch__label {
  position: absolute;
  left: 0;
  top: 0;
}

.switch__input {
  margin: 0;
  padding: 0;
  opacity: 0;
  height: 0;
  width: 0;
  pointer-events: none;
}
.switch__input:checked + .switch__label {
  background-color: hsl(var(--sk7-color-primary-hsl));
}
.switch__input:checked + .switch__label + .switch__marker {
  left: calc(100% - var(--switch-height) + var(--switch-padding));
}
.switch__input:focus + .switch__label, .switch__input:active + .switch__label {
  box-shadow: 0 0 0 2px hsla(var(--sk7-color-contrast-higher-hsl), 0.2);
}
.switch__input:checked:focus + .switch__label, .switch__input:checked:active + .switch__label {
  box-shadow: 0 0 0 2px hsla(var(--sk7-color-primary-hsl), 0.2);
}

.switch__label {
  width: 100%;
  height: 100%;
  color: transparent;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  background-color: hsl(var(--sk7-color-bg-darker-hsl));
  border-radius: inherit;
  z-index: 1;
  transition: var(--switch-animation-duration);
  overflow: hidden;
}

.switch__marker {
  position: relative;
  background-color: hsl(var(--sk7-color-white-hsl));
  width: calc(var(--switch-height) - var(--switch-padding) * 2);
  height: calc(var(--switch-height) - var(--switch-padding) * 2);
  border-radius: 50%;
  z-index: 2;
  pointer-events: none;
  box-shadow: 0 0.1px 0.3px rgba(0, 0, 0, 0.06),0 1px 2px rgba(0, 0, 0, 0.12);
  left: var(--switch-padding);
  transition: left var(--switch-animation-duration);
  will-change: left;
}