Edge modes in discrete lattices: phase transitions under the three-gap theorem (Proceedings of the Royal Society. A, Mathematical, physical, and engineering sciences, 2025)