Electronic structure and lattice dynamics of CaxMg1−xS in the rock-salt phase