Seven radio-button swatches set a --brand custom property via :has() — no JavaScript. The preview card reads it straight into contrast-color(var(--brand)), which picks black or white text for you, and the label below always stays readable.
.card {
--brand: ;
background: var(--brand);
color: contrast-color(var(--brand));
}