The correct option is A had been thinking
In order to discern the correct tense to be used in any sentence, we have to keep in mind two things - one, if the options provided make grammatical sense within the framework of the given sentence; and two whether the secondary action in the sentence has completed or is in the process of unfolding WITHIN the relevant timeframe. In this case, we see that the door had been opened, ruling out the present continuous tense Options B) and D). And Option C) does not grammatically agree with the rest of the sentence as it is present tense. This leaves us with Option A) - the correct answer, and of the past perfect continuous form - which is obtained by adding 'had been' to the base verb + ing. The verb in question is 'to think'; for which the base/ root form is simply 'think'. Applying the above, we clearly get 'had been thinking', which is the correct answer.