This is a case of inversion that appears after certain negative or restrictive expressions and "only".
Paraphrasing Swan:
Rarely had the sunset been more gorgeous.
Seldom could she see such a gorgeous sunset.
Never had she seen a more gorgeous sunset.
Hardly/*Scarcely* had she left the house when she saw the gorgeous sunset.
No sooner did she open the window that she saw the gorgeous sunset.
Only after looking out the window did she notice the gorgeous sunset.
In no way could she imagine how gorgeous the sunset might actually be.
At no time did she see a gorgeous sunset during her stay there.
Under no circumstances would she have said that the sunset was gorgeous.
On no account was she allowed to see the gorgeous sunset.
(*) Note that the last three examples are actually "negative" sentences in that she didn't see the sunset, didn't think the sunset was gorgeous, and wasn't allowed to see the sunset, while the other sentences have a "positive" meaning.