Color-contrast()

is a function that takes a color value and compares it to a list of other color values, selecting the one with the highest contrast from the list.