Gradient-based habitat affinities predict species vulnerability to drought