The spatial architecture of protein function and adaptation