Euclid and Jesus: How and why the church changed mathematics and Christianity across two religious wars