Thermodynamics of scalar-tensor gravity