My guess is that the subject-auxiliary inversion associated with negative or restrictive expressions is permitted only when the negation semantically applies at the clause level.
“Not a single word did he say” has the same meaning as “He did not say a single word”, with negation at the clause level.
“Only then did I understand what she meant” has the same meaning as “Before then, I did not understand what she meant”, with negation at the clause level.
In contrast, “Not far from here you can see foxes” doesn't mean “You cannot see foxes far from here”. The clause is fundamentally positive in meaning: it describes where you can see foxes (equivalent to "You can see foxes near here"), not where you cannot see foxes, so there is no semantic negation at the clause level.
Likewise, I would not normally understand “Not long after that she got married” as having a negation at the clause level (that is, it doesn't seem to mean "Long after that, she did not get married"). Instead, it is equivalent in meaning to "She got married soon after that", with a fundamentally positive meaning at the clause level.
It might be the case that semantic negation at the clause level is necessary, but not sufficient for this kind of inversion to be permitted.
We see negation at the clause level in sentences like He did not hit the ball very far and She did not stay in the house very long. So if *Not very far did he hit the ball and *Not for very long did she stay in the water are ungrammatical, it's for a different reason. In fact, I think it might be overly general to say that "Inversion is not used" in all sentences containing not far or not long. In archaic style, at least, "Not (very) far did..." might be allowed in sentences like this:
Not very far did I run, although at the moment it seemed a long way, but I was out of the reach of human vision.
("Mining Memories", by David Wingate, in Life and Work: A Parish Magazine, Volume 6, page 123, April 1884)
I'm not sure I would say this is much more old-fashioned than the use of inversion in "Not a single word did he say": I think in contemporary colloquial style, I would prefer not to use inversion for either ("He didn't say a single word", "I didn't run very far") whereas in a more artificial, literary, elevated style, I might accept inversion in both cases.
To me, "Far from here(,) you can see foxes" and "Long after that(,) she got married" sound grammatical, although I'm not certain. ("Far from here" and "long after that" definitely aren't as commonly encountered at the start of a sentence as their negated equivalents.)