/* ---------------------------------
-----  dimension variables --------
---------------------------------- */
/* ------  standard elements padding & margin  ------- */
/* spacing */
/**
**  Official Font sizes
------------------------------- */
/**
** Line-heights
------------------------------- */
/*
  Mixin to progressively-enhance :focus-visible, keeping :focus where not supported
  Add an arbitrary list of selectors into the arguments, and the styling in the block.
  I you pass no selectors to the mixin the parent ("ampersand") operator is used instead.

  There are two mixins:
  - focus-visible: a generic focus-visible, giving you "slots" to decide what to render for :focus, :focus reset, and :focus-visible
  - focus-visible-outline: a focus-visible, which only resets the outline. If you don't need more custom resets, use this one!

  Use focus-visible:
  The key thing here is checking which slot is being rendered.
  For example, you can reset box-shadow here, or anything else.

  @include focus-visible using ($slot) {
      @if $slot == focus {
          outline: 2px solid transparent;
          box-shadow: 0 0 0 4px blue;
      }
      @if $slot == focusReset {
          box-shadow: none;
      }
      @if $slot == focusVisible {
          box-shadow: 0 0 0 4px blue;
      }
  }

  Use focus-visible-outline:
  @include focus-visible-outline("button", "a[href]") {
      outline: 2px solid blue;
  }

  Resulting CSS (compressed):

  button:focus,
  a[href]:focus {
      outline: 2px solid blue;
  }

  button:focus:not(:focus-visible),
  a[href]:focus:not(:focus-visible) {
      outline: none;
  }
  button:focus-visible,
  a[href]:focus-visible {
      outline: 2px solid blue;
  }
*/
/**
@prop --ux-switch-control-width: Width of the switch button
@prop --ux-switch-control-height: Height of the switch button
@prop --ux-switch-outline-offset: Outline offset of the handle
@prop --ux-switch-outline-width: Outline width of the handle
@prop --ux-switch-handle-bg-color: Color of the handle
@prop --ux-switch-handle-size: Size of the handle
@prop --ux-switch-handle-offset: Inner offset of the handle
@prop --ux-switch-handle-track-length: Length of the handle track
@prop --ux-switch-handle-bg-color: Color of the handle
@prop --ux-switch-handle-border-color: Border color of the handle
@prop --ux-switch-handle-shadow: Shadow of the handle
@prop --ux-switch-desc-font-size: Font size of the description text
@prop --ux-switch-bg-color: Background color of the switch button
@prop --ux-switch-border-color: Border color of the switch button
@prop --ux-switch-on-bg-color: Background color of the switch button if toggled on
@prop --ux-switch-on-border-color: Border color of the switch button if toggled on
@prop --ux-switch-hover-bg-color: Background color of the switch button if hovered
@prop --ux-switch-hover-border-color: Border color of the switch button if hovered
@prop --ux-switch-focus-bg-color: Background color of the switch button if focused
@prop --ux-switch-focus-border-color: Border color of the switch button if focused
@prop --ux-switch-active-bg-color: Background color of the switch button if focused
@prop --ux-switch-active-border-color: Border color of the switch button if active
@prop --ux-switch-active-handle-bg-color: Color of the handle if active
@prop --ux-switch-disabled-bg-color: Background color of the switch button if disabled
@prop --ux-switch-disabled-border-color: Border color of the switch button if disabled
 */
:host {
  display: block;
}

:host([checked]:not([checked=false])) button {
  background-color: var(--ux-switch-on-bg-color);
  border-color: var(--ux-switch-on-border-color);
}
:host([checked]:not([checked=false])) #handle {
  transform: translateX(var(--ux-switch-handle-track-length));
}

:host([labelPlacement=end]) label {
  flex-direction: row-reverse;
}
:host([labelPlacement=end]) label > span {
  padding: 0 0 0 1em;
}

:host([disabled]:not([disabled=false])) button {
  background-color: var(--ux-switch-disabled-bg-color);
  border-color: var(--ux-switch-disabled-border-color);
  cursor: not-allowed;
}
:host([disabled]:not([disabled=false])) #handle {
  background-color: var(--ux-switch-handle-bg-color);
  box-shadow: none;
}

#handle {
  background-color: var(--ux-switch-handle-bg-color);
  border: var(--ux-switch-border-width) solid var(--ux-switch-handle-border-color);
  border-radius: var(--ux-switch-handle-size);
  box-shadow: var(--ux-switch-handle-shadow);
  box-sizing: border-box;
  display: block;
  height: var(--ux-switch-handle-size);
  left: var(--ux-switch-handle-offset);
  outline: var(--ux-switch-outline-width) solid transparent;
  outline-offset: var(--ux-switch-outline-offset);
  position: absolute;
  top: var(--ux-switch-handle-offset);
  transition: transform 250ms ease;
  width: var(--ux-switch-handle-size);
}

label {
  align-items: center;
  display: flex;
  flex-flow: row nowrap;
  justify-content: stretch;
}
label > span {
  flex: 1 1 auto;
  font-family: var(--ux-font);
  font-size: var(--ux-input-label-font-size, var(--ux-label-font-size));
  font-weight: var(--ux-input-label-font-weight, var(--ux-label-font-weight));
  line-height: var(--ux-input-label-line-height, var(--ux-label-line-height));
  margin: 0;
  padding: 0 1em 0 0;
  text-transform: var(--ux-input-label-text-tranform, var(--ux-label-text-tranform));
}

button {
  background-color: var(--ux-switch-bg-color, transparent);
  border: var(--ux-switch-border-width) solid var(--ux-switch-border-color);
  border-radius: var(--ux-switch-control-height);
  cursor: pointer;
  display: inline-block;
  flex: 0 0 auto;
  height: var(--ux-switch-control-height);
  margin: 0;
  outline: var(--ux-switch-outline-width) solid transparent;
  outline-offset: var(--ux-switch-outline-offset);
  padding: 0;
  position: relative;
  transition: background-color 250ms ease;
  user-select: none;
  width: var(--ux-switch-control-width);
}
button:disabled {
  background-color: var(--ux-switch-disabled-bg-color);
  border-color: var(--ux-switch-disabled-border-color);
}
button:focus-visible {
  background-color: var(--ux-switch-focus-bg-color);
}
button:focus-visible #handle {
  outline-color: var(--ux-switch-focus-border-color);
  outline-offset: var(--ux-switch-outline-offset);
}
button:hover {
  background-color: var(--ux-switch-hover-bg-color);
  border-color: var(--ux-switch-hover-border-color);
}
button:hover #handle {
  border-color: var(--ux-switch-hover-border-color);
}
button:not(:disabled):active {
  background-color: var(--ux-switch-active-bg-color);
  border-color: var(--ux-switch-active-border-color);
}
button:not(:disabled):active #handle {
  background-color: var(--ux-switch-active-handle-bg-color);
  border-color: var(--ux-switch-active-border-color);
}
button:disabled {
  background-color: var(--ux-switch-disabled-bg-color);
  border-color: var(--ux-switch-disabled-border-color);
}

#description {
  font-size: var(--ux-switch-desc-font-size);
  margin-top: 10px;
}