Welcome to the site !!
Sorry for the late reply ........

, and hopefully you are still around ....
It could be a Stator or CDI/ECM issue , or even a Coil ... it sounds like when cold it runs fine but as the system heats up it starts having issues , which to me sounds like a electrical breakdown , I would also check ALL grounds and make sure the wires are tight and all connectors are tight and not corroded (pull each connector apart and look for corrosion) ....now part of it could also be old gas that had sat in the carb and plugged some stuff , like jets , and inner passages maybe as well , and when bouncing around on a trail , the orifice will block then unblock possibly , so I would at least clean the carb bowl while you are working on it just to eliminate the carb from the issue .... but what you need to do is check the output of the Stator , Coil , and check continuity on the CDI while cold , then check it again when it does this , before it has a chance to sit for a long time and cool off , as it may work again , as you mentioned that when it sits , it seems to go back to normal again , at least for a while ..... So if at a connection on the CDI you get voltage cold on a certain wire , but not when it has the issue , then the CDI is bad , as there really is not any tests for them , so all you can really do is test it when you know it works , and when it is not working and note any differences , but the coil and Stator you can test and get output voltages and resistance numbers ....