/*
Copyright 2023, 2024 New Vector Ltd.

SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/

.toggle {
  padding: 2px;
  border: 1px solid var(--cpd-color-border-interactive-secondary);
  border-radius: var(--cpd-radius-pill-effect);
  background: var(--cpd-color-bg-canvas-default);
  display: flex;
  position: relative;
}

.toggle input {
  appearance: none;
  /* Safari puts a margin on these, which is not removed via appearance: none */
  margin: 0;
  block-size: var(--cpd-space-11x);
  inline-size: var(--cpd-space-11x);
  cursor: pointer;
  border-radius: var(--cpd-radius-pill-effect);
  background: var(--cpd-color-bg-action-secondary-rest);
  box-shadow: var(--small-drop-shadow);
  transition: background-color 0.1s;
}

.toggle svg {
  display: block;
  position: absolute;
  padding: calc(2.5 * var(--cpd-space-1x));
  pointer-events: none;
  color: var(--cpd-color-icon-primary);
  transition: color 0.1s;
}

.toggle svg:nth-child(2) {
  inset-inline-start: 2px;
}

.toggle svg:nth-child(4) {
  inset-inline-end: 2px;
}

@media (hover: hover) {
  .toggle input:hover {
    background: var(--cpd-color-bg-action-secondary-hovered);
    box-shadow: none;
  }
}

.toggle input:active {
  background: var(--cpd-color-bg-action-secondary-pressed);
  box-shadow: none;
}

.toggle input:checked {
  background: var(--cpd-color-bg-action-primary-rest);
}

.toggle input:checked + svg {
  color: var(--cpd-color-icon-on-solid-primary);
}

@media (hover: hover) {
  .toggle input:checked:hover {
    background: var(--cpd-color-bg-action-primary-hovered);
  }
}

.toggle input:checked:active {
  background: var(--cpd-color-bg-action-primary-pressed);
}

.toggle input:first-child {
  margin-inline-end: 5px;
}
