Hydraulic disk brake stops working when hot; back to normal after cooling - is this expected?
The least you need to do is bleed the brakes to remove trapped air. It's best though if you completelly change the fluids and bleed. You can do that in an LBS, or yourself if you have a bleeding kit and know how to do it.

The reason for the behavior you described is that air is trapped in the system and makes things mushy and unpredictable. The fact that after a couple of lever presses it came back to "normal" is because hydraulic brakes are auto adjusting both on the pads end (when pads are worn) and on the lever end (when air is in the system).

Air bubbles exist in the system either because a proper bleed was not done in the first place or because the fluids absorbed moisture which vapourated and turned into air as soon as you overheated the fluids. Also note that as soon as the fluids absorb moisture (water) then the boiling point falls even more so having this issue is even easier.