The spectroscopic evolution of the recurrent nova T Pyxidis during its 2011 outburst. I. The optically thick phase and the origin of moving lines in novae