- id: brand
  object:
    closed: true
    properties:
      meta:
        ref: brand-meta
      logo:
        ref: brand-logo
      color:
        ref: brand-color
      typography:
        ref: brand-typography
      defaults:
        schema: object
- id: brand-color
  description: >
    The brand's custom color palette and theme.
  object:
    closed: true
    properties:
      palette:
        description: >
          The brand's custom color palette. Any number of colors can be defined,
          each color having a custom name.
        object:
          additionalProperties:
            schema:
              ref: brand-color-value
      foreground:
        description: The foreground color, used for text.
        schema:
          ref: brand-color-value
        default: black
      background:
        description: The background color, used for the page background.
        schema:
          ref: brand-color-value
        default: white
      primary:
        description: >
          The primary accent color, i.e. the main theme color. Typically used for
          hyperlinks, active states, primary action buttons, etc.
        schema:
          ref: brand-color-value
      secondary:
        description: >
          The secondary accent color. Typically used for lighter text or disabled
          states.
        schema:
          ref: brand-color-value
      tertiary:
        description: >
          The tertiary accent color. Typically an even lighter color, used for hover
          states,
          accents, and wells.
        schema:
          ref: brand-color-value
      success:
        description: The color used for positive or successful actions and information.
        schema:
          ref: brand-color-value
      info:
        description: The color used for neutral or informational actions and information.
        schema:
          ref: brand-color-value
      warning:
        description: The color used for warning or cautionary actions and information.
        schema:
          ref: brand-color-value
      danger:
        description: The color used for errors, dangerous actions, or negative information.
        schema:
          ref: brand-color-value
      light:
        description: >
          A bright color, used as a high-contrast foreground color on dark elements
          or low-contrast background color on light elements.
        schema:
          ref: brand-color-value
      dark:
        description: >
          A dark color, used as a high-contrast foreground color on light elements
          or high-contrast background color on light elements.
        schema:
          ref: brand-color-value
      link:
        description: >
          The color used for hyperlinks. If not defined, the `primary` color is used.
        schema:
          ref: brand-color-value

- id: brand-color-value
  schema: string

- id: brand-font
  description: Font files and definitions for the brand.
  anyOf:
  - ref: brand-font-google
  - ref: brand-font-bunny
  - ref: brand-font-file
  - ref: brand-font-system
    # a font definition missing source information,
    # from which we will assume a default source
    #
    # in Quarto, the default source for typst is `google`
    # and the default source for html formats is `bunny`
  - ref: brand-font-common
- id: brand-font-bunny
  description: A font definition from fonts.bunny.net.
  object:
    super:
      resolveRef: brand-font-common
    closed: true
    properties:
      source:
        enum: [bunny]
- id: brand-font-common
  schema:
    object:
      closed: true
      properties:
        family:
          description: The font family name, which must match the name of the font
            on the foundry website.
          schema: string
        weight:
          description: The font weights to include.
          maybeArrayOf:
            ref: brand-font-weight
          default: [400, 700]
        style:
          description: The font styles to include.
          maybeArrayOf:
            ref: brand-font-style
          default: [normal, italic]
        display:
          description: >
            The font display method, determines how a font face is font face is shown
            depending on its download status and readiness for use.
          enum: [auto, block, swap, fallback, optional]
          default: swap

- id: brand-font-family
  description: >
    A locally-installed font family name. When used, the end-user is responsible
    for ensuring that the font is installed on their system.
  schema: string

- id: brand-font-file
  description: A method for providing font files directly, either locally or from
    an online location.
  object:
    closed: true
    properties:
      source:
        enum: [file]
      family:
        description: The font family name.
        schema: string
      files:
        arrayOf:
          anyOf:
          - path
          - schema:
              object:
                properties:
                  path:
                    schema: path
                    description: >
                      The path to the font file. This can be a local path or a URL.
                  weight:
                    ref: brand-font-weight
                  style:
                    ref: brand-font-style
                required: [path]
                    # We might want to eventually support these but not on 1.0
                    #
                    # display:
                    #   description: >
                    #     The font display method, determines how a font face is font face is shown
                    #     depending on its download status and readiness for use.
                    #   enum: [auto, block, swap, fallback, optional]
                    #   default: swap
                    # unicode-range:
                    #   description: >
                    #     The range of unicode characters included in the font. Examples:
                    #     - `U+0025-00FF` includes all characters from `U+0025` to `U+00FF`.
                    #     - `U+0131,U+0152-0153` includes the characters `U+0131`, `U+0152`, and `U+0153`.
                    #   schema:
                    #     string:
                    #       pattern: '^U\+[0-9A-F]{4}(?:-[0-9A-F]{4})?(?:,U\+[0-9A-F]{4}(?:-[0-9A-F]{4})?)*$'
        description: >
          The font files to include. These can be local or online.
          Local file paths should be relative to the `brand.yml` file.
          Online paths should be complete URLs.
    required: [files, family, source]
- id: brand-font-google
  description: A font definition from Google Fonts.
  object:
    super:
      resolveRef: brand-font-common
    closed: true
    properties:
      source:
        enum: [google]
- id: brand-font-style
  description: A font style.
  enum: [normal, italic, oblique]
  default: normal

- id: brand-font-system
  description: A system font definition.
  object:
    super:
      resolveRef: brand-font-common
    closed: true
    properties:
      source:
        enum: [system]
- id: brand-font-weight
  description: A font weight.
  enum: [100, 200, 300, 400, 500, 600, 700, 800, 900, thin, extra-light, ultra-light,
    light, normal, regular, medium, semi-bold, demi-bold, bold, extra-bold, ultra-bold,
    black]
  default: 400

- id: brand-logo
  description: >
    Provide definitions and defaults for brand's logo in various formats and sizes.
  object:
    closed: true
    properties:
      images:
        description: A dictionary of named logo resources.
        schema:
          object:
            additionalProperties:
              schema: {ref: brand-logo-resource}
      small:
        description: >
          A link or path to the brand's small-sized logo or icon, or a link or path
          to both the light and dark versions.
        schema:
          ref: brand-string-light-dark
      medium:
        description: >
          A link or path to the brand's medium-sized logo, or a link or path
          to both the light and dark versions.
        schema:
          ref: brand-string-light-dark
      large:
        description: >
          A link or path to the brand's large- or full-sized logo, or a link or path
          to both the light and dark versions.
        schema:
          ref: brand-string-light-dark

- id: brand-logo-explicit-resource
  object:
    closed: true
    properties:
      path: path
      alt:
        schema: string
        description: >
          Alternative text for the logo, used for accessibility.
    required: [path]
- id: brand-logo-resource
  anyOf:
  - string
  - ref: brand-logo-explicit-resource

- id: brand-maybe-named-color
  description: >
    A color, which may be a named brand color.
  anyOf:
  - ref: brand-named-theme-color
  - schema: string

- id: brand-meta
  description: >
    Metadata for a brand, including the brand name and important links.
  object:
    closed: false
    properties:
      name:
        description: The brand name.
        anyOf:
        - string
        - object:
            properties:
              full:
                string:
                  description: The full, official or legal name of the company or
                    brand.
              short:
                string:
                  description: The short, informal, or common name of the company
                    or brand.
      link:
        description: >
          Important links for the brand, including social media links.
          If a single string, it is the brand's home page or website.
          Additional fields are allowed for internal use.
        anyOf:
        - string
        - object:
            properties:
              home:
                string:
                  description: The brand's home page or website.
              mastodon:
                string:
                  description: The brand's Mastodon URL.
              bluesky:
                string:
                  description: The brand's Bluesky URL.
              github:
                string:
                  description: The brand's GitHub URL.
              linkedin:
                string:
                  description: The brand's LinkedIn URL.
              twitter:
                string:
                  description: The brand's Twitter URL.
              facebook:
                string:
                  description: The brand's Facebook URL.

- id: brand-named-font
  description: Names of customizeable fonts
  enum: [base, headings, monospace]
- id: brand-named-logo
  description: Names of customizeable logos
  enum: [small, medium, large]
- id: brand-named-theme-color
  description: >
    A named brand color, taken either from `color.theme` or `color.palette` (in that
    order).
  enum: [foreground, background, primary, secondary, tertiary, success, info, warning,
    danger, light, dark, link]
- id: brand-string-light-dark
  anyOf:
  - string
  - object:
      closed: true
      properties:
        light:
          schema: string
          description: >
            A link or path to the brand's light-colored logo or icon.
        dark:
          schema: string
          description: >
            A link or path to the brand's dark-colored logo or icon.

- id: brand-typography
  description: Typography definitions for the brand.
  object:
    closed: true
    properties:
      fonts:
        description: Font files and definitions for the brand.
        arrayOf:
          ref: brand-font
      base:
        description: >
          The base font settings for the brand. These are used as the default for
          all text.
        ref: brand-typography-options-base
      headings:
        description: Settings for headings, or a string specifying the font family
          only.
        ref: brand-typography-options-headings
      monospace:
        description: Settings for monospace text, or a string specifying the font
          family only.
        ref: brand-typography-options-monospace
      monospace-inline:
        description: Settings for inline code, or a string specifying the font family
          only.
        ref: brand-typography-options-monospace-inline
      monospace-block:
        description: Settings for code blocks, or a string specifying the font family
          only.
        ref: brand-typography-options-monospace-block
      link:
        description: Settings for links.
        ref: brand-typography-options-link

- id: brand-typography-options-base
  description: Base typographic options.
  anyOf:
  - string
  - object:
      closed: true
      properties:
        family: string
        size: string
        weight:
          ref: brand-font-weight
        line-height:
          ref: line-height-number-string

- id: brand-typography-options-headings
  description: Typographic options for headings.
  anyOf:
  - string
  - object:
      closed: true
      properties:
        family: string
        weight:
          ref: brand-font-weight
        style:
          ref: brand-font-style
        color:
          ref: brand-maybe-named-color
        line-height:
          ref: line-height-number-string

- id: brand-typography-options-link
  description: Typographic options for inline monospace elements.
  anyOf:
  - string
  - object:
      closed: true
      properties:
        weight:
          ref: brand-font-weight
        color:
          ref: brand-maybe-named-color
        background-color:
          ref: brand-maybe-named-color
        decoration: string

- id: brand-typography-options-monospace
  description: Typographic options for monospace elements.
  anyOf:
  - string
  - object:
      closed: true
      properties:
        family: string
        size: string
        weight:
          ref: brand-font-weight
        color:
          ref: brand-maybe-named-color
        background-color:
          ref: brand-maybe-named-color

- id: brand-typography-options-monospace-block
  description: Typographic options for block monospace elements.
  anyOf:
  - string
  - object:
      closed: true
      properties:
        family: string
        size: string
        weight:
          ref: brand-font-weight
        color:
          ref: brand-maybe-named-color
        background-color:
          ref: brand-maybe-named-color
        line-height:
          ref: line-height-number-string

- id: brand-typography-options-monospace-inline
  description: Typographic options for inline monospace elements.
  anyOf:
  - string
  - object:
      closed: true
      properties:
        family: string
        size: string
        weight:
          ref: brand-font-weight
        color:
          ref: brand-maybe-named-color
        background-color:
          ref: brand-maybe-named-color

- id: line-height-number-string
  description: Line height
  anyOf: [number, string]
