/* L'interrupteur de la ruche : carré (pas de formes rondes), le rail creusé des barres incrustées, le curseur doré une
   fois allumé, le liseré crème. Un seul pour tout le site (avant : Paramètres, la page joueur et l'élevage avaient
   chacun le leur, celui de l'élevage arrondi).
     <label class="switch">
       <input type="checkbox">
       <span class="switch__track" aria-hidden="true"></span>
       Son nom (ou <span class="sr-only">…</span> s'il est dit à côté)
     </label>
   .switch--small : dans une ligne serrée (un tableau, une carte).
   .switch-host : quand c'est la carte entière qui se clique (la carte d'option des outils, `.rd-switch`) : son état
   allume le rail, une case cochée dedans ou la classe `is-on` (un bouton). */

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--parchment);
  cursor: pointer;
}
.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}
.switch__track {
  position: relative;
  flex: none;
  width: 46px;
  height: 24px;
  border: 1px solid rgba(221, 162, 62, 0.35);
  background: var(--well);
  box-shadow: var(--well-shadow);
  transition:
    background-color 0.2s,
    border-color 0.2s;
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: var(--text-soft);
  transition:
    transform 0.2s,
    background-color 0.2s;
}
.switch input:checked + .switch__track,
.switch-host.is-on .switch__track,
.switch-host:has(input:checked) .switch__track {
  border-color: var(--cream);
  background: #3a2f22;
}
.switch input:checked + .switch__track::after,
.switch-host.is-on .switch__track::after,
.switch-host:has(input:checked) .switch__track::after {
  background: var(--gold);
  transform: translateX(22px);
}
.switch input:focus-visible + .switch__track {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.switch:has(input:disabled) {
  cursor: not-allowed;
}
.switch input:disabled + .switch__track {
  opacity: 0.45;
}

.switch--small {
  gap: 8px;
  font-size: 0.85rem;
}
.switch--small .switch__track {
  width: 34px;
  height: 18px;
}
.switch--small .switch__track::after {
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
}
.switch--small input:checked + .switch__track::after {
  transform: translateX(16px);
}
@media (prefers-reduced-motion: reduce) {
  .switch__track,
  .switch__track::after {
    transition: none;
  }
}
