// 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 project(
  title: "",
  subtitle: "",
	university: "",
	semester: "",
	arbeit: "",
  bibliographyFilePath: "",
  abstract: [],
  managementSummary: [],
  authors: (),
  supervisors: (),
  industrialPartners: (),
  date: none,
  logoIndustrialPartner: none,
  ostLogo: none,
  enableOutlines: true,
  body,
) = {
  // Set the document's basic properties.
  set document(author: authors.map(a => a.name), title: title)
  
  set text(font: "Linux Libertine", lang: "en")
  show math.equation: set text(weight: 400)
  show link: underline
  
  set page(numbering: none)

  let headingFont = "Arial";

  show heading.where(level: 1): h => {
    v(10pt)
    align(left, text(size: 1.4em, font: headingFont, h))
  }
  show heading.where(level: 2): h => {
    text(size: 1.2em, font: headingFont, h)
  }
  show heading.where(level: 3): h => {
    text(size: 1em, font: headingFont, h)
  }

  // --- Title page ---   
  // Logos
  if logoIndustrialPartner != none and ostLogo != none {
    // TODO: align it properly
      grid(
        columns: (1fr, 1fr),
        gutter: 1em,
        image(logoIndustrialPartner, height: 130pt),
        image(ostLogo, height: 130pt),
      )
  }

  v(6fr)
  smallcaps(text(1.1em, [#date - #arbeit #semester]))

  v(0.6fr)
  text(2em, weight: 700, title)

  if subtitle != "" {
    v(0.3fr)
    text(1.3em, subtitle)
  }

  // Author information.
  pad(
    top: 1em,
    right: 10%,
    grid(
      columns: (1fr, 2fr, 2fr, 2fr),
      gutter: 2em,
			[#smallcaps("Studenten:")],
			..authors.map(author => align(start)[
				*#author.name* \
				#author.email
			]),
    ),
  )

	// Supervisor information.
  pad(
    top: 1em,
    right: 20%,
    grid(
      columns: (1fr, 2fr, 2fr, 1fr),
      gutter: 2em,
			[#smallcaps("Dozent:")],
			..supervisors.map(sv => align(start)[
				*#sv.name* \
				#sv.email
			]),
    ),
  )

  v(2.4fr)
  pagebreak()

  set par(justify: true)
  set page(
    numbering: "1 / 1", 
    number-align: center,
		header: [
			#set text(10pt)
			#smallcaps(title)
			#h(1fr)	#text(date)
		]
	)
  counter(page).update(1)

  // --- Table of contents --- 
   {
     show outline.entry.where(
       level: 1
     ): it => {
       v(12pt, weak: true)
       strong(it)
     }
     heading(outlined: false,numbering: none, bookmarked: true, [List of contents])
     outline(depth: 2, indent: true, title: none)
   }

   pagebreak()
  
  // --- Main body --- 
  set heading(numbering: "1.1", supplement: [Kapitel])

  body

  pagebreak()
  set heading(numbering: "A.1")
  counter(heading).update(0)

  // --- Outlines ---  
  if enableOutlines {
     heading("Abbildungsverzeichnis")
     outline(title: none, target: figure.where(kind: image))
  }

  // Bibliography
  if bibliographyFilePath != "" {
    heading("Bibliography")
    bibliography(bibliographyFilePath, title: none, style: "ieee")
  }
}