The foundational requirement is that one must be able to benefit from the moon's light: the Shulchan Arukh (Orach Chayim 426:1) rules that kiddush levana should be recited only at night, when the moon shines and one can benefit from its light, and the Tur (Orach Chayim 426) records the underlying Talmudic principle that the blessing is recited over the moon's renewal as long as its deficiency is still being filled.
The Gemara itself frames the outer time limit in terms of the moon's visible completeness: Sanhedrin 41b records Rabbi Yoḥanan's teaching that one may bless until the moon's flaw is filled, with Rav Yehuda placing that at seven days and the Sages of Neharde'a at sixteen days, and the Beit Yosef (Orach Chayim 426) explains that the reason blessings are recited as the moon grows — and not after — is that we bless over goodness and increase, not diminishment.
The practical standard, unanimously applied by the later authorities, is that the moon's light must be perceptible on the ground: the Magen Avraham (Orach Chayim 426) requires that the moon's shining be discernible upon the earth and that no screen intervene between the person and the moon, unless that screen is so clear that the moon is visible through it and one can recognize objects normally seen by moonlight.
Building on this, the Mishnah Berurah (426:3) rules that if the moon is covered by a thick cloud one may not recite the brachah, but if the cloud is thin and weak — such that the moon is visible through it and one can benefit from its light — one may bless; and the same standard applies to any other screen between the person and the moon: if it is thin enough that moonlight passes through and objects normally visible by moonlight can be recognized, the brachah is valid.
The Kitzur Shulchan Arukh (97:7) codifies the same rule and adds the practical guidance that if one has already begun the brachah and the moon is then covered by clouds, one completes it — but if one estimates at the outset that the moon will be covered before the brachah is finished, one may not begin.
Peninei Halakhah, Zemanim 1:17 synthesizes the position: if the moon is covered by a light cloud such that one can see by moonlight what one would ordinarily see by moonlight, the brachah may be recited, but the preferred practice is to recite it when the moon is clearly visible without any obstruction, and if necessary to defer to another night for that clarity; one must also look at the moon briefly beforehand in order to derive genuine benefit from its light.