Gradient theory of phase-transitions in composite media