Zenith Angle of Moon Terminator?

Hello, newbie here!

My basic question is simply this: what is the formula/calculation required to derive the angle of the Moon's terminator with respect to the *horizon*? Obviously, it will point to the Sun in some way -- but I want to know its orientation in az/alt terms -- not with respect to the celestial pole.

I have done a lot of hair-pulling in the last few days trying to find the clear and correct answer to this question.

My interpretation of the code in the 1990 edition of 'Astronomy With Your Personal Computer' is to calculate the slope of the az/alt of the Moon taken slightly before/after the time of interest -- but I am beginning to doubt that this is correct, since it does not account for the fact that the moon is exactly aligned with the ecliptic (where the Sun is located).

I recently explored treating the Moon/Sun az/alt as 'long/lat', in hopes that a 'great circle bearing' between the two would be better, but the math gets messed up in some situations (below the horizon?).

My question is similar to -- but not the same -- as was asked here: