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

File#: _1_radio-switch-v2
Title: Radio Switch v2
Descr: A custom radio button with a switch element and two labels
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 */
  --rw7-color-primary-hsl: 213, 48%, 50%;
  --rw7-color-bg-hsl: 0, 0%, 100%;
  --rw7-color-contrast-high-hsl: 230, 7%, 23%;
  --rw7-color-contrast-higher-hsl: 230, 13%, 9%;
  --rw7-color-bg-darker-hsl: 240, 4%, 90%;

  /* spacing */
  --rw7-space-xs: 0.5rem;

  /* typography */
  --rw7-text-sm: 0.833rem;
}

@media(min-width: 64rem){
  :root {
    /* spacing */
    --rw7-space-xs: 0.75rem;

    /* typography */
    --rw7-text-sm: 1rem;
  }
}

/* component */
:root {
  --radio-switch-v2-width: 52px;
  --radio-switch-v2-height: 30px;
  --radio-switch-v2-padding: 4px;
  --radio-switch-v2-radius: 50em;
  --radio-switch-v2-animation-duration: 0.3s;
}

.radio-switch-v2 {
  position: relative;
  display: inline-block;
  display: inline-flex;
  list-style-type: none!important;
  padding-left: 0;
}

.radio-switch-v2__item {
  position: relative;
  height: var(--radio-switch-v2-height);
  float: left;
}

.radio-switch-v2__input {
  position: relative;
  z-index: 2;
  height: 100%;
  width: calc(var(--radio-switch-v2-width)*0.5);
  opacity: 0;
  cursor: pointer;
  -webkit-transform: scaleX(2);
          transform: scaleX(2);
  -webkit-transform-origin: 0 0;
          transform-origin: 0 0;
}
.radio-switch-v2__item:last-of-type .radio-switch-v2__input {
  -webkit-transform-origin: 100% 100%;
          transform-origin: 100% 100%;
}
.radio-switch-v2__item:first-of-type .radio-switch-v2__input {
  order: 1;
}
.radio-switch-v2__input:checked {
  z-index: -1;
}

.radio-switch-v2__label {
  position: relative;
  z-index: 2;
  display: block;
  line-height: var(--radio-switch-v2-height);
  font-size: var(--text-size-100);
  transition: color var(--radio-switch-v2-animation-duration);
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
}
.radio-switch-v2__item:first-of-type .radio-switch-v2__label {
  float: left;
  padding-right: var(--sp-x);
  cursor:pointer;
}
.radio-switch-v2__item:last-of-type .radio-switch-v2__label {
  float: right;
  padding-left: var(--sp-x);
  cursor:pointer;
}
.radio-switch-v2__input:checked ~ .radio-switch-v2__label {
  color: hsl(var(--rw7-color-primary-hsl));
}
.radio-switch-v2__input:focus ~ .radio-switch-v2__label {
  outline: 2px solid hsla(var(--rw7-color-primary-hsl), 0.2);
  outline-offset: 2px;
}
.radio-switch-v2__label :not(*):focus-within, .radio-switch-v2__input:focus ~ .radio-switch-v2__label {
  outline: none;
}

.radio-switch-v2__toggle {
  position: absolute;
  z-index: 1;
  width: var(--radio-switch-v2-width);
  height: var(--radio-switch-v2-height);
  top: 0;
  left: 0;
  -webkit-transform: translateX(-50%);
          transform: translateX(-50%);
  border-radius: var(--radio-switch-v2-radius);
  background-color: hsl(var(--rw7-color-bg-darker-hsl));
}
.radio-switch-v2:focus-within .radio-switch-v2__toggle, .radio-switch-v2:active .radio-switch-v2__toggle {
  box-shadow: 0 0 0 2px hsla(var(--rw7-color-contrast-higher-hsl), 0.15);
}

.radio-switch-v2__marker {
  position: absolute;
  z-index: 1;
  top: var(--radio-switch-v2-padding);
  left: var(--radio-switch-v2-padding);
  width: calc(var(--radio-switch-v2-height) - var(--radio-switch-v2-padding) * 2);
  height: calc(var(--radio-switch-v2-height) - var(--radio-switch-v2-padding) * 2);
  border-radius: 50%;
  background-color: hsl(var(--rw7-color-primary-hsl));
  transition: left var(--radio-switch-v2-animation-duration);
  box-shadow: 0 0.3px 0.4px rgba(0, 0, 0, 0.025),0 0.9px 1.5px rgba(0, 0, 0, 0.05), 0 3.5px 6px rgba(0, 0, 0, 0.1);
  will-change: left;
}

.radio-switch-v2__input:checked ~ .radio-switch-v2__toggle .radio-switch-v2__marker {
  left: calc(var(--radio-switch-v2-width) - var(--radio-switch-v2-height) + var(--radio-switch-v2-padding));
}