The role of magnesium in stabilising amorphous calcium carbonate and controlling calcite morphologies