  The Mg II resonance doublet at 2796 {\AA} and 2803 {\AA} is an increasingly
important tool to study cold, $T \sim 10^{4}\,$K, gas -- an observational
driven development requiring theoretical support. We develop a new Monte Carlo
radiative transfer code to systematically study the joined Mg II and Ly$\alpha$
escape through homogeneous and `clumpy' multiphase gas with dust in arbitrary
3D geometries. Our main findings are: (i) The Mg II spectrum differs from
Ly$\alpha$ due to the large difference in column densities, even though the
atomic physics of the two lines are similar. (ii) the Mg II escape fraction is
generally higher than that of Ly$\alpha$ because of lower dust optical depths
and path lengths -- but large variations due to differences in dust models and
the clumpiness of the cold medium exist. (iii) Clumpy media possess a `critical
covering factor' above which Mg II radiative transfer matches a homogeneous
medium. The critical covering factors for Mg II and Ly$\alpha$ differ, allowing
constraints on the cold gas structure. (iv) The Mg II doublet ratio $R_{\rm
MgII}$ varies for strong outflows/inflows ($\gtrsim 700 \mathrm{km\,s}^{-1}$),
in particular, $R_{\rm MgII}<1$ being an unambiguous tracer for powerful
galactic winds. (v) Scattering of stellar continuum photons can decrease
$R_{\rm MgII}$ from two to one, allowing constraints on the scattering medium.
Notably, we introduce a novel probe of the cold gas column density -- the halo
doublet ratio -- which we show to be a powerful indicator of ionizing photon
escape. We discuss our results in the context of interpreting and modeling
observations as well as their implications for other resonant doublets.
