Micro-environmental fine-tuning of electronic and kinetic properties of photochromic dyes