Detecting and analysing wavelength-scale optical gradients at an interface by their effects on the internal reflectance near the critical angle