/**
 * RadioGroup styles
 * @countermeasure/web-components/primitives/radio
 */

/* ==========================================================================
   Radio Group
   ========================================================================== */

.cmm-radio-group {
  display: flex;
}

.cmm-radio-group--horizontal {
  flex-direction: row;
  gap: 1rem;
  flex-wrap: wrap;
}

.cmm-radio-group--vertical {
  flex-direction: column;
  gap: 0.5rem;
}

/* ==========================================================================
   Radio Item
   ========================================================================== */

.cmm-radio {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.cmm-radio--disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Visually hidden native input */

.cmm-radio__input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

/* Custom radio circle */

.cmm-radio__circle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  border: 1.5px solid hsl(var(--border));
  border-radius: 50%;
  background-color: hsl(var(--background));
  transition: border-color var(--transition-fast),
    background-color var(--transition-fast);
}

.cmm-radio__circle::after {
  content: '';
  display: none;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background-color: hsl(var(--primary-foreground));
}

/* Checked state */

.cmm-radio__input:checked + .cmm-radio__circle {
  background-color: hsl(var(--primary));
  border-color: hsl(var(--primary));
}

.cmm-radio__input:checked + .cmm-radio__circle::after {
  display: block;
}

/* Hover state */

.cmm-radio:hover .cmm-radio__circle {
  border-color: hsl(var(--ring));
}

/* Focus state */

.cmm-radio__input:focus-visible + .cmm-radio__circle {
  outline: 2px solid hsl(var(--focus-ring));
  outline-offset: 2px;
}

/* Label text */

.cmm-radio__label {
  font-size: 0.875rem;
  line-height: 1.5;
  color: hsl(var(--foreground));
}
