/* Shared by the Astro, React and Vanilla Checkbox and Radio variants. */

.exo-choice {
  box-sizing: border-box;
  display: flex;
  align-items: flex-start;
  gap: var(--exo-space-3, 8px);
  font-family: var(--exo-font-family-sans, system-ui, sans-serif);
  line-height: var(--exo-font-line-height-snug, 1.25);
  color: var(--exo-color-text, #333333);
  cursor: pointer;
}

/* Sizes */
.exo-choice--md {
  font-size: var(--exo-font-size-sm, 14px);
}

.exo-choice--sm {
  font-size: var(--exo-font-size-xs, 12px);
}

/* The native input, tinted with the accent. Its top lines up with the first line of the label. */
.exo-choice__input {
  flex: 0 0 auto;
  width: 1.15em;
  height: 1.15em;
  margin: calc((1.25em - 1.15em) / 2) 0 0;
  accent-color: var(--exo-color-accent, #2f5fdb);
  cursor: inherit;
}

/* So the focus and error outlines follow the circle. */
.exo-choice--radio .exo-choice__input {
  border-radius: 50%;
}

.exo-choice__text {
  display: flex;
  flex-direction: column;
  gap: var(--exo-space-0-5, 2px);
  min-width: 0;
}

.exo-choice__description {
  font-size: var(--exo-font-size-xs, 12px);
  color: var(--exo-color-text-muted, #666666);
}

/* Card: a bordered box that highlights when checked. */
.exo-choice--card {
  padding: var(--exo-space-3, 8px) var(--exo-space-4, 12px);
  background: var(--exo-color-bg, #ffffff);
  border: var(--exo-border-width-1, 1px) solid var(--exo-color-border-strong, #cccccc);
  border-radius: var(--exo-radius-3, 6px);
}

.exo-choice--card.exo-choice--sm {
  padding: var(--exo-space-2, 6px) var(--exo-space-3, 8px);
}

.exo-choice--card .exo-choice__label {
  font-weight: var(--exo-font-weight-medium, 500);
}

.exo-choice--card:hover:not(:has(.exo-choice__input:disabled)) {
  background: var(--exo-color-bg-hover, rgb(0 0 0 / 0.1));
}

.exo-choice--card:has(.exo-choice__input:checked) {
  border-color: var(--exo-color-accent, #2f5fdb);
  box-shadow: inset 0 0 0 var(--exo-border-width-1, 1px) var(--exo-color-accent, #2f5fdb);
}

/* States */
.exo-choice__input[aria-invalid="true"] {
  outline: var(--exo-border-width-1, 1px) solid var(--exo-color-danger, #b3261e);
  outline-offset: var(--exo-border-width-1, 1px);
}

.exo-choice--card:has(.exo-choice__input[aria-invalid="true"]) {
  border-color: var(--exo-color-danger, #b3261e);
}

.exo-choice--card .exo-choice__input[aria-invalid="true"] {
  outline: none;
}

.exo-choice__input:focus-visible {
  outline: var(--exo-border-width-2, 2px) solid var(--exo-color-accent, #2f5fdb);
  outline-offset: var(--exo-border-width-2, 2px);
}

/* A card shows focus around the whole card instead. */
.exo-choice--card .exo-choice__input:focus-visible {
  outline: none;
}

.exo-choice--card:has(.exo-choice__input:focus-visible) {
  outline: var(--exo-border-width-2, 2px) solid var(--exo-color-accent, #2f5fdb);
  outline-offset: var(--exo-border-width-2, 2px);
}

.exo-choice:has(.exo-choice__input:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}
