First off, your definition of "total solar eclipse" is different from that generally used. A total solar eclipse occurs when the moon is directly in front of the sun and is bigger so it blocks the whole of the photosphere. Also note that the sun and moon are both somewhat oblate (not perfect spheres, but flattened) and not exactly the same shape, but for the sake of estimation I'll use the diameter information from wikipedia.
The moon has an average diameter of 3,474 km, and the sun has an average diameter of 1.392684 million km. So the Sun is 400.9 times larger than the moon. When the sun is 149600000 km distant, then if the moon is $149600000/400.9 = 373200$km, the sun and the moon would appear equal in size.
When the moon is 384000km from the centre of the Earth, the distance to the Earth's surface is smallest at the sub-lunar point, about 378000km, but still greater than 373200, so when the Sun and Moon are both at their average distance, an annular eclipse occurs. Annular eclipses are slightly more common than total eclipses.
However if the distance from an observer to the moon is closer than 1/400.9 of the distance to the sun, then a total eclipse is possible, and this allows you to generate infinitely many solutions to the question "How far is the moon during a total solar eclipse"