/**
 * Choice-control primitives (r-39 step f3): checkbox, radio, toggle switch.
 *
 * Native inputs first (§13 "Native first"), so keyboard, focus and form
 * behaviour come from the browser:
 *   .check    a visible checkbox (e.g. the All Updates "To review" filter)
 *   .radio    a visible radio button
 *   .toggle   an on/off switch: a wrapper around a visually hidden
 *             .toggle-input plus .toggle-track and .toggle-thumb. Use it
 *             for a setting or a view filter that applies immediately.
 * A checkbox or radio inside a picker panel is the panel's own hidden
 * .picker-input (picker.css), not one of these.
 *
 * Width, flex and margins stay with the organism; this file only owns how
 * a control looks.
 *
 * @see docs/architecture/ui-design-system.md §13 "Fields"
 * @see docs/architecture/module-map/controls.css.md
 */

/* ── Checkbox / radio ─────────────────────────────────────────────────── */
.check,
.radio {
  width: 1rem;
  height: 1rem;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--color-accent);
  cursor: pointer;
}

.check:focus-visible,
.radio:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: 2px;
}

.check:disabled,
.radio:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Toggle switch ────────────────────────────────────────────────────── */
.toggle {
  display: inline-block;
  position: relative;
  width: 2.6rem;
  height: 1.35rem;
  flex-shrink: 0;
}

.toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Themed in every theme (v0.109.0, tokens.css "Toggle switches"). */
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--color-control-track);
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-control-track-border);
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s;
}

.toggle-input:checked + .toggle-track {
  background: var(--color-control-track-on);
  border-color: var(--color-control-track-on);
}

/* The input itself is invisible, so the keyboard focus ring goes on the track. */
.toggle-input:focus-visible + .toggle-track {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: 2px;
}

.toggle-input:disabled + .toggle-track,
.toggle-input[data-permission-locked] + .toggle-track {
  cursor: not-allowed;
}

/* Centred with top:50% + translateY(-50%): a fixed top offset doesn't divide
   evenly into the track's inner height once its border counts, and the thumb
   sat closer to the top edge (found live by Peter). */
.toggle-thumb {
  position: absolute;
  top: 50%;
  left: 2px;
  width: 0.95rem;
  height: 0.95rem;
  background: var(--color-control-knob);
  border-radius: var(--radius-pill);
  transform: translateY(-50%);
  transition: transform 0.25s ease, background 0.25s;
  pointer-events: none;
}

.toggle-input:checked ~ .toggle-thumb {
  background: var(--color-control-knob-on);
  transform: translateY(-50%) translateX(1.25rem);
}
