I am reading Theoretical minimum: Special Relativity and Classical Field Theory where you construct a Lagrangian for the field by the argument that it would be invariant under the Lorentz transformation, so basically any scalar function involving $\phi(x^\mu)$ since $\phi$ transforms as: $$\phi(x) = \phi'(x')$$ But then he argues that the derivatives of the field can also be included in the Lagrangian by making a scalar out of them in the following manner: $$\left(\frac{\partial \phi}{\partial t} \right)^2 - \left(\frac{\partial \phi}{\partial x} \right)^2 - \left(\frac{\partial \phi}{\partial y} \right)^2 - \left(\frac{\partial \phi}{\partial z} \right)^2$$ But I dont understand how covariant components can combine in the above way like the magnitude of a vector to create an invariant quantity since: $$\vec A = A^1 \vec e_1 + A^2 \vec e_2 = A_1 \vec e^1 + A_2 \vec e^2$$ $(A^1)^2 + (A^2)^2$ is an invariant but $(A_1)^2 + (A_2)^2$ is not.
Is there an intuitive way to see how the above squares of the covariant derivatives are invariant under the Lorentz transformation ?
For example if I actively transform $\vec e_x \rightarrow \vec e'_x = 2\vec e_x$ then $\partial_x\phi$ also doubles and the others ($\partial_t\phi$, $\partial_y\phi$, $\partial_z\phi$) remain the same, then how can $(\partial_t\phi)^2 + (\partial_x\phi)^2 + (\partial_y\phi)^2 + (\partial_z\phi)^2$ remain invariant ?