Establishing common ground between attiny and 24v motor, and between attiny and 12v logic circuit, without connecting 24v motor and 12v logic grounds
If you use an optocoupler instead of a BJT, you can avoid having a common ground between the motor and the other two blocks.  This requires more current than driving the base of a BJT, but it sounds like you're in a line-powered environment there.