The unintended and inevitable consequence of trying to legislate something as massive as this away is it promotes what I call wankerism. Where by the more law abiding individuals are put at a further disadvantage as they try to follow onerous laws, whilst the people who are happy to skirt and bend them will do so and get ahead. After all there is almost never going to be a smoking gun and to the extent than you can tighten the rules against laying off pregnant women, then it moves on to hiring discrimination against women of a certain age range and effecting even more people, where its practically impossible to prove discrimination.
Maybe the government and increased maternity pay is part of the solution, but no formula is going to capture the career costs and simultaneously be fair to the lower paid. Maybe it is the responsibility of the parents to make it right between them, in as much as that is practical and in as much as they believe in operating like that.