Technically, the Pope must be a bishop (because the Pope’s most important title is “(Arch)bishop of Rome”. In order to be consecrated a bishop, one must be first a priest, and prior to that a deacon. The requirements for being ordained a deacon and then a priest (as only priests can be consecrated as bishops), are that the person be a validly baptized and confirmed Catholic man for the ordination to be valid.
Now, IIRC, in Western Catholicism, it is considered valid, though illicit (except in certain cases - primarily with Anglican and certain other clergy converting to Catholicism) for married men to be ordained to the presbyterate and episcopacy; and in the East, it’s considered valid, but illicit, for married men to be ordained to the episcopacy. Plus, all ordinations to the episcopacy must be done with the expressed permission from the Pope.
This is in theory, of course, as the College of Cardinals in practice selects one of their own for the papacy, and it has been centuries since there have been any Cardinals who have not been bishops. It is technically possible for the Pope to nominate a priest, deacon, or layman to the College of Cardinals, but this has not been done for centuries.