All of the above.
The card has to know to work quickly (payment terminals for example) and offline, the bank has to know for ATMs and if a card has locked itself due to too many incorrect PIN attempts.
When the two get out of sync, huge trouble occurs. This is why ATMs should be used to change PINs, they can update both places at the same time.