  Magnetic flux emergence into the outer layers of the Sun is a fundamental
mechanism for releasing energy into the chromosphere and the corona. In this
paper, we study the emergence of granular-sized flux concentrations and the
structuring of the corresponding physical parameters and atmospheric
diagnostics in the upper photo- sphere and in the chromosphere. We make use of
a realistic 3D MHD simulation of the outer layers of the Sun to study the
formation of the Ca II 8542 line. We also derive semi-empirical 3D models from
non-LTE inversions of our observations. These models contain depth-dependent
information of the temperature and line-of-sight stratification. Our analysis
explains the peculiar Ca II 8542 profiles observed in the flux-emerging region.
In addition, we derive detailed temperature and velocity maps describing the
ascent of magnetic bubbles from the photosphere to the chromosphere. The
inversions suggest that, in active regions, granular-sized bubbles emerge up to
the lower chromosphere where the existing large-scale field hinders their
ascent. We report hints of heating when the field reaches the chromosphere.
