// lemma: a stated result, optionally with a proof.
//
// Contract fields:
//   content: `stmt` (required), `proof` (optional)
//   scalar:  none
//
// Numbered "定理 N" via the shared lemma-counter.
//   student: show `stmt`, HIDE `proof`.
//   teacher: show both (when `proof` is present).
// `proof` may be absent (key omitted) — handled gracefully.

#import "../fonts.typ"
#import "common.typ": element-box, tag-line, divider, lemma-counter, hue-of

#let display-lemma(part, show-proof: true) = {
  let theme = oklch(70%, 0.08, hue-of.lemma * 1deg)
  lemma-counter.step()

  element-box(hue-of.lemma, {
    // Statement
    tag-line(context [定理 #lemma-counter.display()])
    set text(font: fonts.accent)
    part.stmt

    // Proof: only when requested AND actually provided.
    let proof = part.at("proof", default: none)
    if show-proof and proof != none {
      divider(theme)
      tag-line[证明]
      set text(font: fonts.accent)
      proof
    }
  })
}
