put a test light on the crank wire next time it happens. If the light lights when you turn the key and the engine does not crank I would replace the starter/solonoid. It sounds like a faulty solonoid, or as above the gear not retracting. This is not an unusual problem. If the car has headers even more common. I have had a few where the headers were too close to the starter. would start when cold but not when warm. I have a mini on mine.