I have always understood the definition of "night" ("leilah") when the day is for sure over and we've passed through "bein hashmoshos" completely, is when there are 3 visible stars and "hiksef elyon shaveh l'tachton" -- meaning that the sky is completely dark on both sides (both in the east and the west where the sun has set.)
However a notable talmud chacham told me today that I am mistaken in this and that the definition of night "halachically speaking" is only dependent on when 3 stars are visible and not in what light is left in the sky. Meaning once the 3 stars are easily seen, it's no longer bein hashmoshos and it's now night for all halachic purposes even if both sides of the sky are not completely dark.
He referred me to a Rambam in Hilchos Trumas Perek 7 Halacha 2 that says the following:
אין הטמאים אוכלין בתרומה עד שיעריב שמשן ויצאו שלשה כוכבים אחר שקיעת החמה שנאמר ובא השמש וטהר עד שיטהר הרקיע מן האור ואחר יאכל מן הקדשים
It seems to be then that once the sun has "set" (not mentioning the darkness of the sky) and that 3 stars are visible it would be night in regards to the permissibility for those that were impure to now eat trumah once they have went through the process of purity.
What sources can be provided for this? What halachically speaking is the definition of night for all purposes (Shabbos, Krias Shema, Trumah, Taanisim, etc, etc, etc.)
(I have left out purposely any discussion of whether the stars have to be medium or small size. I've also left out any discussion in regards to time limits in terms of minutes given in the poskim throughout the generations and do not wish to mix those different times in since every part of the world is different. Simply in the terms of what we find in Chazal, Rishonim and Achronim in regards to the "actual" situation, "metzius", etc.)