Welcome to the site !!
A bit more details would be helpful
Where you were riding , was it someplace you normally ride without issues ?? , was it a dramatic change in elevation and temperature ?? , you said when it sat and you started it , it started fine .... did you ride it ?? , and was it also fine then ??
Also when you had the issue , did you try the Hot Start ?? , and it still would not start ?? , how were you able to get it started when it stalled ?? and if so how and how long did it take ??
It could be several things , anything from stator , carb issues , a gas cap vent clogged , even valves , even the ECU/ECM , sometimes when they are going bad , they give signs like once they get hot then they shut down , and once they cool , then they work again .....
Have you checked any of the wiring connections to make sure nothing is partially connected and hitting a bump or something makes it sputter or bog ??
There are lots of variables , so the more detail , the better . and if you have a manual and a multi meter , you can test all the electrical system to eliminate or confirm each part
But you need to rule out each thing , try checking the float level , make sure it is not sticking and maybe running the bowl out of gas by sticking the needle/seat closed , then freeing itself ..... make sure the electrical checks out .... eliminate the valves as the culprit ...
If it is starting and running now , do a test ride to see if it happens again ..