Sample a color mask and overlay another texture scaled to the mask size

Hello, I am looking to fix up my current shader in Amplify Shader Editor. I have color masked various colors, and am looking to get another texture overlay. I can get my texture to overlay the entire mask, and it works perfectly. However, I want to sample just the mask location, and then scale the secondary texture to fit over it. My textures are fitting in a 512 512 square, the whole texture is 4096. Or 256 if I reduce to 2048.
The texture to overlay is 1024. I need to scale this and position it to multiply with the mask.

Any idea how I might go about this?