<script lang="ts">
  import { customElementForwardEvents } from '../../utils';
  /**
   * A radio button is a selection control that allows users to choose a single option from a list of mutually exclusive choices. Unlike checkboxes, only one option can be selected at a time within the same group. Radio Buttons are commonly used in forms, surveys, and settings where a single choice must be made.
   */
  interface Props {
    [key: string]: any;
    /**
     * A unique identifier for the radio, used to associate the label with the form element.
     */
    id: string;
    /**
     * The name attribute for the radio element, typically used for form submission.
     */
    name?: string;
    /**
     * The text label displayed next to the radio.
     */
    label?: string;
    /**
     * The radio's checked state.
     */
    checked?: boolean;
    /**
     * If `true`, applies an invalid state to the radio.
     */
    isinvalid?: boolean;
    /**
     * If `true`, disables the radio, making it non-interactive.
     */
    disabled?: boolean;
  }

  let {
    id,
    name,
    label,
    checked = $bindable(false),
    disabled,
    isinvalid,
    class: className,
    ...attrs
  }: Props = $props();
</script>

<div class="mc-radio">
  <input
    {id}
    type="radio"
    class={['mc-radio__input', isinvalid && 'is-invalid', className]}
    {name}
    {disabled}
    {checked}
    {...attrs}
  />
  <label for={id} class="mc-radio__label">{label}</label>
</div>

<style>/**
 * Do not edit directly, this file was auto-generated.
 */
.mc-radio {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  padding: 0.375rem;
}
.mc-radio__label {
  font-size: var(--font-size-150, 1rem);
  line-height: var(--line-height-s, 1.3);
  color: var(--forms-color-text-default, #000000);
  cursor: pointer;
}
.mc-radio__input {
  appearance: none;
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
  transition: box-shadow 200ms ease;
  background-color: var(--forms-color-background-default, #ffffff);
  border: var(--border-width-m, 0.125rem) solid var(--forms-color-border-default, #666666);
  border-radius: 100%;
  transition: all ease 200ms;
  height: 1.25rem;
  width: 1.25rem;
  position: relative;
}
.mc-radio__input::before {
  border-radius: var(--border-radius-full, 100%);
  content: "";
  display: block;
  height: 0.5rem;
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 0.5rem;
}
.mc-radio__input:hover {
  border-color: var(--forms-color-border-hover, #4d4d4d);
}
.mc-radio__input:focus-visible {
  box-shadow: 0 0 0 0.125rem var(--focus-color-mid, var(--focus-color-outline-mid, #ffffff)), 0 0 0 0.25rem var(--focus-color-outer, var(--focus-color-outline-outer, #000000));
  outline: 0.125rem solid transparent;
  outline-offset: 0.125rem;
}
.mc-radio__input:checked {
  background-color: var(--forms-color-background-checked, #117f03);
}
.mc-radio__input:checked::before {
  background-color: var(--forms-color-background-default, #ffffff);
}
.mc-radio__input:checked, .mc-radio__input:disabled {
  border-color: transparent;
}
.mc-radio__input:disabled {
  background-color: var(--forms-color-background-disabled, #d9d9d9);
  cursor: not-allowed;
}
.mc-radio__input:disabled:checked::before {
  background-color: var(--forms-color-icon-disabled, #737373);
}
.mc-radio__input:disabled + .mc-radio__label {
  color: var(--forms-color-text-disabled, #737373);
  cursor: not-allowed;
}
.mc-radio__input:not(:disabled):checked:hover {
  background-color: var(--forms-color-background-checked-hover, #006902);
}
.mc-radio__input.is-invalid:not(:checked) {
  border-color: var(--forms-color-border-invalid, #ea302d);
}
.mc-radio__input.is-invalid:not(:checked):hover {
  border-color: var(--forms-color-border-invalid-hover, #c61112);
}</style>
