/* Layer: ds.components.global (@canonical/styles README, "Cascade layers"). */

@layer ds.components.global {
  /* Generated by @canonical/summon-component:react v0.1.0 */

  /* The atomic radio control: a circular native input with the design-system
   * selection chrome. Carries no label — the host supplies it. */
  .ds.form-radio {
    appearance: none;
    box-sizing: border-box;
    margin-inline: var(--form-input-padding-inline);
    /* 16px control — a fixed element size, not a baseline multiple (the 4px-baseline
       spike halved the old `--space-baseline × 2`). Stable --dimension-200 (16px). */
    width: var(--dimension-200);
    height: var(--dimension-200);
    border: var(--dimension-stroke-thickness-medium) solid var(--color-border);
    border-radius: 50%;
    background-color: var(
      --surface-color-foreground-radio-unselected,
      var(--color-foreground-radio-unselected)
    );
    cursor: pointer;
    transition:
      background-color var(--motion-duration-fast) ease,
      border-color var(--motion-duration-fast) ease;

    &:checked {
      /* Dot = selected token, ring fill = unselected token; both surface-provided
       * (flat fallback) so the control adapts to OnSurface stepping. */
      border-color: var(
        --surface-color-foreground-radio-selected,
        var(--color-foreground-radio-selected)
      );
      background: radial-gradient(
        var(
            --surface-color-foreground-radio-selected,
            var(--color-foreground-radio-selected)
          )
          40%,
        var(
            --surface-color-foreground-radio-unselected,
            var(--color-foreground-radio-unselected)
          )
          41%
      );
    }

    &:hover:not(:disabled):not(:checked) {
      background-color: var(--color-foreground-radio-unselected-hover);
    }

    /* Hover on a selected radio shifts only the dot's fill, not via a whole-element
     * brightness filter (which would also dim the ring). Re-paint the gradient with
     * the hovered selected shade from the `--hover--…-selected` channel. */
    &:checked:hover:not(:disabled) {
      border-color: var(--hover--color-foreground-radio-selected);
      background: radial-gradient(
        var(--hover--color-foreground-radio-selected) 40%,
        var(
            --surface-color-foreground-radio-unselected,
            var(--color-foreground-radio-unselected)
          )
          41%
      );
    }

    &:focus-visible {
      outline: none;
      border-color: var(--color-focus-ring);
      box-shadow: 0 0 0 1px var(--color-focus-ring);
    }

    &:disabled {
      border-color: var(--color-border-disabled);
      background-color: var(--color-foreground-radio-unselected-disabled);
      cursor: not-allowed;
    }
  }
}
