{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "highlight-schema-v1",
  "title": "Highlight Schema",
  "description": "Schema for Bible verse highlights. Each file is associated with a specific translation. Supports import/export of user highlights.",

  "definitions": {
    "highlight": {
      "type": "object",
      "description": "A single highlight span within a verse",
      "properties": {
        "sc": {
          "type": "integer",
          "minimum": 0,
          "description": "Start character offset (0-indexed)"
        },
        "ec": {
          "type": "integer",
          "minimum": 0,
          "description": "End character offset (exclusive)"
        },
        "style": {
          "type": "integer",
          "minimum": 0,
          "description": "Style ID: 0=highlight, 1=underlineSolid, 2=underlineDashed, 3=underlineDotted"
        },
        "color": {
          "type": "string",
          "description": "Hex color code (e.g., 'FFCC00') or color name (e.g., 'yellow')"
        }
      },
      "required": ["sc", "ec", "style"]
    },

    "theme": {
      "type": "object",
      "description": "Theme/meaning associated with a color+style combination",
      "properties": {
        "color": {
          "type": "string",
          "description": "Hex color code (e.g., 'FFCC00')"
        },
        "style": {
          "type": "integer",
          "minimum": 0,
          "maximum": 3,
          "description": "Style ID: 0=highlight, 1=underlineSolid, 2=underlineDashed, 3=underlineDotted"
        },
        "name": {
          "type": "string",
          "description": "Short theme name (e.g., 'Promises', 'Commands')"
        },
        "description": {
          "type": "string",
          "description": "Optional longer description of what this color+style means"
        }
      },
      "required": ["color", "style", "name"]
    },

    "verseHighlights": {
      "type": "object",
      "description": "Highlights for a single verse",
      "properties": {
        "ref": {
          "type": "integer",
          "description": "Verse reference in BBCCCVVV format"
        },
        "highlights": {
          "type": "array",
          "items": { "$ref": "#/definitions/highlight" },
          "description": "Array of highlight spans for this verse"
        }
      },
      "required": ["ref", "highlights"]
    }
  },

  "type": "object",
  "properties": {
    "meta": {
      "type": "object",
      "description": "Highlight file metadata",
      "properties": {
        "schemaVersion": { "type": "string", "enum": ["1.0"], "description": "Schema version" },
        "id": { "type": "string", "description": "Unique identifier for this highlight set" },
        "type": { "type": "string", "const": "highlights" },
        "name": { "type": "string", "description": "Display name (e.g., 'My Highlights')" },
        "description": { "type": "string", "description": "Optional description of this highlight set" },
        "translationId": { "type": "string", "description": "Associated translation ID (e.g., 'ESV', 'BSBs')" },
        "created": { "type": "integer", "description": "Unix timestamp when created" },
        "lastModified": { "type": "integer", "description": "Unix timestamp of last modification" },
        "themes": {
          "type": "array",
          "items": { "$ref": "#/definitions/theme" },
          "description": "Optional themes associating meaning with color+style combinations"
        }
      },
      "required": ["schemaVersion", "id", "type", "translationId"]
    },

    "verses": {
      "type": "array",
      "items": { "$ref": "#/definitions/verseHighlights" },
      "description": "Array of verses with highlights"
    }
  },

  "required": ["meta", "verses"]
}
