A teeny-weeny time-waster

This one’s fun.  I used to know a similar card trick, but this is much more sophisticated, and I can’t quite figure out how it works.