Cosmological dynamics of scalar–tensor gravity