{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://graphic-fiction-studio.netlify.app/schema/brand.schema.json",
  "title": "Graphic fiction studio brand",
  "description": "Brand, voice, comic style and fixed cast for the graphic fiction studio. Format version 1.0. See docs/brand-json.md.",
  "type": "object",
  "required": ["formatVersion", "brand", "colours", "fonts", "voice", "cta", "comicStyle", "characters"],
  "properties": {
    "$schema": { "type": "string" },
    "formatVersion": { "const": "1.0" },
    "brand": {
      "type": "object",
      "required": ["name", "kicker", "line", "monogram"],
      "properties": {
        "name": { "type": "string", "minLength": 1, "description": "Full brand name, e.g. Craig Stanley Work." },
        "shortName": { "type": "string", "description": "Short form for running text and the footer." },
        "kicker": { "type": "string", "description": "Mono uppercase running header, e.g. CRAIG STANLEY · WORK." },
        "line": { "type": "string", "description": "Tagline, printed in the footer." },
        "monogram": { "type": "string", "maxLength": 4, "description": "Letters shown in the round mark." },
        "locale": { "type": "string", "default": "en-GB" }
      }
    },
    "colours": {
      "type": "object",
      "required": ["light", "dark"],
      "properties": { "light": { "$ref": "#/$defs/palette" }, "dark": { "$ref": "#/$defs/palette" } }
    },
    "fonts": {
      "type": "object",
      "required": ["display", "body", "mono"],
      "properties": {
        "display": { "type": "string", "description": "Headings and titles (upright serif in the default brand)." },
        "body": { "type": "string" },
        "mono": { "type": "string", "description": "Kickers, labels, meta lines." },
        "googleFontsUrl": { "type": "string", "pattern": "^https://fonts\\.googleapis\\.com/" }
      }
    },
    "voice": {
      "type": "object",
      "required": ["rules", "bannedWords"],
      "properties": {
        "rules": { "type": "array", "items": { "type": "string" }, "description": "Sent to the script writer with every request." },
        "bannedWords": { "type": "array", "items": { "type": "string" } }
      }
    },
    "cta": {
      "type": "object",
      "required": ["text", "url"],
      "properties": {
        "text": { "type": "string", "description": "Printed bottom right, next to the QR code." },
        "url": { "type": "string", "pattern": "^https?://", "description": "Encoded in the QR code." }
      }
    },
    "comicStyle": {
      "type": "object",
      "required": ["styleLock"],
      "properties": {
        "styleLock": { "type": "string", "minLength": 21, "description": "Added to every image request. Describe line, colour, setting, and say no text in images." },
        "lettering": { "enum": ["app"], "description": "Balloons and captions are lettered by the app on canvas." },
        "panelAspect": { "enum": ["1:1", "4:3", "3:4", "3:2", "16:9"] },
        "balloonFill": { "$ref": "#/$defs/hex" },
        "balloonInk": { "$ref": "#/$defs/hex" },
        "captionFill": { "$ref": "#/$defs/hex" }
      }
    },
    "characters": {
      "type": "array", "minItems": 1, "maxItems": 12,
      "items": {
        "type": "object",
        "required": ["id", "name", "age", "role", "visual", "palette", "personality", "speech"],
        "properties": {
          "id": { "type": "string", "pattern": "^[a-z0-9-]{1,32}$" },
          "name": { "type": "string" },
          "age": { "type": "number", "exclusiveMinimum": 0, "exclusiveMaximum": 120 },
          "role": { "type": "string" },
          "visual": { "type": "string", "description": "Fixed look: face, hair, build, one fixed outfit, a prop. Keep it to things an illustrator can see." },
          "palette": {
            "type": "object",
            "required": ["skin", "hair", "primary", "secondary", "accent"],
            "properties": {
              "skin": { "$ref": "#/$defs/hex" }, "hair": { "$ref": "#/$defs/hex" },
              "primary": { "$ref": "#/$defs/hex" }, "secondary": { "$ref": "#/$defs/hex" }, "accent": { "$ref": "#/$defs/hex" }
            }
          },
          "personality": { "type": "string" },
          "speech": { "type": "string" },
          "locked": { "type": "boolean", "default": false },
          "sheet": { "type": "string", "description": "Optional path or URL of a reference sheet image, relative to the site root." }
        }
      }
    }
  },
  "$defs": {
    "hex": { "type": "string", "pattern": "^#[0-9a-fA-F]{6}$" },
    "palette": {
      "type": "object",
      "required": ["field", "paper", "paper2", "hero", "ink", "muted", "line", "accent", "accentInk", "warn", "tileA", "tileB", "tileC", "tileD"],
      "additionalProperties": { "$ref": "#/$defs/hex" }
    }
  }
}
