Brake fluid is Hygroscopic (it absorbs water from the atmosphere) this is the reason it should be replaced regularly.
When the fluid gets hot, because of the moisture absorbed the boiling point is significantly lower, you get some vapour in the fluid and this compresses ,result, no brakes
the lever goes to the stops.When it cools its all fluid again and won't compress the brake pedal returns.
Just basic science a vapour can be compressed a liquid cannot.