The enrichment history of baryons in the Universe