If someone smokes close to you and you inhale the smoke involuntarily, does that break your fast? Also, does ruling change between fard fasting and extra (nafilah) fasting?
To answer the first question, if done on purpose, then yes. If not intensional, then no.
Depends on your intention according to the following extract from a fatwa:
One's fast is not invalidated by what is too hard to protect oneself from swallowing. This includes the dust of the street, the dust of the flour, and the like. Although smoking a cigarette breaks the fast of the smoker himself, it does not break the fast of a passive smoker (the person next to him who breathes in some of the smoke). Also, it does not break the fast of one who breathes in the odor of incense or other fragrances, however if one deliberately breathes in the particles which come out of a spray bottle (whether perfume or the like), while remembering that one is fasting, then one's fast is terminated.
Full fatwa can be seen here.
Only if it's intentional.
Firstly, in order for one's fast to become invalid, one has to inhale the smoke intentionally and deliberately. If the smoke of a perfume entered through one's nose or throat unintentionally, then one's fast will not break. (Maraqi al-Falah, P: 660) (Source)
There are studies that show passive smoking is extremely harmful. Taking smoke in directly or indirectly or thru a sheesh all are harmful for the inhaler.
"...make not your own hands contribute to your destruction..." (Qur'an 2:195)
If we know ALL these smoke(passive,active etc) will destroy our lung and still continue to inhale these smoke then we are going against the above verse of the quran. Hence I would deem these smoke as haraam.
I would also include any undesirable smoke like pollution from vehicles in this category.
To explain better I would use the analogy of someone ridiculing Allah's Message...
"Already has He sent you Word in the Book, that when ye hear the signs of Allah held in defiance and ridicule, ye are not to sit with them unless they turn to a different theme: if ye did, ye would be like them. For Allah will collect the hypocrites and those who defy faith - all in Hell.." (Quran 4:140)
In the above verse Allah says that if someone is ridiculing Allah's message, you must go away until they change the subject. This should happen the moment you know that they start to do it.
So if someone is doing something haraam and you must go away if you do not have the ability to stop it.
Now to answer your question about fasts.. If something is haraam on normal days, it is haraam when you fast too (with the exception of food, drink and sex, which is not haraam otherwise)
So if you walk away from the smoker your fast MAY remain intact just like your emaan remains intact, otherwise it MAY have been broken because passive smoking itself is haraam. The reason I use MAY is because here I have used an analogy and not a direct quote or hadees.
But Allah knows best...