Text this: A Variational Approach to Electrostatics of Polarizable Heterogeneous Substances