Is it a sin to just fantasize about sexual things?
What if these thoughts are accidental and uncontrollable?

It is not consider as sin but it leads to sin. It is not a fire but smoke itself that is harmful. Be in the state of wudhu, read surah and think good things.