Text this: StratLearn-z: Improved photo-$z$ estimation from spectroscopic data subject to selection effects