The structural principles of protein adaptation