When/Why did Nagi move out of her mansion and into the apartments in the anime? In the first episode of the 4th season (Hayate no Gotoku! Cuties), Nagi is shown living in the apartment building with all of her friends.


(You can't really tell this is the apartments from the screenshot, but note the rather plain looking Japanese-style room compared to her Western-style room in her mansion which definitely had a fancy bed rather than a futon)

When did she move out of her mansion and into the apartments in the anime? I don't remember this happening.

And is there a reason she moved?

Update: In the following episodes, she is shown back in her mansion sometimes as well. This would imply that the current anime season is not fully following the manga which is why I have not accepted the answers giving manga-based answers.
All of the events leading to Nagi moving out to the Violet Mansion (the apartment building) happens during the Golden Week arc, which is not (yet?) animated.

In chapter 220, on the trip during the Golden Week, Aika delivers a mail from Mikado to Hayate:


   Mikado sets a new condition of inheritance, which is to defeat Hayate and either retrieve or destroy the King's Jewel that he is currently carrying. This King's Jewel was given to Hayate by Mikado in chapter 14, during his first visit to the main mansion.


In chapter 244 to 248


   Hayate and Athena meets again. Athena is possessed by King Midas, and King Midas wants the King's Jewel that Hayate carries to re-enter the Garden Palace and obtain god's power. To save Athena, they must break the "agreement" between Athena and King Midas which allows King Midas to possess her, and the only (safe) way to do it is to destroy Hayate's King's Jewel.


On the last day on the trip to Mykonos during Golden Week. In chapter 252:


   Hayate was troubled over whether to destroy the King's Jewel he has to save Athena, or to keep it to protect Nagi's inheritance. Nagi, seeing Hayate troubled face, decided to break the King's Jewel herself, henceforth loses her rights to the inheritance. She decides to abandon the money that has protected her so far and entrust herself to Hayate to protect her.


In chapter 268 to 270 (after Golden Week arc)


   They are now back from the trip to Mykonos. Having lost the rights to the Sanzen'in family's inheritance, Nagi has to move out of the mansion in a week. After a series of events, Klaus shows Hayate the apartment building called Violet Mansion, which was given to him by Nagi's mother due to a misunderstanding. Klaus decides it is time to return it to Nagi. Nagi later moves into the apartment building starting from chapter 277.