/* The light and dark switch (`shared/_mode_switch`): System, Light, Dark.

   A segmented control built on three real radios. The radio is laid over its
   label, invisible but focusable and clickable, so the browser does the
   keyboard (arrows move and select inside the group, Tab leaves it) and the
   screen reader announces group, option and state with no ARIA.

   Tokens only, so it reads in both modes on both surfaces. The outline is
   `--control-line`, 3:1 against the field in both modes (1.4.11). Targets are 44px
   (`--target-min`, declared in 10-globals.css), well over WCAG 2.5.8's 24. The
   checked option differs from the others by a dot and weight as well as by
   fill, so color is never the only signal (1.4.1). */

.mode-switch {
  display: inline-flex;
  margin: 0;
  padding: 0;
  min-inline-size: 0;
  border: 1px solid var(--control-line);
  border-radius: 999px;
  background: var(--surface-inset);
}

.mode-switch-option {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-block-size: var(--target-min);
  padding-inline: 1rem;
  border-radius: 999px;
  color: var(--fg2);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition:
    background-color 120ms ease,
    color 120ms ease;
}

.mode-switch-input {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.mode-switch-option:hover {
  background: var(--accent-soft);
  color: var(--fg1);
}

/* The ring is drawn on the label because the radio under it is invisible. */
.mode-switch-input:focus-visible {
  outline: none;
}
.mode-switch-option:has(.mode-switch-input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.mode-switch-option:has(.mode-switch-input:checked) {
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 700;
}
.mode-switch-option:has(.mode-switch-input:checked)::before {
  content: "";
  inline-size: 0.4rem;
  block-size: 0.4rem;
  border-radius: 50%;
  background: currentColor;
}

/* Forced colors drop our fills; keep the checked option unmistakable with the
   system's own selection colors. */
@media (forced-colors: active) {
  .mode-switch {
    border-color: CanvasText;
  }
  .mode-switch-option:has(.mode-switch-input:checked) {
    forced-color-adjust: none;
    background: Highlight;
    color: HighlightText;
  }
}
