Seems like something that could be calculated and baked server side
Your site's design should just have well-chosen colours.
And there's decent reason to not want to tell the server either.
CSS function doing "here is color A, here is color B, make one that is same hue as color B but contrasting" would be much more useful