// Series Style — shared typography and visual identity
// This file defines the consistent "look" across all rPubs publications.
// Change this to rebrand the entire series.

#let series-fonts = (
  body: "New Computer Modern",
  heading: "New Computer Modern Sans",
  mono: "New Computer Modern Mono",
)

#let series-colors = (
  accent: rgb("#2d4a3e"),
  muted: rgb("#666666"),
  rule: rgb("#cccccc"),
  cover-bg: rgb("#1a1a2e"),
  cover-fg: rgb("#e0e0e0"),
)

#let apply-series-style(body) = {
  set text(
    font: series-fonts.body,
    size: 9pt,
    lang: "en",
  )
  set par(
    leading: 0.7em,
    spacing: 0.9em,
    justify: true,
  )
  set heading(numbering: none)
  show heading.where(level: 1): it => {
    set text(font: series-fonts.heading, size: 14pt, weight: "bold", fill: series-colors.accent)
    v(1em)
    it
    v(0.5em)
  }
  show heading.where(level: 2): it => {
    set text(font: series-fonts.heading, size: 11pt, weight: "bold", fill: series-colors.accent)
    v(0.8em)
    it
    v(0.3em)
  }
  show heading.where(level: 3): it => {
    set text(font: series-fonts.heading, size: 10pt, weight: "semibold")
    v(0.6em)
    it
    v(0.2em)
  }
  show raw: set text(font: series-fonts.mono, size: 7.5pt)
  show raw.where(block: true): it => {
    set par(justify: false)
    block(
      fill: rgb("#f5f5f5"),
      inset: 8pt,
      radius: 2pt,
      width: 100%,
      it,
    )
  }
  show link: set text(fill: series-colors.accent)
  body
}

#let series-rule() = {
  line(length: 100%, stroke: 0.5pt + series-colors.rule)
}

#let series-separator() = {
  v(0.5em)
  align(center, text(fill: series-colors.muted, size: 8pt)[· · ·])
  v(0.5em)
}
