Sedimentary and diagenetic transitions between carbonates and evaporites