How religion changed the presidency—and vice versa