Do not over think this. You pushed too hard in heat that you were not conditioned and acclimatized for, became dehydrated, under-fueled and exposed to harsh climbing conditions. I have been hospitalized for heat exhaustion. It took three bags of Ringers Lactate to get my blood volume up so I could be discharged. I could not keep fluids down and would have died if not for the ER visit.
So my answer is hydrate and add potassium, calcium, magnesium and sodium (lightly salted almonds work for me) to your diet in supplement or food form the day before and morning of your more challenging rides. In addition add a good sports drink like Tri Fuel to one of your water bottles. In conditions like you shared I carry four 25 oz bottles. One with a whey protein mix, one with Cytomax and two with water.
I weigh 210 lbs and aim to drink at least one bottle per hour on average. Sometimes more in high heat and humidity. I also will leave for a ride in the early morning to avoid heat above 85F.