Principles of ribbon geometry