What happens with Arduino digital pin 12 when the power is OFF
Digital CMOS chips, including microcontrollers such as the one on your Arduino, are sensitive to ESD (electrostatic discharge), so as a protection measure, each pin typically has a pair of diodes that clamp its voltage range to the supply rails.

When the chip is powered, these diodes do not conduct unless the voltage on the pin tries to go below ground or above Vcc by more than the forward voltage drop of the diodes. But when the power is removed from the chip, both Vcc and Gnd are effectively at ground potential, and the input voltage is clamped to a range of about &plusmn; 0.65 V.

The simplest way to prevent this from affecting the signal source is to put a resistor in series between the source and the pin, which will limit the amount of current that can flow through the protection diodes when they conduct. Picking the value for this resistor depends somewhat on your application. Typical values would be in the range of 10 k&Omega; to 100 k&Omega;. Larger values allow less current to flow, but they also can interact with the input capacitance of the pin to create a low-pass filter that slows down the signal edges. Smaller values minimize this effect, but increase the loading on the signal source.

If you can't find a value that works acceptably well in your application, you might need to add an active buffer to the signal path &mdash; either a transistor or one of those "single gate" ICs.