#import "./typst-catppuccin/src/lib.typ": catppuccin, flavors, mocha, get-flavor


// The project function defines how your document looks.
// It takes your content and some metadata and formats it.
// Go ahead and customize it to your liking!
#let flavor = sys.inputs.at("flavor", default: flavors.mocha.identifier)
#let palette = get-flavor(flavor)
#let project(title: "", subtitle: "", authors: (), logo: none, body) = {
  show: catppuccin.with(flavors.mocha, code-block: true, code-syntax: true)
  // Set the document's basic properties.
  set document(author: authors.map(a => a.name), title: title)
  set page(numbering: "1", number-align: center)
  set text(font: "Nunito", lang: "en")
  set heading(numbering: none)

  show heading: it => [
    #set align(left)
    #set text(18pt, fill: palette.colors.mauve.rgb)
    #block(it.body)
    #v(0.5em)
  ]
  // Title page.
  // The page can contain a logo if you pass one with `logo: "logo.png"`.
  v(0.6fr)
  if logo != none {
    align(right, image(logo, width: 50%))
  }
  v(9.6fr)


  text(2em, weight: 700, title, fill: palette.colors.red.rgb)
  v(0.5fr)
  text(1.2em, weight: 700, subtitle, fill: palette.colors.mauve.rgb)

  // Author information.
  pad(
    top: 0.7em,
    right: 20%,
    grid(
      columns: (1fr,) * calc.min(3, authors.len()),
      gutter: 1em,
      ..authors.map(author => align(start)[
        *#author.name* \
        #author.affiliation \
        #author.email
      ]),
    ),
  )

  v(2.4fr)
  pagebreak()


  // Main body.
  set par(justify: true)

  body
}

