/* Every [role=switch] checkbox is drawn here, by attribute, so a hand-written one looks the same. Only --switch-*
   tokens are read: the back office loads this sheet too and has no --tap or --primary of the product's. */
@layer components {
  .switch-field { display: flex; align-items: center; gap: 12px; min-height: var(--switch-tap); cursor: pointer; }
  .switch-field:has(input:disabled) { cursor: default; }
  .switch-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
  .switch-label { font-weight: 600; }
  .switch-hint { font-size: 13px; color: var(--switch-hint); }

  /* The knob and its shadow are radial gradients: Firefox does not paint ::before on an input. */
  input[type="checkbox"][role="switch"] {
    appearance: none; flex: none; box-sizing: border-box; width: 46px; height: 28px; margin: 0; cursor: pointer;
    border: 1px solid var(--switch-off-border); border-radius: 999px; background-color: var(--switch-off);
    background-repeat: no-repeat;
    background-image:
      radial-gradient(circle closest-side, var(--switch-knob) calc(100% - 1px), transparent 100%),
      radial-gradient(circle closest-side, var(--switch-shadow) 55%, transparent 100%);
    background-size: 24px 24px, 28px 28px;
    background-position: 1px 50%, -1px calc(50% + 1px);
    transition: background-position .18s cubic-bezier(.3, .7, .4, 1), background-color .18s ease;
  }
  input[type="checkbox"][role="switch"]:checked {
    border-color: var(--switch-on); background-color: var(--switch-on);
    background-position: calc(100% - 1px) 50%, calc(100% + 1px) calc(50% + 1px);
  }
  input[type="checkbox"][role="switch"]:focus-visible { outline: 2px solid var(--switch-focus); outline-offset: 3px; }
  input[type="checkbox"][role="switch"]:disabled { opacity: .5; cursor: default; }

  @media (prefers-reduced-motion: reduce) {
    input[type="checkbox"][role="switch"] { transition: none; }
  }

  /* High contrast: the system's own checkbox is the readable one. */
  @media (forced-colors: active) {
    input[type="checkbox"][role="switch"] { appearance: auto; width: 24px; height: 24px; background-image: none; }
  }
}
