Hamiltonian magnetohydrodynamics: Lagrangian, Eulerian, and dynamically accessible stability: Theory