Mixing wire sized is certain not prohibited by code, but it is not a workman like installation and can cause issues down the road.
If this is done you MUST size the breaker according tot he smallest wire on the circuit. So, your 20A circuit with #14 to the lights is not complaint and should be fixed. Either replace the breaker with a 15 or replace the #14 with #12.
Hopefully you did not create and even worse violation and tap off a kitchen/DR or bath receptacle circuit for lighting.
The argument that all you are doing is tapping off for a light fixture is NOT valid.
It is extremely rare that you would need to upsize wire in a typical residential installation to counter voltage drop. If you do though it is a good idea to use all the same wire. If you do mix wire sizes IMO it is a good idea, and IMO should be code required, to label the wire in the panel to only be used for the smaller breaker. Someone down the road might see #12 and have no idea that the circuit has #14 on it and replace the 15 with a 20A breaker.
Some people have the misguided idea that they should use all #12 and use some 15 amp breakers so they can someday "upgrade" the circuit to a 20A. They feel there is some safety factor built in by doing this. This is completely untrue, unless of course you have an extremely long circuit and voltage drop is an issue as I mentioned before. There is NO "safety margin" by doing this. All you are doing wasting a potential 5 amps of circuit capacity by under sizing a breaker.