Can transaction inputs reference outputs of pending transactions?
If transaction Y is in block B, then it is - for purposes of deciding whether X's inputs are valid - confirmed.

As far as consensus rules are concerned, a transaction X can spend outputs from a transaction Y that is anywhere in the block chain before X. That means either Y is in an earlier block as X, or in the same block but in an earlier position.

The P2P transaction relay also supports this. It will relay transactions that spend outputs of unconfirmed transactions under some conditions. Given two interdependent unconfirmed transactions, miners can decide to put both of them in the same block, or only include the first one in a block (leaving the other one in the memory pool for inclusion in a later block).