.switch {
  display: inline-flex;
  text-align: center;
}

.switch__item {
  flex: 1 1 auto;
  position: relative;
  display: flex;
}

.switch__input {
  opacity: 0;
  position: absolute;
  z-index: 1;
  top: 0;
  left: 0;
  margin: 0;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.switch__label {
  position: relative;
  z-index: 0;
  overflow: hidden;
  flex: 1 1 auto;
  padding: 0.4em 1em;
  border: 1px solid var(--color-text);
  border-radius: 6px;
}

.switch__label::before {
  content: "";
  opacity: 0;
  position: absolute;
  inset: -1px;
  background-color: currentColor;
  transition: opacity 0.2s;
}

.switch__input:checked + .switch__label {
  color: var(--color-background);
  background-color: var(--color-text);
}

.switch__item:first-child .switch__label {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.switch__item:last-child .switch__label {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.switch__item:not(:first-child, :last-child) .switch__label {
  border-radius: 0;
}

.switch__item:not(:first-child) {
  margin-left: -1px;
}

.switch__item:hover .switch__label::before {
  opacity:
    calc(
      var(--is-light-theme-on) * 0.06 +
      var(--is-dark-theme-on) * 0.12
    );
}

.switch:focus-within {
  outline: auto 2px Highlight;
  outline: auto 2px -webkit-focus-ring-color;
  outline-offset: 2px;
  border-radius: 6px;
}
