MJ Brogdin Consulting Co. (“Brogdin”) retained the services of Plaintiff-Appellant Charles D. Cook to deliver casing1 and oversee its installation in Brogdin’s oil well. During the execution of his work on the project, Cook delivered casing to the drill site, but thereafter made a counting error that caused him to take away more of that casing, as excess, than he should have. This error in turn resulted in the completion of the well at an incorrect depth, shallower than the zone targeted for completion. Consequently, Brogdin incurred increased costs to have the well reworked and casing reinstalled to the correct depth. Cook sued his commercial general liability (“CGL”) insurance carrier, Defendant-Appellee Admiral Insurance Company (“Admiral”), seeking a declaratory judgment that Admiral must (1) defend Cook in any lawsuit brought against him by Brogdin and (2) indemnify Cook for all damages awarded to Brogdin in such a suit.
*315Seeking a determination that it did not owe Cook a defense or indemnity, Admiral filed a motion for summary judgment, which the district court granted. The court reasoned that, because there was no “loss of use” of the Brogdin well, Cook’s acts did not result in “property damage” under the terms of Admiral’s policy, so Admiral had no duty to defend or indemnify Cook. We affirm the summary judgment, but for different reasons
I. FACTS & PROCEEDINGS
A. Facts
Cook purchased a CGL insurance policy from Admiral. During the term of that policy, Brogdin retained Cook to deliver casing to the well and to oversee its installation in the well bore. In preparation for casing and completing the oil well, Cook was required to haul any excess casing away from the drill site. Cook made a counting error, however, and hauled away too much casing from the drill site. This resulted in an insufficient string of casing being installed in the well bore, causing the well to be completed ineffectively at a depth that was shallower than that of the zone intended for completion and production. This required Brogdin to have the well reworked before it could be completed at the correct depth, costing Brogdin $336,745.63. Brogdin sued Cook in state court, claiming only that cost of reworking the well.
B. Proceedings
Before he was sued by Brogdin, Cook notified Admiral of Brogdin’s pre-suit claim. Admiral responded that, although the CGL policy provided $1 million in coverage, Cook could not recover more than $100,000 in damages because of an endorsement relating to underground work. This prompted Cook to sue Admiral in state court, seeking a declaratory judgment that the policy’s full $1 million coverage was applicable to Brogdin’s anticipated claim because Cook’s work did not involve an underground equipment hazard. When, thereafter, Brogdin sued Cook, Admiral accepted Cook’s defense under a reservation of the right to claim that it had no duty to defend or indemnify Cook against Brogdin’s suit.
Admiral removed Cook’s action to federal court and Brogdin intervened. Admiral then countersued Cook and Brogdin, seeking a declaratory judgment that its duty to indemnify Cook was limited to $100,000. Cook filed a motion for partial summary judgment on Admiral’s counterclaim. Admiral then filed a motion for summary judgment, asserting that it had no duty to defend Cook in Brogdin’s state court suit because Brogdin’s claims against Cook were not within the scope of coverage of the CGL policy.
The district court granted summary judgment in favor of Admiral. It held that Admiral did not have a duty to defend Cook against Brogdin’s lawsuit because Cook’s actions did not result in a “loss of use of tangible property that is not physically injured,” and that there thus was no “property damage” under the CGL policy.2 The district court also ruled that, for the same reasons, Admiral did not have a duty to indemnify Cook, who then timely filed a notice of appeal.
II. ANALYSIS
A. Standard of Review
We review a district court’s summary judgment de novo, applying the same legal *316standards as the district court.3 Summary judgment is proper only “if the movant shows that there is no genuine dispute as to any material fact and the movant is entitled to judgment as a matter of law.”4 In our review, we may only consider the summary judgment record that was before the district court, viewing that evidence in the light most favorable to the non-moving party.5
B. Admiral Does Not Have a Duty to Defend Cook
Under Texas law, an insurer’s duty to defend “is governed by the ‘eight-corners’ rule, whereby a court considers only the allegations in the underlying complaint and the terms of the insurance policy. If the petition filed against the insured, liberally construed, alleges facts within the scope of coverage, the insurer must defend.”6 In addition, the duty to defend “is determined by the underlying plaintiffs pleadings ... without regard to the truth or falsity of those allegations,” making “only two documents [ ] ordinarily relevant to the determination of the duty to defend: the policy and the pleadings of the underlying claimant. Facts outside the pleadings, even those easily ascertained, are ordinarily not material to the determination and allegations against the insured are liberally construed in favor of coverage.”7
Here, Brogdin asserts in its complaint that it had contracted with Cook to “deliver and oversee the running of casing on a well” but that Cook had “removed more casing from the well site than it [sic] should, thereby resulting in a failure to complete the well to the desired depth, necessitating an expensive rework of the well, proximately causing damage to plaintiff.” Based on these alleged facts, Brogdin makes two distinct legal claims—one based on a theory of breach of contract and the other based on a theory of negligence—contending that under each theory Cook “must reimburse [Brogdin] for the funds paid by [Brogdin] to mitigate damages caused by [Cook], to the damage of [Brogdin].” We now must determine in our de novo review whether Brogdin has made allegations against Cook that fall within the scope of coverage of Admiral’s CGL policy.
1. “Loss of Use of Tangible Property That Is Not Physically Injured”
The CGL policy requires Admiral to defend Cook against any suit seeking “damages because of ‘bodily injury’ or ‘property damage’ to which this insurance applies.”8 The policy further provides that “[t]he insurance applies to [] ‘property damage’ only if: The [ ] ‘property damage’ is caused by an ‘occurrence’ that takes place in the ‘coverage territory’ ....” And an “occurrence” is defined as “an accident, including continuous or repeated exposure to substantially the same harmful conditions.” The Texas Supreme Court has agreed with our earlier assessment that “‘claims for damage caused by an in*317sured’s defective performance or faulty workmanship’ may constitute an ‘occurrence’ when ‘property damage’ results from the ‘unexpected, unforeseen or undesigned happening or consequence’ of the insured’s negligent behavior”9—regardless of whether the occurrence injures a third party’s property or the insured’s work.10 The Texas Supreme Court has also explained that “[a]n accident is generally understood to be a fortuitous, unexpected, and unintended event” and has cited, as an example, “[t]he wrong number of boxes was shipped because someone made a mistake in counting.”11
Here, Cook’s “remov[al][of] more casing from the well site than [he] should” (because someone made a mistake in counting) was an “occurrence” under the terms of the CGL policy, as construed by the Texas Supreme Court.12 The question then is whether the resulting damage alleged by Brogdin—the “failure to complete the well to the desired depth”—constituted “property damage” under Admiral’s policy.
That CGL policy defines “property damage” disjunctively as:
(a) Physical injury to tangible property, including all resulting loss of use of that property. All such loss of use shall be deemed to occur at the time of the physical injury that caused it; or
(b) Loss of use of tangible property that is not physically injured. All such loss of use shall be deemed to occur at the time of the “occurrence” that caused it.
In the district court, Cook assumed that Brogdin’s alleged facts fit into the CGL policy under subsection (b) alone, i.e., the “loss of use” definition of “property damage.” The district court determined, however, that for there to be “loss of use of tangible property,” the tangible property—here, the well—must have been in use prior to the damage.13 The court observed: “The well completed at the specified depth had not only not been used but could not have been used. It was not poised ready to put in action or service. It simply did not exist at the time of the breach or when the reworking was done.”14 Based on that analysis, the district court concluded that Cook’s actions did not result in “loss of use” of an existing well.15 The court went on to note that “even if the policy did cover damages for the loss of use of something that had not yet been created, the Brogdin lawsuit does not allege damages for loss of use.”16 We need not pursue this further, however, because we affirm on different grounds.
2. “Property Damage” Exclusions
Although the CGL policy does generally require Admiral to defend against any suit seeking damages from Cook for “property damage,” section j of the policy expressly excludes coverage of:
“Property damage” to:
*318(5) That particular part of real property on which you ... are performing operations if the “property damage” arises out of those operations; or
(6) That particular part of any property that must be restored, repaired or replaced because ‘your work’ was incorrectly performed on it.
Here, the “property damage,” i.e., the completion of the well at an incorrect depth, undeniably arose out of Cook’s operations; and it was precisely that well which had to be reworked because Cook’s negligence in retrieving too much casing from the site left an insufficient quantity of casing to reach the proper depth for completion. Moreover, Cook then oversaw the running of that insufficient casing. Relying on Mid-Continent Casualty Co. v. JHP Development, Inc.,17 Cook insists that exclusion j(5) is inapplicable because, temporally speaking, “there was a gap between the occurrence and loss of use.” In that opinion, we addressed this same CGL policy exclusion, recognizing that “exclusion j(5) makes clear that the exclusion only applies to property damage that occurred during the performance of construction operations” and concluding that the exclusion did not apply in that case because the property damage “occur[red] during a prolonged, open-ended, and complete suspension of construction activities.” 18 Cook attempts to liken Mid-Continent to the instant case by identifying the “occurrence” as the removal of the casing and then arguing that the property damage “occurred after the occurrence was performed, when the casing was run.” This analysis, however, misses the point of our holding in Mid-Continent and misses the factual distinction between that case and this one. The plain language of exclusion j(5) makes it applicable to property damage that “arises out of’ operations that take place while the insured is “performing operations.” That is why exclusion j(5) did not apply in Mid-Continent to damage caused during a suspension of construction activities. Here, in contrast, there was no suspension of construction activities: The well was completed to the incorrect depth, i.e., damaged, while Cook was “delivering] and overseeing] the running of casing on [the] well,” as his “work” was characterized in Brogdin’s complaint.
Cook likewise asserts that exclusion j(6) is inapplicable because “the defective work was the removal of casing, [and] the loss of use was to the well, a separate property.” But, this analysis too strays from the plain text of the exclusion. In Mid-Continent, we explained that “[t]he plain meaning of the exclusion ... is that property damage only to parts of the property that were themselves the subjects of the defective work is excluded.” 19 In the instant case, Cook was hired to (1) provide casing for the well as an integral part of the drilling and completion of the well as a whole and (2) oversee the running of the casing that he provided. As Admiral notes, casing “is not a component of a well that functions independently, and without which the rest of the well would continue to function.”20 Therefore, because Cook *319negligently recovered and hauled off too much of the casing from the well site where he had delivered it—thus furnishing a net amount of casing insufficient to reach the target depth for the completion of the well—he caused defects in the “construction” of the well as a whole when he oversaw the installation of that deficient quantity of casing. These circumstances are distinguishable from those of defective repair work (performed after a well is constructed) that causes damage only to the casing, as a pre-installed component of the finished well.21 By contrast, there was here no domino effect of damage to the entire well triggered by Cook’s defective work on one independent working part of the well; rather, Cook’s work was performed during the overall drilling and completion operation of the well and thus caused damage to the entire well when his work was incorrectly performed.
Although the district court did not grant summary judgment in favor of Admiral on the basis of exclusions j(5) and j(6), we have recognized that we may affirm a district court’s judgment for reasons—supported by the record—other than those relied on by the district court.22 We may, therefore, properly consider whether any of the Admiral policy’s exclusions apply to coverage in this case because the entire CGL policy, including exclusions j(5) and j(6), is part of the record. Cook contends that Admiral has waived any argument based on these policy exclusions because, under Texas law, a policy exclusion is an affirmative defense,23 and failure to raise an affirmative defense generally constitutes waiver.24 But, we have also made clear that “there is some play in the joints” of that general rule, and “ ‘a defendant does not waive an affirmative defense if it is raised at a pragmatically sufficient time, and [the plaintiff] was not prejudiced in its ability to respond.’ “25 We have, for example, upheld a summary judgment in favor of an insurer based on an affirmative defense that the insurer did not plead.26
Here, the parties’ dispute turned primarily on whether Cook’s negligence, as alleged by Brogdin, caused “property damage” under the policy’s “loss of use” definition. The district court determined that it did not, thereby denying that Admiral had a duty to defend, and the court stopped its analysis at that point. Because the court thus determined that there was no policy coverage in the first place, it had no reason to question whether any of the policy’s exclusions might apply. As *320we found that ruling to raise a difficult question, however, and believed the policy-exclusion question to be rather straightforward, we requested that both parties submit supplemental letter briefs addressing the applicability of the policy’s two exclusions, which to us seemed relevant to the facts of this case. Cook thus had an adequate opportunity to respond and to refute the applicability of the exclusions; and, indeed, he took only two days, of the seven we allowed, to do so. Now that we have reviewed both Cook’s and Admiral’s responding analyses on this issue, we are satisfied that Cook was not prejudiced by our sua sponte raising of this issue,27 and we are now convinced that these exclusions provide the correct legal basis on which to affirm the district court’s summary judgment.
In sum, the property damage alleged by Brogdin in its complaint falls squarely within these two “property damage” exclusions—j(5) and j(6)—of the CGL policy. This, in turn, relieves Admiral of any duty to defend Cook in the action brought against him by Brogdin.
C. Admiral Does Not Have a Duty to Indemnify Cook
Under Texas law, an insurer’s duty to indemnify “is justiciable before the insured’s liability is determined in the liability lawsuit when the insurer has no duty to defend and the same reasons that negate the duty to defend likewise negate any possibility the insurer will ever have a duty to indemnify.”28 Admiral’s CGL policy provides that it “will pay those sums that [Cook] becomes legally obligated to pay as damages because of [] ‘property damage’ to which this insurance applies.” As we have determined that the CGL policy does not apply to the type of “property damage” alleged by Brogdin, Admiral does not have a duty to indemnify Cook for the same reasons that it does not have a duty to defend him.
III. CONCLUSION
For the foregoing reasons, the district court’s summary judgment relieving Admiral of any duty to defend or indemnify Cook is, in all respects, AFFIRMED.
Pursuant to 5th Cm. R. 47.5, the court has determined that this opinion should not be published and is not precedent except under the limited circumstances set forth in 5th Cm. R. 47.5.4.
. Casing is tubing or hollow pipe that comes in lengths or "joints” and is used to line the hole or “bore” of an oil well and to permit production when the drilling is finished and the well is "completed,” to permit production of minerals from the well’s productive zone. To avoid unnecessary delay, a maximum number of joints of casing are delivered to the drill site, and, after the depth for completion is determined, excess joints are removed from the site and returned to the supplier.
. Cook v. Admiral Ins. Co., No. 2:09-CV-0109-J, 2010 WL 2605256, at *2-4 (N.D.Tex. June 29, 2010).
. United States v. Caremark, Inc., 634 F.3d 808, 814 (5th Cir.2011) (citation omitted).
. Fed.R.Civ.P. 56(a).
. Caremark, 634 F.3d at 814 (citations omitted).
. Lincoln Gen. Ins. Co. v. Aisha’s Learning Center, 468 F.3d 857, 858 (5th Cir.2006) (citing Nat’l Union Fire Ins. Co. v. Merchants Fast Motor Lines, Inc., 939 S.W.2d 139, 141 (Tex.1997)).
. Liberty Mut. Ins. Co. v. Graham, 473 F.3d 596, 599-600 (5th Cir.2006) (citing GuideOne Ins. Co. v. Fielder Rd. Baptist Church, 197 S.W.3d 305, 308 (Tex.2006)).
. The parties do not dispute that Brogdin does not allege "bodily injury” in this case.
. Lamar Homes, Inc. v. Mid-Continent Cas. Co., 242 S.W.3d 1, 16 (Tex.2007) (quoting Federated Mut. Ins. Co. v. Grapevine Excavation Inc., 197 F.3d 720, 725 (5th Cir.1999)).
. Id. at 9 ("The CGL policy, however, does not define an ‘occurrence’ in terms of the ownership or character of the property damaged by the act or event. Rather, the policy asks whether the injury was intended or fortuitous, that is, whether the injury was an accident.”).
. Id. at 8 (quotation marks and citations omitted).
. See id.
. Cook, 2010 WL 2605256, at *3.
. Id.
. Id.
. Id. (emphasis added).
. 557 F.3d 207 (5th Cir.2009).
. Id. at 213.
. Id. at 215.
. This is simply not a situation in which the insured’s work was to be performed on a discrete independent component of a whole piece of property, and its defective work on that one component caused damage to other components of the whole property. See Gore Design Completions, Ltd. v. Hartford Fire Ins. Co., 538 F.3d 365, 371-72 (5th Cir.2008) (holding that when the insured was hired for "engineering of an in-flight enlertainment/cabin management system," exclusion *319j(6) only "exclude[d] coverage for the damage to the IFE/CMS itself (or, perhaps, the electrical system) but not the rest of the Aircraft and the ensuing loss of use damages”).
. See, e.g., Underwriters at Lloyd’s London v. OSCA, Inc., Nos. 03-20398, 03-20817, 03-21021, -Fed.Appx.-, 2006 WL 941794, at *18-19 (5th Cir.2006) (per curiam) (unpublished).
. Palmer ex rel. Palmer v. Waxahachie Indep. Sch. Dist., 579 F.3d 502, 506 (5th Cir.2009) (citing United States v. Dunigan, 555 F.3d 501, 508 n. 12 (5th Cir.2009)), cert. denied, - U.S. -, 130 S.Ct. 1055, 175 L.Ed.2d 883 (2010); LLEH, Inc. v. Wichita County, Tex., 289 F.3d 358, 364 (5th Cir.), cert. denied, 537 U.S. 1045, 123 S.Ct. 621, 154 L.Ed.2d 517 (2002).
. Tex. Ins.Code § 554.002 ("Language of exclusion in the contract or an exception to coverage claimed by the insurer or health maintenance organization constitutes an avoidance or an affirmative defense.”).
. Rogers v. McDonnan, 521 F.3d 381, 385 (5th Cir.2008).
. Id. at 385-86 (quoting Arismendez v. Nightingale Home Health Care, Inc., 493 F.3d 602, 610 (5th Cir.2007)) (alteration in original).
. Standard Waste Sys. Ltd. v. Mid-Continent Cas. Co., 612 F.3d 394, 398 (5th Cir.2010).
. Federal Rule of Civil Procedure 56 does not limit district courts or courts of appeals to granting summary judgment based on grounds asserted by the parties.
. Farmers Tex. Cnty. Mut. Ins. Co. v. Griffin, 955 S.W.2d 81, 84 (Tex. 1997) (emphasis in original).