Bosnia & Herzegovina is made up of 3 main ethnicities, Croats, Bosniaks and Serbs, with a very small number of people not part of any those. They elect 3 presidents for each of the 3 ethnicities, and my understanding is that there are a certain amount of seats reserved in the parliament per ethnicity.

I read the related articles on Wikipedia countless times, but I still cannot figure out how this functions. Who can vote for which president or parliamentarians? Does everyone vote for Croat, Bosniak and Serb representatives? Or can people only vote for people of "their" ethnicity?

If it is the latter, how does the voting function for people not within one of those ethnicities, for example as Jews or foreigners having acquired Bosnian citizenship?