Lagrangian phase transitions in nonequilibrium thermodynamic systems