Do mirages really occur due to total internal reflection?

Mirages occur in areas such as deserts due to difference in the refractive indices of layers of air. As the light ray travels from denser to rarer layers of air, slowly bending, it approaches the critical angle and after refracting, it goes along with the boundry and the angle becomes 90 degrees. Now this light ray becomes the incident ray and if this ray undergoes total internal reflection, its angle of reflection would be 90degrees which means it would never bend, but in case of mirages, the ray bends in the upward direction. Does this mean that mirages dont occur due to total internal reflection?

$$`$$

An alternative explanation would be "index gradient reflection". Normally, TIR refers to reflection at an interface between a high index material and a low index material. "index gradient reflection" occurs without need for an interface: instead, it requires only a refractive index that changes gradually. The light rays never need to encounter an interface where the index changes abruptly.

A good example is a gradient index rod, in which the refractive index decreases from the axis outwards. In the case of a mirage, usually the air is warmer and less dense, and thus has lower refractive index, near the ground.

Yes, a situation comes, when the ray has bent so much that it's angle of incidence at new layer becomes greater than critical angle. Assuming ray comes from above, it gets refracted by rarer layers below, so its angle of incidence keeps on increasing; it becomes more horizontal. So a point comes when TIR occurs, and ray bounces upwards.

YES, reason for mirage is not Total internal Reflection.

You said correct at lowest most point when the ray bounce upward, angle of incident is 90° so if TIR is the reason angle of reflection is 90°, hence, the ray should continue move in straight line but we know this is not happen.

So lets consider refractive index of surrounding increases gradually upward as μ = μ0 + αy , (say, α is small) and assume origin at point of minima (convergence).

Now, using snell's law , μ sinθ = constant

(μ0 + αy)sinθ = μ0 {at bottom}

sinθ = μ0 / μ0 + αy

now , use dy/dx = tanθ

to find equation of trajectory,

taking α to be small, equation of trajectory is parabolic in nature whose minima is at origin , And that explain why rays is bouncing upward.

so its not TIR but equation of trajectory (snell's law) is the reason.