[verb (plain)] + とは [i-adj] + とは [na-adj] + (だ) + とは [noun] + (だ) + とは [noun] + とは + [definition]
とは after a plain-form clause means "to think that…": the speaker had not expected this at all. A noun or な-adjective takes it with or without だ. The reaction often follows – おもわなかった思わなかった, しらなかった知らなかった, おどろいた驚いた – or the sentence stops at とは.
This とは is written and dramatic: narration, essays, a character on stage. In conversation the same surprise is なんて, which attaches in the same place.
After a noun, とは introduces what the word means: "X is…", "what is X?". The sentence often ends in のことだ, といういみ意味だ or ものだ. This use is not about surprise at all, and it is common in textbooks and dictionaries.