Grammar of なにを思ったのか


I would like to know the grammar behind なにを思ったのか in the sentence

> そしてダクネスの頭に、 **何を思ったのか** 石を投げつけそのままタルの中に身を隠した。
>
> Then she pitched a stone at Darkness's head and ducked down into the barrel.

The translated sentence does not seem to take into account 何を思ったのか.

Does the 何を思ったのか石 mean "a stone or something I thought was a stone" ?




It is

> そしてダクネスの頭に、( **彼女は** )何を思ったのか、石を投げつけそのままタルの中に身を隠した.

The part is translated as "What did she think?", "I wonder what she thought".
That is "the speaker couldn't understand the reason why she pitched a stone at
Darkness's head and ducked down into the barrel."




It is

> そしてダクネスの頭に、( **彼女は** )何を思ったのか、石を投げつけそのままタルの中に身を隠した.

The part is translated as "What did she think?", "I wonder what she thought".
That is "the speaker couldn't understand the reason why she pitched a stone at
Darkness's head and ducked down into the barrel."

