
727 N.W.2d 403 (2007)
STATE of Minnesota, Respondent,
v.
Scott Edward CANNADY, Appellant.
No. A05-811.
Supreme Court of Minnesota.
February 8, 2007.
*405 Jeffrey C. Dean, Dean Law Office, Minneapolis, MN, for appellant.
Lori Swanson, Atty. Gen., Susan Gaertner, Ramsey County Atty., Jeanne L. Schleh, Asst. County Atty., St. Paul, MN, for respondent
Heard, considered, and decided by the court en banc.

OPINION
PAGE, Justice.
After a court trial in Ramsey County District Court, appellant Scott Edward Cannady was convicted of 23 counts of possessing child pornography in violation of Minn.Stat. § 617.247, subd. 4(a) (2006), based on photographic images found on his computer. Cannady appealed his conviction, arguing that Minn.Stat. § 617.247, subd. 8 (2006), an affirmative defense provision, unconstitutionally shifts the burden of production and persuasion to the defendant on the element of age of the persons depicted in the alleged pornographic images. The court of appeals affirmed Cannady's convictions, relying on its 2002 decision in State v. Myrland, which upheld the constitutionality of section 617.247, subdivision 8, on the basis that only the burden of production is shifted to the defendant and not the burden of persuasion. 644 N.W.2d 847, 851 (Minn.App.2002), rev. denied (Minn. Aug. 6, 2002). While we agree with the court of appeals that section 617.247, subdivision 8, shifts the burden of production to criminal defendants, we hold that this shift violates a criminal defendant's right to due process because it also creates a de facto shift in the burden of persuasion. But we further hold that to the extent the trial court applied section 617.247, subdivision 8, in this case, that error was harmless beyond a reasonable doubt. We therefore affirm Cannady's convictions.
This appeal arises out of the following events. In December of 2003, St. Paul police executed a search warrant at Cannady's home. As a result of the search, police seized and forensically searched the hard drive of Cannady's computer. Analysis of the computer hard drive revealed what were determined to be a number of photographic images of what was thought to be child pornography. On March 16, 2004, the Ramsey County Attorney's office charged Cannady with 25 counts of possession of child pornography in violation of section 617.247, subdivision 4(a). Each count involved a separate image of an alleged minor found on the computer and described in detail a sexual act taking place in the image. Before trial, Cannady moved to dismiss the complaint on constitutional grounds, arguing that, among other things, section 617.247, subdivision 8, violates the U.S. and Minnesota Constitutions by shifting the burden of production and persuasion to the defendant on the element of the age of the person depicted in the photographic image alleged to contain child pornography.[1] The state opposed Cannady's motion, asserting that the court of appeals held the statute constitutional in Myrland. The trial court denied Cannady's motion.
After the trial court dismissed Cannady's motion, Cannady gave notice of his intent to rely on the affirmative defense in section 617.247, subdivision 8. On September *406 7, 2004, while expressly preserving his right to appeal the constitutionality of section 617.247, Cannady waived his right to a jury trial and agreed to a court trial. As part of the trial, the parties stipulated to the admission of 16 exhibits into evidence, including the complaint, the police reports, and the photographic images constituting the alleged child pornography. Cannady made clear to the court that, although he stipulated to the police reports and that the police found the photographs on the computer, he was not conceding "the age of the people in the photographs," but instead was "leaving that for the Court to decide." Cannady again asserted the affirmative defense found in section 617.457, subdivision 8, and stated that he was "not conceding the element of age, and expects that to be an element proven by the State." Cannady did not testify or otherwise offer any evidence in his defense.
On September 20, 2004, the trial court issued its findings of fact, conclusions of law, and guilty verdicts on 23 counts and verdicts of not guilty on the remaining two. The court also put its findings and the verdicts on the record. In doing so, the court noted that, although Cannady asserted the statutory affirmative defense, "[t]he burden of proof remained with the State to prove beyond a reasonable doubt that each photograph contained * * * pornography involving a minor." The court further noted that the state had proved the element of age beyond a reasonable doubt based on the physical depiction of the persons in the photographs and how the photographs were described (e.g., "pre13"). The court made no mention of the effect, if any, of Cannady's invocation of the affirmative defense.
On appeal to the court of appeals, Cannady challenged the constitutionality of the affirmative defense in section 617.457, subdivision 8, and the court's earlier decision in Myrland. State v. Cannady, No. A-05-811, 2006 WL 997782 *1, *3 (Minn.App. 2006). Relying on Myrland, the court of appeals upheld subdivision 8's constitutionality and affirmed Cannady's convictions. Cannady now asks us to overrule Myrland and find section 8 unconstitutional.

I.
Statutes are presumed constitutional, and we exercise our power to declare a statute unconstitutional with extreme caution and only when absolutely necessary. In re Haggerty, 448 N.W.2d 363, 364 (Minn.1989). Constitutional challenges are questions of law, which we review de novo. In re Blilie, 494 N.W.2d 877, 881 (Minn.1993).
Section 617.247, subdivision 4, makes possession of child pornography a felony: "A person who possesses a pornographic work or a computer disk or computer * * * containing a pornographic work, knowing or with reason to know its content and character, is guilty of a felony." The definition of "pornographic work" is as follows:
(f) "Pornographic work" means:
(1) an original or reproduction of a picture, film, photograph, negative, slide, videotape, videodisc, or drawing of a sexual performance involving a minor, or
(2) any visual depiction, including any photograph, film, video, picture, drawing, negative, slide, or computer-generated image or picture, whether made or produced by electronic, mechanical, or other means that:
(i) uses a minor to depict actual or simulated sexual conduct;
(ii) has been created, adapted, or modified to appear that an identifiable minor is engaging in sexual conduct; or

*407 (iii) is advertised, promoted, presented, described, or distributed in such a manner that conveys the impression that the material is or contains a visual depiction of a minor engaging in sexual conduct.
For the purposes of this paragraph, an identifiable minor is a person who was a minor at the time the depiction was created or altered, whose image is used to create the visual depiction.
Minn.Stat. § 617.246, subd. 1(f) (2006) (emphasis added). In all cases except under section 617.246, subdivision 1(f)(2)(iii), the state must prove, as an essential element of its case, that the person or persons in the pornographic work are minors.[2]
Section 617.247, subdivision 8, provides that, "It shall be an affirmative defense to a charge of violating this section that the pornographic work was produced using only persons who were 18 years or older." (Emphasis added.) Cannady argues that the statute's language is plain and leaves no discretion regarding whether age is an affirmative defense because it uses the word "shall," which is mandatory. Minn. Stat. § 645.44, subd. 16 (2004). Thus, he concludes that the statute violates a defendant's right to due process because it requires the defendant to affirmatively disprove one of the essential elements of the crime, specifically that the persons in the pictures are minors. In response, the state argues that, despite the language of the statute, subdivision 8 is "merely advisory" because the legislature "cannot shift any burden of proving age, an element of the offense, to the defense."
In Minnesota, defendants bear the burden of production when asserting an "affirmative defense." State v. Auchampach, 540 N.W.2d 808, 816-17 n. 7 (Minn.1995). In certain situations, a defendant may also be required to bear the burden of persuasion. See id. (explaining our past treatment of the term "affirmative defense"). In discussing our past treatment of the term "affirmative defense," we have noted that the legislature is aware of these definitions and has "used affirmative defense to require the defendant to bear not only the burden of production but also the burden of persuasion." Id. Further, we assume that when the legislature uses a term of artas it did in subdivision 8 with "affirmative defense" it intends to use the accepted definition of that term of art. Minn. & Pac. R.R. Co. v. Sibley, 2 Minn. 13, 19 (2 Gil. 1) (1858) ("When terms of art or peculiar phrases are used, it must be supposed they are used in the sense as understood by persons familiar and acquainted with such terms.").
Given the plain language of subdivision 8, including the legislature's use of the term of art "affirmative defense," we conclude that the legislature intended subdivision 8 to be, and it in fact is, an affirmative defense.
But the legislature did not indicate in subdivision 8 whether the affirmative defense shifts the burden of production or the burden of persuasion on the element of age to the defendant. The court of appeals in Myrland concluded that if the affirmative defense shifted the burden of *408 production, it would be constitutional, but if it shifted the burden of persuasion, it would be unconstitutional. 644 N.W.2d at 851. The court of appeals held that the affirmative defense could be construed as "merely requir[ing] respondents to make a prima facie showing that the age of the persons involved is a disputed issue. As such, the state is never freed of its burden to prove the age of the persons involved and the charges will be dismissed if it fails to meet that burden." Id. (internal footnote omitted).
But the Myrland court did not consider what would happen if a defendant fails to make out a prima facie case on the element of age, which in this case is an essential element of the crime. It is well-established law that a defendant's failure to meet his or her burden of production on a defense prohibits the assertion of that defense. State v. Yang, 644 N.W.2d 808, 819 (Minn.2002); State v. Charlton, 338 N.W.2d 26, 30-31 (Minn.1983). By placing the burden of production of an essential element of the offense on the defendant, section 617.247, subdivision 8, creates a de facto shift in the burden of persuasion because a defendant's failure to meet the burden of production on the issue of age would prevent the issue from ever reaching the jury. "It is well settled that due process `protects the accused against conviction except upon proof beyond a reasonable doubt of every fact necessary to constitute the crime with which he is charged.'" State v. Hage, 595 N.W.2d 200, 204 (Minn.1999) (quoting Patterson v. New York, 432 U.S. 197, 204, 97 S.Ct. 2319, 53 L.Ed.2d 281 (1977)). As a result, "[d]ue process does not permit the state to place on a defendant the burden of disproving an element of the crime with which she is charged." Id. Because the affirmative defense in subdivision 8 creates a de facto shift in the burden of persuasion to the defendant on the essential element of age, we hold that it is unconstitutional.

II.
When we hold a statute to be unconstitutional, we invalidate only as much of the law as is unconstitutional. Minn.Stat. § 645.20 (2004); State v. Shattuck, 704 N.W.2d 131, 143 (Minn.2005). To do so, we first look to the intent of the legislature, with our primary goal of creating a remedy that would conform to the legislature's intent had it known a provision of the law was invalid. Shattuck, 704 N.W.2d at 143. Absent a provision to the contrary, all provisions of a law are severable. Minn.Stat. § 645.20; Shattuck, 704 N.W.2d at 143.
The legislature has stated that its policy and intent, in enacting section 617.247, was "to penalize possession of pornographic work[s] depicting sexual conduct which involve minors or appears to involve minors in order to protect the identity of minors who are victimized by involvement in the pornographic work." Minn.Stat. § 617.247, subd. 1. The affirmative defense in section 617.247, subdivision 8, is the only portion of section 617.247 that shifts the burden of persuasion to the defendant on the element of age and thus is the only portion of the statute that is unconstitutional. By severing subdivision 8 from the rest of the statute and striking only that portion, we maintain the rest of section 617.247, which criminalizes possession of child pornography as intended by the legislature.

III.
Our determination that section 617.247, subdivision 8, is unconstitutional does not end our inquiry. A deprivation of rights in a criminal trial may be harmless error, even though it is a constitutional violation. Arizona v. Fulminante, 499 *409 U.S. 279, 306, 111 S.Ct. 1246, 113 L.Ed.2d 302 (1991); Chapman v. California, 386 U.S. 18, 23, 87 S.Ct. 824, 17 L.Ed.2d 705 (1967); accord State ex rel. Kons v. Tahash, 281 Minn. 467, 475 n. 3, 161 N.W.2d 826, 832 n. 3 (1968). Constitutional error is not reversible error when the error is harmless beyond a reasonable doubt. State v. Larson, 389 N.W.2d 872, 875 (Minn.1986). When determining whether the error is harmless, we consider all of the facts and circumstances of the case. State v. Bouwman, 354 N.W.2d 1, 8 (Minn. 1984).
The United States Supreme Court has held that the harmless-error analysis applies to errors that occurred during the trial that can be "quantitatively assessed" in the context of the rest of the trial and the evidence presented. Fulminante, 499 U.S. at 307-08, 111 S.Ct. 1246. The Court has rejected the use of the harmless-error test in cases in which "[t]he entire conduct of the trial from beginning to end is obviously affected," such as in the case of a biased judge, the deprivation of the right to counsel at trial, the exclusion of jurors based on racial bias, the right to self-representation at trial, and the right to a public trial. Id. at 309-10, 111 S.Ct. 1246.
Even in cases in which the Court has invalidated a state statute that was related to the defendant's trial, the Court has used the harmless-error test. Id. at 307, 111 S.Ct. 1246 (citing Hopper v. Evans, 456 U.S. 605, 102 S.Ct. 2049, 72 L.Ed.2d 367 (1982), as an example). In Hopper, the defendant had been charged with a capital offense in Alabama, which had a statute precluding the consideration of lesser-included offenses in capital cases. 456 U.S. at 607-08, 102 S.Ct. 2049. After the defendant appealed, the Court held in a different case that a sentence of death could not be imposed after a guilty verdict in a capital case if lesser-included offenses had not been included in the jury instructions, provided that the evidence would have supported the lesser-included offense. Id. at 609, 102 S.Ct. 2049. When considering the defendant's case in Hopper, the Court concluded that even though the preclusion statute was unconstitutional, Hopper would not have been entitled to the instruction because no evidence in his trial would support the lesser-included offense. Id. at 612-13, 102 S.Ct. 2049. The Court concluded that "[t]he preclusion clause did not prejudice respondent in any way, and a new trial is not warranted." Id. at 613-14, 102 S.Ct. 2049.
So, too, in this case Cannady was not prejudiced by the existence of section 617.247, subdivision 8. Cannady asserted the affirmative defense, without presenting any evidence that the persons depicted in the photographic images were 18 years or older. The record, however, indicates that the trial court not only considered the issue of age, despite Cannady's failure to meet his burden of production, it required the state to prove beyond a reasonable doubt that the photographs included minors. The court found Cannady guilty on 23 of the 25 counts beyond a reasonable doubt, made a clear record, both in writing and verbally, indicating that the state had met its burden of proving age beyond a reasonable doubt, and explained in some detail exactly how the state had met that burden. The court noted:
I have found the Defendant, Scott Cannady, not guilty of Counts 6 and 11, as I did not find that the evidence was sufficient to prove beyond a reasonable doubt that those photographs in Mr. Cannady's possession constituted child pornography. However, I found, as it relates to photographs 1 through 5, 7 through 10 and then 12 through 25, that the State did prove beyond a reasonable doubt that each of those photographic *410 images constitute child pornography. * * * [T]hese photographs include a minor, a subject under the age of 18. My conclusion that the State proved that element beyond a reasonable doubt is two-fold: One, the actual photograph, the physical facial depiction of the child, as well as the categorization of the photograph * * * how the photographs were listed, how they were described, whether it be "pre13," "pre14," "little girl," "preteen Lolita."
Thus, despite the fact that Cannady asserted the affirmative defense in section 617.247, subdivision 8, the trial court unequivocally required the state to prove the elements of the offense beyond a reasonable doubt. Cf. State v. Ayers, 303 Minn. 562, 562, 228 N.W.2d 547, 547 (1975) (holding that it was not prejudicial error in a bench trial for the court to state the wrong standard of reviewclear and convincing, instead of beyond a reasonable doubt when "the trial court made it clear that he applied the proof-beyond-a-reasonable-doubt standard in finding defendant guilty"). Additionally, a review of the photographic images from the 23 counts for which Cannady was convicted shows that each of the alleged pornographic works depicts persons so clearly under the age of 18 that there can be no question that the state met its constitutional burden of persuasion without regard to any obligation placed on Cannady by subdivision 8. Thus, we hold that even though section 617.247, subdivision 8, is unconstitutional, any error in Cannady's bench trial was harmless beyond a reasonable doubt and therefore affirm his conviction.
Affirmed in part, reversed in part.
NOTES
[1]  Cannady also argued that section 617.247, subdivision 4, is overbroad, in violation of the First Amendment to the U.S. Constitution. Cannady did not raise that argument on appeal and it is therefore not before us.
[2]  In this case, as in State v. Fingal, 666 N.W.2d 420, 422 (Minn.App.2003), rev. denied (Minn. Oct. 21, 2003), the trial court determined that section 617.246, subdivision 1(f)(2)(iii), was unconstitutional under the First Amendment to the U.S. Constitution, relying in part on Ashcroft v. Free Speech Coalition, 535 U.S. 234, 122 S.Ct. 1389, 152 L.Ed.2d 403 (2002). Cannady did not raise the constitutionality of section 617.246, subdivision 1(f)(2)(iii), in this appeal. Because the subdivision's constitutionality is not before us, we express no opinion regarding that issue.
