The energy functional of a Hitchin representation