What happens if a Pope is unable to continue his duties due to physical or mental illness?
That will depend on the circumstances in which a particular pope finds himself.
Being bedridden would not be considered a problem in itself, since a pope could theoretically make decisions from his bed. This naturally would presume that the Sovereign Pontiff had the proper medical and council support of doctors and cardinals.
Pope Clement VII was almost completely blind for the better part of his final years when he was pope from 1478-1534. A pope can still be at the helm of the Church as long as he has his intellectual abilities and they are not overly comprised.
But what really happens when the Papal Throne is impeded through some unforeseen event.
Canon 335: When the Roman See is vacant or entirely impeded, nothing is to be altered in the governance of the universal Church; the special laws issued for these circumstances, however, are to be observed.
It is obvious that the Church has some sort of protocols set in place, in the event the pope is impeded somehow of fulfilling his duties, even if these protocols are not shared publicly, they are nevertheless in place. My guess is that the Church hopes that such situations will not happen! The Church takes nothing for granted.