#import "misc.typ": ored

#let solution_warning() = {
  set text(ored)
  align(
    center,
    block(
      width: 60%,
      height: auto,
      breakable: false,
      fill: rgb(255, 255, 255),
      stroke: ored + 2pt,
      inset: 3mm,
      (
        align(center, text(weight: "bold", size: 12pt, [Instructor's Handout]))
          + parbreak()
          + align(
            left,
            text(
              size: 10pt,
              [
                This handout contains solutions and notes. \
                Recompile without solutions before distributing.
              ],
            ),
          )
      ),
    ),
  )
}


#let short_solution_warning() = {
  set text(ored)
  align(
    center,
    block(
      width: 60%,
      height: auto,
      breakable: false,
      fill: rgb(255, 255, 255),
      stroke: ored + 2pt,
      inset: 3mm,
      (
        align(center, text(weight: "bold", size: 12pt, [Instructor's Handout]))
          + parbreak()
      ),
    ),
  )
}

#let make_header(
  title,
  subtitle: none,
  by: none,
  top_left: "",
  top_right: "",
) = {
  let date = datetime
    .today()
    .display("[month repr:long] [day padding:none], [year]")

  if (by != none) {
    by = text(size: 10pt, [Prepared by #by on #date])
  }

  let sub = ()
  if (by != none) {
    sub.push(by)
  }
  if (subtitle != none) {
    sub.push(subtitle)
  }

  // Main title
  align(
    center,
    block(
      width: 60%,
      height: auto,
      breakable: false,
      align(
        center,
        stack(
          spacing: 7pt,
          // Top
          text(size: 10pt, top_left) + h(1fr) + text(size: 10pt, top_right),
          line(length: 100%, stroke: 0.2mm),
          // Title
          text(size: 20pt, title),
          // Subtitle
          ..sub,
          line(length: 100%, stroke: 0.2mm),
        ),
      ),
    ),
  )
}
