{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:planets:system:v1",
  "title": "Planets System v1",
  "description": "Runtime also validates unique body IDs, parent references, acyclic hierarchy, star and visible-body presence, ring ordering, and safe texture URLs.",
  "type": "object",
  "required": [
    "schemaVersion",
    "id",
    "name",
    "bodies"
  ],
  "properties": {
    "schemaVersion": {
      "const": 1
    },
    "id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 1000
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 1000
    },
    "description": {
      "type": "string",
      "maxLength": 1000
    },
    "sources": {
      "type": "array",
      "maxItems": 32,
      "items": {
        "type": "object",
        "required": [
          "label",
          "url"
        ],
        "properties": {
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000
          },
          "url": {
            "type": "string",
            "minLength": 1,
            "description": "HTTP(S), relative to JSON document, or embedded PNG/JPEG/WebP data URL for textures"
          }
        }
      }
    },
    "bodies": {
      "type": "array",
      "minItems": 1,
      "maxItems": 256,
      "items": {
        "type": "object",
        "required": [
          "id",
          "name",
          "kind",
          "radius"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9_-]{1,80}$"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000
          },
          "kind": {
            "enum": [
              "star",
              "planet",
              "moon",
              "body"
            ]
          },
          "visible": {
            "type": "boolean",
            "default": true
          },
          "radius": {
            "type": "number",
            "minimum": 0.001,
            "maximum": 10000
          },
          "color": {
            "type": "string",
            "pattern": "^#[0-9a-fA-F]{6}$"
          },
          "position": {
            "type": "array",
            "minItems": 3,
            "maxItems": 3,
            "items": {
              "type": "number",
              "minimum": -100000,
              "maximum": 100000
            }
          },
          "luminosity": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000,
            "default": 1
          },
          "spinPeriodYears": {
            "type": "number",
            "minimum": -1000000.0,
            "maximum": 1000000.0,
            "default": 0
          },
          "spinPhaseDeg": {
            "type": "number",
            "default": 0
          },
          "heightScale": {
            "type": "number",
            "minimum": 0,
            "maximum": 0.2,
            "default": 0
          },
          "textures": {
            "type": "object",
            "properties": {
              "diffuse": {
                "type": "string",
                "minLength": 1,
                "description": "HTTP(S), relative to JSON document, or embedded PNG/JPEG/WebP data URL for textures"
              },
              "height": {
                "type": "string",
                "minLength": 1,
                "description": "HTTP(S), relative to JSON document, or embedded PNG/JPEG/WebP data URL for textures"
              },
              "night": {
                "type": "string",
                "minLength": 1,
                "description": "HTTP(S), relative to JSON document, or embedded PNG/JPEG/WebP data URL for textures"
              }
            }
          },
          "orbit": {
            "type": "object",
            "required": [
              "parent",
              "semiMajorAxis",
              "periodYears"
            ],
            "properties": {
              "parent": {
                "type": "string"
              },
              "semiMajorAxis": {
                "type": "number",
                "minimum": 0.001,
                "maximum": 100000.0
              },
              "periodYears": {
                "type": "number",
                "minimum": 1e-06,
                "maximum": 1000000000.0
              },
              "eccentricity": {
                "type": "number",
                "minimum": 0,
                "maximum": 0.95,
                "default": 0
              },
              "inclinationDeg": {
                "type": "number",
                "default": 0
              },
              "ascendingNodeDeg": {
                "type": "number",
                "default": 0
              },
              "argumentOfPeriapsisDeg": {
                "type": "number",
                "default": 0
              },
              "phaseDeg": {
                "type": "number",
                "default": 0
              }
            }
          },
          "rings": {
            "type": "object",
            "required": [
              "innerRadius",
              "outerRadius"
            ],
            "properties": {
              "innerRadius": {
                "type": "number",
                "minimum": 0.001,
                "maximum": 100000.0
              },
              "outerRadius": {
                "type": "number",
                "minimum": 0.001,
                "maximum": 100000.0
              },
              "color": {
                "type": "string",
                "pattern": "^#[0-9a-fA-F]{6}$"
              },
              "tiltDeg": {
                "type": "number",
                "default": 0
              }
            }
          },
          "info": {
            "type": "object",
            "properties": {
              "summary": {
                "type": "string",
                "maxLength": 1000
              },
              "facts": {
                "type": "array",
                "maxItems": 12,
                "items": {
                  "type": "object",
                  "required": [
                    "label",
                    "value"
                  ],
                  "properties": {
                    "label": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 1000
                    },
                    "value": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 1000
                    }
                  }
                }
              }
            }
          },
          "clouds": {
            "type": "object",
            "required": [
              "texture"
            ],
            "properties": {
              "texture": {
                "type": "string",
                "minLength": 1
              },
              "altitude": {
                "type": "number",
                "minimum": 0.001,
                "maximum": 0.5,
                "default": 0.0028
              },
              "opacity": {
                "type": "number",
                "minimum": 0,
                "maximum": 1,
                "default": 0.85
              },
              "spinPeriodYears": {
                "type": "number",
                "minimum": -1000000.0,
                "maximum": 1000000.0
              }
            }
          },
          "physical": {
            "type": "object",
            "required": [
              "radiusKm"
            ],
            "properties": {
              "radiusKm": {
                "type": "number",
                "minimum": 0.001,
                "maximum": 10000000000.0
              },
              "orbitKm": {
                "type": "number",
                "minimum": 0.001,
                "maximum": 1000000000000000.0
              }
            }
          },
          "atmosphere": {
            "type": "object",
            "properties": {
              "color": {
                "type": "string",
                "pattern": "^#[0-9a-fA-F]{6}$"
              },
              "strength": {
                "type": "number",
                "minimum": 0,
                "maximum": 1
              }
            }
          },
          "material": {
            "type": "object",
            "properties": {
              "ocean": {
                "type": "boolean"
              },
              "roughness": {
                "type": "number",
                "minimum": 0.04,
                "maximum": 1
              }
            }
          },
          "stellarSurface": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean",
                "default": true
              },
              "speed": {
                "type": "number",
                "minimum": 0,
                "maximum": 4,
                "default": 0.6
              },
              "granulation": {
                "type": "number",
                "minimum": 0,
                "maximum": 1,
                "default": 0.45
              },
              "activity": {
                "type": "number",
                "minimum": 0,
                "maximum": 1,
                "default": 0.18
              },
              "seed": {
                "type": "number",
                "minimum": 0,
                "maximum": 1000000.0,
                "default": 1
              },
              "temperatureK": {
                "type": "number",
                "minimum": 0,
                "maximum": 40000,
                "default": 0
              },
              "cellScale": {
                "type": "number",
                "minimum": 6,
                "maximum": 240,
                "default": 48
              },
              "limbDarkening": {
                "type": "number",
                "minimum": 0,
                "maximum": 1,
                "default": 0.6
              }
            }
          }
        }
      }
    },
    "background": {
      "type": "object",
      "required": [
        "texture"
      ],
      "properties": {
        "texture": {
          "type": "string",
          "minLength": 1
        },
        "brightness": {
          "type": "number",
          "minimum": 0,
          "maximum": 3,
          "default": 0.65
        },
        "rotationDeg": {
          "type": "number",
          "default": 0
        }
      }
    },
    "overview": {
      "type": "object",
      "required": [
        "members"
      ],
      "properties": {
        "label": {
          "type": "string"
        },
        "members": {
          "type": "array",
          "minItems": 1,
          "maxItems": 256,
          "uniqueItems": true,
          "items": {
            "type": "string"
          }
        }
      }
    }
  }
}
