#import "./packages.typ": *


/***********************************************/
/*            Slanted Parallelogram            */
/***********************************************/

#let slantArt = pattern(
  size: (20pt, 20pt),
  relative: "parent",
  place(
    dx: 5pt,
    dy: 5pt,
    rotate(45deg, square(
      size: 5pt,
      fill: black,
    )),
  ),
)


#let repeat_char(character, count, spacing) = {
  // Loop to repeat the character and add minimal spacing
  let character = text(character, size: 20pt, weight: "bold")
  for i in range(0, count) {
    if i > 0 { h(spacing) }
    text(character)
  }
}

#let parallelogram = rotate(25deg)[
#rect(
  width: 0.001cm,
  height: 0.50cm
)
#h(3.5pt)
]




/***********************************************/
/*            Underlined Red Titles            */
/***********************************************/

#let subhead(body, head: false) = {

// Conditions
set text(black) if head

set text(12pt, font: "Source Serif Pro")
  underline(
    stroke: 2pt + red,
    offset: 4pt,
    [#body]
  )

}




#let empha(term, option) = {
  v(-2pt)  // align with text
  set text(10pt)
  set align(center)
  set text(fill: black)
  if option == 1 [
    #h(5pt)
    #badge-yellow(term)
    #h(5pt)
  ] else if option == 2 [
    #h(5pt)
    #badge-green(term)
    #h(5pt)
  ] else if option == 3 [
    #h(5pt)
    #badge-red(term)
    #h(5pt)
  ] else if option == 4 [
    #ui-action(term)
    #h(5pt)
  ] else [
    #set text(12pt)
  ]
}


#let page-number(number) = {
  move(dx: 280pt, dy: 770pt)[
    #number
  ]
}


/***********************************************/
/*               Slanted Colorbox              */
/***********************************************/


#let slantedFigure(color: black, body) = {
  set text(fill: white, weight: "bold")
  style(styles => {
    let size = measure(body, styles)
    let inset = 8pt
    [#block()[
      #polygon(
        fill: color,
        (0pt, 0pt),
        (0pt, size.height + (2*inset)),
        (size.width + (2*inset), size.height + (2*inset)),
        (size.width + (2*inset) + 6pt, 0cm)
      )
      #place(center + top, dy: size.height, dx: -3pt)[#body]
    ]]
  })
}

#let slantedColorbox(title: "title", color: none, radius: 0pt, width: auto, body) = {

  let strokeColor = luma(70)
  let backgroundColor = white

  if color == "red" {
    strokeColor = rgb(237, 32, 84)
    backgroundColor = rgb(253, 228, 224)
  } else if color == "green" {
    strokeColor = rgb(102, 174, 62)
    backgroundColor = rgb(235, 244, 222)
  } else if color == "blue" {
    strokeColor = rgb(29, 144, 208)
    backgroundColor = rgb(232, 246, 253)
  }

  return box(
    fill: backgroundColor,
    stroke: 2pt + strokeColor,
    radius: radius,
    width: width,
  )[
    #slantedFigure(color: strokeColor)[#title]
    #block(
      width: 100%,
      inset: (top: -2pt, x: 10pt, bottom: 10pt)
    )[
      #body
    ]
  ]
}



#let desc = {
  set text(12pt, font: "Gotham")
  set text(weight: "regular")
  set text(white)
  "A comprehensive guide"
}

#let title = {
  set text(20pt, font: "Gotham")
  set text(weight: "extrabold")
  set text(white)
  "Front End Lead"
}




// #box(
//   width: auto,
//   height: 14pt,
//   {
    
//     stack(
//       dir: ltr,
//       spacing: 0pt,
//       [A], 
//       empha("Loan", 3)
//     )
//   }
// )