Magnetic phase transitions and structural distortion in Nd2CuO4