Discuss the theoretical foundations of soil mechanics and their application in geotechnical engineering, particularly in slope stability analysis, foundation design, and earthworks construction, and explore how advances in soil testing and characterization contribute to improved geotechnical design practices.