Quantum violation of macroscopic realism and the transition to classical physics