I recently picked up a book of example NPCs (the Pathfinder NPC Codex, incidentally) and came across an entry for a "master spy". In the flavor text, it describes how his "secret identities have secret identities" and how he might pose as another NPC or even a player character temporarily.
This of course got the wheels turning in my head, and I can imagine a scenario where the party (having encountered this master spy in the past and knowing of his skills) kicks down a door to discover one of their own, bound, gagged, and stripped of their belongings. Then the pieces will come together and they'll realize that they've been deceived by the spy, and that he has been in their company for several hours, if not days, acting as their comrade would act and gathering privileged information. If said information lets him get the leg up on the party and beat them in a race to and important something or someone, all the better.
I could obviously work with the player in question to make the deception happen, but I think the reveal would be much more powerful if all the players were deceived, and could work out the details for themselves from the hints and foreshadowed elements, so my question is this: how do I separate a character from the party and replace him with a doppelganger without rousing the suspicions of player in question or the party at large?
One idea I've come up with is to isolate the character and render them unconscious (during which time the imitator makes the switch) in a secondary encounter, then have the rest of the group happen upon the unconscious character a short time later — from that point forward, the player's actions are actually being carried out by the imitator in disguise until the reveal. This feels somewhat heavy-handed, so any more elegant ideas would be appreciated.