Molecular mechanisms and evolutionary robustness of a color switch in proteorhodopsins