i have another question regarding calculations with the co- and contravariant formalism in QFT. It is not that i don't understand all of this, but most of the time i'm missing some "middle" steps, i.e. when reading books and trying to recap the stuff.
One example is derivation of the Klein-Gordon-Equation from the Lagrangian for a scalar field: $$\mathcal{L} = \frac{1}{2} \left( \partial_\mu \phi \right) \left( \partial^\mu \phi \right) + \frac{1}{2} m^2 \phi^2$$
with help of the Euler-Lagrange-Formalism: $$\partial_\mu \left( \frac{\partial \mathcal{L}}{\partial \left( \partial_\mu \phi \right)} \right) - \frac{\partial \mathcal{L}}{\partial \phi} = 0.$$
My first question is, why i can write $$(\partial_\mu \phi)(\partial^\mu \phi) = \left( \partial_\mu \phi \right)^2~?$$ I know that co- and contravariants are related via a metric, but what exactly is the step inbetween? Or is it just a convention? If yes, why is $$\frac{\partial}{\partial (\partial_\mu \phi)} \left( \partial_\mu \phi \right)^2 = 2\partial^\mu \phi~?$$ Normally i would have lowered the second index in $(\partial_\mu \phi)(\partial^\mu \phi)$, used the product rule and $\frac{\partial \partial_i \phi}{\partial \partial_\mu \phi} = \delta^\lambda_\mu$ ($i=\mu, \nu$) to get the solution.
Now i have the Lagrangian of the electromagnetic field: $$\mathcal{L} = -\frac{1}{2} (\partial_\mu A_\nu)(\partial^\mu A^\nu) + \frac{1}{2}(\partial_\mu A^\mu)^2.$$ Again i could write $$(\partial_\mu A_\nu)(\partial^\mu A^\nu) = (\partial_\mu A_\nu)^2$$ and calculate the derivation. But how can i do the calculation using the product rule for this part? Is there a way of varying $A_\mu$ (like $\phi$) to get something similar to $$\frac{\partial \partial_i}{\partial \partial_\lambda} = \delta^\lambda_x~?$$
And how can i calculate the derivative of the last part $(\partial_\mu A^\mu)^2$ (Tongs QFT script says that it is $(\partial_\rho A^\rho) \eta^{\mu \nu}$)?