{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://supercards.io/schemas/template-v1.json",
  "title": "SuperCards Template File",
  "description": "A reusable card template written by the SuperCards desktop app under {Library}/.supercards/templates/. Template elements mirror card elements plus an isPlaceholder flag. Unknown fields are ignored by readers. All timestamps are Unix epoch milliseconds.",
  "type": "object",
  "required": ["formatVersion", "id", "name", "style", "front", "back", "createdAt", "updatedAt"],
  "properties": {
    "$schema": {
      "type": "string",
      "description": "Reference to this schema."
    },
    "formatVersion": {
      "type": "string",
      "pattern": "^1\\.",
      "description": "Native template format version (currently \"1.0.0\")."
    },
    "id": { "type": "string" },
    "name": { "type": "string" },
    "description": { "type": "string" },
    "style": {
      "type": "object",
      "required": ["pattern", "color", "size"],
      "properties": {
        "pattern": {
          "type": "string",
          "enum": ["blank", "classic", "grid"]
        },
        "color": {
          "type": "string",
          "description": "Card background color as a hex string."
        },
        "size": {
          "type": "string",
          "enum": ["small", "medium", "large"],
          "description": "Canvas size: small 812×375, medium 844×390, large 956×440."
        }
      }
    },
    "front": { "$ref": "#/$defs/templateFace" },
    "back": { "$ref": "#/$defs/templateFace" },
    "createdAt": {
      "type": "integer",
      "description": "Unix epoch milliseconds."
    },
    "updatedAt": {
      "type": "integer",
      "description": "Unix epoch milliseconds."
    }
  },
  "$defs": {
    "templateFace": {
      "type": "object",
      "required": ["elements"],
      "properties": {
        "elements": {
          "type": "array",
          "items": { "$ref": "#/$defs/templateElement" }
        }
      }
    },
    "templateElement": {
      "type": "object",
      "required": ["id", "type", "content", "isPlaceholder", "x", "y", "width", "height", "zIndex"],
      "properties": {
        "id": { "type": "string" },
        "type": {
          "type": "string",
          "enum": ["text", "image"]
        },
        "content": { "type": "string" },
        "isPlaceholder": {
          "type": "boolean",
          "description": "True when the element is placeholder content the user replaces."
        },
        "x": { "type": "number" },
        "y": { "type": "number" },
        "width": { "type": "number" },
        "height": { "type": "number" },
        "zIndex": { "type": "integer" },
        "styles": {
          "type": "object",
          "properties": {
            "bold": { "type": "boolean" },
            "italic": { "type": "boolean" },
            "underline": { "type": "boolean" },
            "strikethrough": { "type": "boolean" },
            "fontSize": { "type": "integer" },
            "textAlign": {
              "type": "string",
              "enum": ["left", "center", "right"]
            },
            "color": { "type": "string" },
            "fontFamily": { "type": "string" }
          }
        }
      }
    }
  }
}
