Text ---- Against solid backgrounds this works fairly well: hsl( from --colour h s calc(sign(l - 51) * -100)) ) But doesn't work for some lighter and mid-tone colours like lime, cyan, and yellow. Lab colour space might work better in these circumstances. lab( from var(--row-colour) calc(sign(l - 70) * -100) 0 0 / 1) Lightness Inversion: hsl h s calc(100 - l) Darken: hsl h s calc(l / 2) Lighten: hsl h s calc(l + (100 - l) / 2)