Order of diagenetic events controls evolution of porosity and permeability in carbonates