/* Custom CSS only: no Bootstrap dependency. BEM-ish naming. */

.alfa-choice-wrap {
    --ac-gap: 8px;
    --ac-radius: 6px;
    --ac-fg: #1f2937;
    --ac-fg-muted: #6b7280;
    --ac-bg: #ffffff;
    --ac-border: #d1d5db;
    --ac-active-bg: #2563eb;
    --ac-active-fg: #ffffff;
    --ac-active-border: #2563eb;
    --ac-focus-ring: rgba(37, 99, 235, 0.35);
    display: block;
}

.alfa-choice {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ac-gap);
    font-family: inherit;
}

.alfa-choice--vertical   { flex-direction: column; align-items: flex-start; }
.alfa-choice--horizontal { flex-direction: row; }
.alfa-choice--grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

/* Visually hide the input, used by button + chip variants.
   Kept focusable for keyboard accessibility. */
.alfa-choice--button .alfa-choice__input{
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    clip: rect(0 0 0 0);
    overflow: hidden;
    white-space: nowrap;
}

/* radio / checkbox: keep native input visible */
.alfa-choice--radio .alfa-choice__label,
.alfa-choice--checkbox .alfa-choice__label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--ac-fg);
    font: inherit;
    user-select: none;
}

.alfa-choice--radio .alfa-choice__input,
.alfa-choice--checkbox .alfa-choice__input {
    margin: 0;
    accent-color: var(--ac-active-bg);
}

/* button variant */
.alfa-choice--button .alfa-choice__label {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    padding: 8px 16px;
    border: 1px solid var(--ac-border);
    border-radius: var(--ac-radius);
    background: var(--ac-bg);
    color: var(--ac-fg);
    font: inherit;
    user-select: none;
    transition: background .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.alfa-choice--button .alfa-choice__label:hover {
    border-color: var(--ac-active-border);
    color: var(--ac-active-bg);
}

.alfa-choice--button .alfa-choice__input:checked + .alfa-choice__label {
    background: var(--ac-active-bg);
    color: var(--ac-active-fg);
    border-color: var(--ac-active-border);
}

.alfa-choice--button .alfa-choice__input:focus-visible + .alfa-choice__label {
    box-shadow: 0 0 0 3px var(--ac-focus-ring);
}

/* native select */
.alfa-choice__select {
    padding: 8px 32px 8px 10px;
    border: 1px solid var(--ac-border);
    border-radius: var(--ac-radius);
    background: var(--ac-bg);
    color: var(--ac-fg);
    font: inherit;
    min-width: 200px;
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--ac-fg-muted) 50%),
        linear-gradient(135deg, var(--ac-fg-muted) 50%, transparent 50%);
    background-position:
        calc(100% - 18px) 50%,
        calc(100% - 13px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

.alfa-choice__select[multiple] {
    background-image: none;
    padding-right: 10px;
    min-height: 120px;
}

.alfa-choice__select:focus-visible {
    outline: none;
    border-color: var(--ac-active-border);
    box-shadow: 0 0 0 3px var(--ac-focus-ring);
}

/* hint text under the field (min/max counter) */
.alfa-choice__hint {
    display: block;
    margin-top: 6px;
    font-size: 0.8125rem;
    color: var(--ac-fg-muted);
}

.alfa-choice__hint--error {
    color: #dc2626;
}

/* frontend display */
.alfa-choice__display {
    color: var(--ac-fg);
}

/* the group's name for assistive technology; the caption beside the group shows it */
.alfa-choice__legend {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
