Cosmological gravitational particle production of dark matter during inflation and beyond