Was logic invented or discovered?
As often, the same word may mean different things, so the answer depends on what we mean by the word "logic". Yet, we can look at what people do to decide.
First, what (most) academics do. The job of academics is, literally, to pursue academic disciplines (not to say their academic career). What academics choose to call "logic" is, as a consequence, either a formal discipline, better called not "logic" but "formal logic", or formal systems developed in the context of formal logic. Such systems are, therefore, literally, theoretic construct of formal logic. Not all theoretic constructs mean something which exists, and I believe that, in these instances, none of them do.
However, what is interesting in what academics do in relation to logic is that they all protest vehemently that they reason logically. Thus, we can at least say that either these people are totally deluded or they have to have, at the very least, a logical capacity. But if they have a logical capacity, this is presumably not because they are all either particularly gifted in reasoning logically (whatever they themselves believe), or trained so as to have an otherwise totally unnatural ability to reason logically. Presumably, academics believe that they have a capacity to reason logically because they have a capacity to reason logically. This is not even controversial, and not even particular to academics. We all have a capacity to reason logically. Since most people are not taught to reason logically, we probably have to conclude that it is a natural capacity.
Just to realise that we can reason logically requires a logical capacity.
If we accept that (nearly) all humans have a natural capacity to reason logically, it must be because logic is, at the very least, itself a natural (cognitive) capacity. Maybe it is something more, but it has to be at least a natural capacity.
How come we have it? The most plausible answer is natural selection. Logic must have appeared as a selective advantage, possibly over hundreds of millions of years of evolution. Neurons have appeared broadly 525 million years ago, and they seem a good candidate as the physical substrate to our logical capacity. So we just inherit our own logical capacity through our DNA, just as Homo Sapiens inherited its logical capacity through the DNA it "received" from its ancestor species.
Thus, logic is essentially a innate cognitive capacity (very nearly) all humans have in common. It would also be very implausible that among all animals with a brain, only humans had this logical capacity. Only humans possess the sort of articulated language that they have. Pigs and cows clearly cannot articulate any reasoning, but since they don't do silly things, certainly not most of the time, they too have to be logical, and so they too have to have a logical capacity.
Thus, logic was discovered.
And then, formal logic was invented, almost in the same breath. It is sometimes said that Aristotle did it, but more reasonably it was the work of a number of philosophers in Ancient Greece, most prominently among them, Aristotle.
can math exist without logic?
Certainly not. Mathematics could not exist without language either, but language itself could not exist without logic. Language involves so-called linguistic rules, and nobody could apply rules sensibly if they didn't have a logical capacity. So, just to be able to speak and understand what other people say, we need to have a logical capacity. Mathematics itself requires the applications of implicit and explicit rules, and so requires a logical capacity. This is why logic could not possibly be a branch of mathematics.
One could even argue that logic is foundational to philosophy itself
Obviously, yes, but this is nothing specific to philosophy. Logic is necessary to every meaningful thought that we have, for the ascription of a meaning to a thought requires a logical capacity.
How could philosophy, or any form of rigorous inquiry, exist without logic?
No, but this is more general than that. No sensible conversation in natural language could take place if those taking part didn't have a logical capacity. Language involves rules, and applying rules requires logic.
Logic seems to function universally, making it appear fundamental to the workings of the universe.
This is putting the cart in front of the horse. Logic is fundamental to every meaningful thought that we have, so we cannot think of anything outside the logical framework imposed by our own nature. Thus, logic appears universal to us, but not because it is, only because by nature we cannot think illogically, or outside the logical box, as it were.
Obviously, because logic is just a consequence of natural selection, it is also the consequence of the laws of nature. As such, it is a part of nature. However, I don't think that a mere chunk of brute matter has a logical capacity in the sense that we do. Logic requires something like perception, re-presentation of perception and computation on re-presentation. If we happen to believe that Kurt and Bertrand like cabbage, we will also inevitably believe that Kurt like cabbage. Our brain has to work like this if we are to survive in our environment. People whose brain doesn't work like this I don't think live very long.
Or is logic purely an abstract construct of the human mind, with no objective existence in reality?
Our idea of logic is an abstraction, but we do have very real logical intuitions, such as for example that Aristotle's syllogisms are logically valid. We can test this on ourselves, by simple introspection.
Formal logic is definitely a theoretic construct. As practiced by academics at the moment, it doesn't correspond to anything real, but this could probably be improved.
And if all minds capable of logical thought were to vanish, would reality still operate in accordance with logical principles?
Again, it all depends on what we use the word "principle" to mean. If we mean "formal principle", then of course reality doesn't need any formal principle to do what it does. If instead we mean by "principle" something fundamental to reality, then reality seems to always work according to fundamental principles, although it is very possible that we be mistaken in the belief that it does.