If you want to limit marriage to religion, fine, then the state should get out of the marriage business altogether.
However, when the state elects to engage in the marriage business, there's a little something in the Constitution called "equal protection", which is why the California Supreme Court ruled the way it did.
Unfortunately, a simple majority of people in California believed that discrimination should be written into our state Constitution. Sad. I am ashamed of my state today.