The cognitive basis for encoding and navigating linguistic structure