Statistical Mechanics of Quantum Error-Correcting Codes