Sex and Gender Diversity as a Framework for Social and Ecological Adaptation