{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://booplex.com/screenslop/design-profile.schema.json",
  "title": "Screenslop Design Profile",
  "type": "object",
  "required": ["schemaVersion", "project", "tokens", "components", "screenTypes", "stateSemantics", "reviewRules", "freshness"],
  "properties": {
    "schemaVersion": { "const": 1 },
    "project": {
      "type": "object",
      "required": ["name", "platform"],
      "properties": {
        "name": { "type": "string" },
        "platform": { "enum": ["ios", "macos", "watchos", "tvos", "visionos", "apple"] },
        "appCategory": { "type": ["string", "null"] },
        "audience": { "type": "array", "items": { "type": "string" } },
        "tone": { "type": "array", "items": { "type": "string" } }
      }
    },
    "sources": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["path", "kind", "hash"],
        "properties": {
          "path": { "type": "string" },
          "kind": { "type": "string" },
          "hash": { "type": "string" },
          "lastSeenAt": { "type": "string" }
        }
      }
    },
    "designSources": {
      "type": "array",
      "items": { "type": "string" }
    },
    "tokens": {
      "type": "object",
      "required": ["colors", "typography", "spacing", "cornerRadii", "materials", "icons"],
      "properties": {
        "colors": { "type": "array", "items": { "$ref": "#/$defs/token" } },
        "typography": { "type": "array", "items": { "$ref": "#/$defs/token" } },
        "spacing": { "type": "array", "items": { "$ref": "#/$defs/token" } },
        "cornerRadii": { "type": "array", "items": { "$ref": "#/$defs/token" } },
        "materials": { "type": "array", "items": { "$ref": "#/$defs/token" } },
        "icons": { "type": "array", "items": { "$ref": "#/$defs/token" } }
      }
    },
    "components": { "type": "array", "items": { "type": "object" } },
    "screenTypes": { "type": "array", "items": { "type": "object" } },
    "stateSemantics": { "type": "array", "items": { "type": "object" } },
    "reviewRules": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "pillar", "severity", "description"],
        "properties": {
          "id": { "type": "string" },
          "pillar": { "enum": ["accessibility", "hierarchy", "typography", "color", "layout", "interaction", "motion", "platform", "performance", "slop"] },
          "severity": { "enum": ["P0", "P1", "P2", "P3"] },
          "description": { "type": "string" }
        }
      }
    },
    "profileGaps": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "severity", "detail"],
        "properties": {
          "id": { "type": "string" },
          "severity": { "enum": ["P0", "P1", "P2", "P3"] },
          "detail": { "type": "string" }
        }
      }
    },
    "freshness": {
      "type": "object",
      "required": ["createdAt", "updatedAt", "sourceHash", "status"],
      "properties": {
        "createdAt": { "type": "string" },
        "updatedAt": { "type": "string" },
        "sourceHash": { "type": "string" },
        "status": { "enum": ["current", "stale", "missing-sources", "needs-review"] }
      }
    }
  },
  "$defs": {
    "token": {
      "type": "object",
      "required": ["name", "value", "source"],
      "properties": {
        "name": { "type": "string" },
        "value": { "type": "string" },
        "source": { "type": "string" },
        "sourceKind": { "type": ["string", "null"] },
        "layer": { "enum": ["primitive", "semantic", "component", "unknown"] },
        "resolvedValue": { "type": "string" },
        "aliasOf": { "type": "string" },
        "extraction": { "type": "string" },
        "confidence": { "enum": ["low", "medium", "high"] }
      },
      "additionalProperties": true
    }
  }
}
