Scotland is heading into a population crisis that could ramp up pressure on already-strained public services.