Once upon a time, my conception of oil drilling was roughly that there were these giant tanks of oil underground, and to extract it we more or less stuck a straw down and sucked it out. And that one day, the well would make the same sound as the straw as you're finishing a milkshake, and we would suddenly have no more oil available.
Then circa 2002 I got a job at an oil well services company, and learned a lot of complexities about oil drilling. A key insight is that not all oil is equally economic to extract, and therefore the amount of oil available to extract is only fixed for a given price and set of technologies. As prices go up, the amount of available oil goes up too; as technology invariably marches forward, the amount of available oil goes up.
This behaves nicely with the control system we call the free market. As oil gets used up, prices will go up, which will unlock more available oil acting as negative feedback. At the higher price, some oil users will find a different solution to their problem, while other oil users will grumble and pay up, acting as a second source of negative feedback. This process repeats as the available oil at the new price point is exhausted.
This same pattern exists for essentially all mined resources. We're not going to one day run out of cobalt or lithium or whatever. As mines that are economic at current prices shut down, its price will go up, and some users will find an alternative, while others will grumble and pay. The higher prices will enable mines that weren't viable at the lower prices.