Pion structure in the nuclear medium