Enrichment of CO2 and magnesium in early stages of biomineralization