{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/Classiccottrell/isometric-asset-harness/schema/blueprint.schema.json",
  "title": "IGAH blueprint",
  "description": "One asset, described as primitives on a tile footprint. Units are tiles; y is up; the footprint centre is the origin.",
  "type": "object",
  "required": ["id", "footprint", "parts"],
  "properties": {
    "$schema": { "type": "string" },
    "id": { "type": "string", "pattern": "^[a-z0-9_]+$", "description": "snake_case, used for file names" },
    "name": { "type": "string" },
    "category": { "type": "string", "examples": ["rides", "scenery", "buildings", "paths", "fences"] },
    "footprint": {
      "type": "array", "items": { "type": "integer", "minimum": 1, "maximum": 8 }, "minItems": 2, "maxItems": 2,
      "description": "[x, z] in whole tiles"
    },
    "occupancy": {
      "type": "array", "items": { "type": "array", "items": { "enum": [0, 1] } },
      "description": "Rows run along z, columns along x. 1 = the tile is blocked. Defaults to all 1."
    },
    "render": {
      "type": "object",
      "description": "Drawing options that belong to the asset and win over CLI/sandbox settings (e.g. ground tiles: no outline, no shadow).",
      "additionalProperties": false,
      "properties": {
        "outline": { "enum": [0, 4, 8] },
        "shadow": { "enum": ["checker", "solid", "none"] },
        "shadeLevels": { "type": "integer", "minimum": 0 },
        "look": { "enum": ["rich", "flat"] }
      }
    },
    "anchors": {
      "type": "object",
      "description": "Named ground points, e.g. \"door\": where a walker stops to enter. [x, z] in tiles from the footprint centre, in authoring space; the manifest rotates them per view.",
      "additionalProperties": { "type": "array", "items": { "type": "number" }, "minItems": 2, "maxItems": 2 }
    },
    "groups": {
      "type": "object",
      "description": "Named lists of parts that `use` can place, rotate and repeat.",
      "additionalProperties": { "type": "array", "items": { "$ref": "#/$defs/part" }, "minItems": 1 }
    },
    "parts": { "type": "array", "items": { "$ref": "#/$defs/part" }, "minItems": 1 }
  },
  "$defs": {
    "vec3": { "type": "array", "items": { "type": "number" }, "minItems": 3, "maxItems": 3 },
    "placement": {
      "type": "object",
      "properties": {
        "name": { "type": "string", "description": "Pick label in the parts map (e.g. roof, wall, door). Defaults to the placing group's name, then the shape." },
        "at": { "$ref": "#/$defs/vec3", "description": "Bottom-centre position [x, y, z]" },
        "rotate": { "type": "number", "description": "Degrees about the vertical axis" },
        "repeat": {
          "type": "object", "required": ["count", "step"],
          "properties": {
            "count": { "type": "integer", "minimum": 1, "maximum": 64 },
            "step": { "$ref": "#/$defs/vec3", "description": "Offset between copies, in the parent's frame. The part's own rotate turns each copy, not the spacing." }
          }
        }
      }
    },
    "part": {
      "oneOf": [
        {
          "allOf": [{ "$ref": "#/$defs/placement" }],
          "type": "object",
          "required": ["use"],
          "properties": {
            "use": { "type": "string", "description": "Name of a group in this blueprint, or a built-in detail kit piece (kit/window, kit/window_shuttered, kit/window_planter, kit/door, kit/lantern, kit/hanging_sign, kit/barrel, kit/crate, kit/bench, kit/flower_pot, kit/chimney)" },
            "scale": { "type": "number", "exclusiveMinimum": 0, "maximum": 8, "description": "Uniform scale for everything in the group" },
            "recolor": { "type": "object", "description": "Colour swaps inside the group, { \"#from\": \"#to\" }", "additionalProperties": { "type": "string", "pattern": "^#[0-9a-fA-F]{6}$" } }
          }
        },
        {
          "allOf": [{ "$ref": "#/$defs/placement" }],
          "type": "object",
          "required": ["shape", "size"],
          "properties": {
            "shape": { "enum": ["box", "pyramid", "cylinder", "cone", "gable", "wedge", "stairs", "arch", "model"] },
            "src": { "type": "string", "description": "model: path to a .glb file, relative to the repo root" },
            "size": { "allOf": [{ "$ref": "#/$defs/vec3" }], "description": "[width (x), height (y), depth (z)] in tiles" },
            "color": { "type": "string", "pattern": "^#[0-9a-fA-F]{6}$" },
            "pattern": { "enum": ["brick", "clapboard", "planks", "shingles", "paving", "cobble", "foliage", "speckle", "ripple"], "description": "Pixel-scale surface texture, drawn on the face plane" },
            "pitch": { "type": "number", "description": "Degrees: swings the part about a horizontal axis through pivotY; positive moves its lower end forward (+z)" },
            "roll": { "type": "number", "description": "Degrees: tips the part sideways about pivotY; positive leans toward +x" },
            "pivotY": { "type": "number", "description": "Hinge height above the part's base, in tiles (e.g. the hip for a leg)" },
            "patternSeed": { "type": "integer", "description": "Shifts the pattern in whole 12 px steps, for tile variants that don't repeat" },
            "segments": { "type": "integer", "minimum": 3, "description": "cylinder, cone, arch" },
            "top": { "type": "number", "minimum": 0, "description": "cone, pyramid: top scale, 0 = point" },
            "steps": { "type": "integer", "minimum": 1, "description": "stairs" },
            "thickness": { "type": "number", "minimum": 0, "description": "arch band thickness" }
          }
        }
      ]
    }
  }
}
