{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://linkbio.dev/schemas/theme.json",
  "title": "Theme document",
  "description": "A whole link-in-bio page as data: global settings, blocks, per-block style overrides and display rules.",
  "type": "object",
  "required": [
    "blocks"
  ],
  "properties": {
    "version": {
      "type": "integer",
      "const": 1
    },
    "meta": {
      "type": "object",
      "properties": {
        "title": {
          "type": "string"
        },
        "description": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "global": {
      "type": "object",
      "properties": {
        "theme": {
          "type": "object",
          "title": "Theme",
          "description": "Which values the page paints with, before anything else is changed.",
          "properties": {
            "mode": {
              "description": "Auto follows the reader's operating system. It is not a third palette — it resolves to one of the other two.",
              "type": "string",
              "enum": [
                "light",
                "dark",
                "auto"
              ],
              "default": "auto"
            },
            "preset": {
              "description": "A starting point, not a lock. Every value a preset sets stays editable.",
              "type": "string",
              "default": "neue"
            }
          },
          "additionalProperties": false
        },
        "background": {
          "type": "object",
          "title": "Background",
          "description": "The ground the whole page sits on.",
          "properties": {
            "style": {
              "description": "Theme uses the palette's own background, so it follows a light/dark switch.",
              "type": "string",
              "enum": [
                "token",
                "solid",
                "gradient",
                "image"
              ],
              "default": "token"
            },
            "color": {
              "description": "Colour",
              "type": "string",
              "default": "oklch(0.965 0 0)"
            },
            "from": {
              "description": "From",
              "type": "string",
              "default": "oklch(0.97 0.03 250)"
            },
            "to": {
              "description": "To",
              "type": "string",
              "default": "oklch(0.94 0.05 300)"
            },
            "angle": {
              "description": "Angle",
              "type": "number",
              "minimum": 0,
              "maximum": 360,
              "default": 160
            },
            "image": {
              "description": "Served from wherever you host it. The kit adds no request of its own.",
              "type": "string",
              "default": ""
            },
            "fit": {
              "description": "Fit",
              "type": "string",
              "enum": [
                "cover",
                "contain",
                "tile"
              ],
              "default": "cover"
            },
            "overlay": {
              "description": "Darkens the ground behind the text. Text over an image needs this to stay legible.",
              "type": "number",
              "minimum": 0,
              "maximum": 100,
              "default": 0
            },
            "attachment": {
              "description": "Scrolls",
              "type": "boolean",
              "default": true
            }
          },
          "additionalProperties": false
        },
        "typography": {
          "type": "object",
          "title": "Typography",
          "description": "One family at two temperaments, sized from a single ratio.",
          "properties": {
            "sans": {
              "description": "Family",
              "type": "string",
              "enum": [
                "kit",
                "system",
                "humanist",
                "grotesque",
                "rounded",
                "serif",
                "slab",
                "mono"
              ],
              "default": "kit"
            },
            "baseSize": {
              "description": "Base size",
              "type": "number",
              "minimum": 13,
              "maximum": 22,
              "default": 17
            },
            "scale": {
              "description": "The ratio between one step and the next. 1.15 is a minor third; 1.25 is a major third and gets loud quickly.",
              "type": "number",
              "minimum": 1.05,
              "maximum": 1.45,
              "default": 1.15
            },
            "lineHeight": {
              "description": "Line height",
              "type": "number",
              "minimum": 1.2,
              "maximum": 2,
              "default": 1.7
            },
            "headingWeight": {
              "description": "Aeonik ships 400 and 500. Heavier weights are synthesised by the browser and will look coarse.",
              "type": "string",
              "enum": [
                400,
                500,
                600,
                700
              ],
              "default": 500
            },
            "bodyWeight": {
              "description": "Body weight",
              "type": "string",
              "enum": [
                300,
                400,
                500
              ],
              "default": 400
            },
            "tracking": {
              "description": "Applied to display sizes only. Body text at a tracked size is harder to read, not more designed.",
              "type": "number",
              "minimum": -3,
              "maximum": 4,
              "default": 0
            },
            "caps": {
              "description": "Uppercase headings",
              "type": "boolean",
              "default": false
            }
          },
          "additionalProperties": false
        },
        "palette": {
          "type": "object",
          "title": "Colour palette",
          "description": "One brand colour, and how far its hue reaches into the neutrals.",
          "properties": {
            "primary": {
              "description": "The filled action. Its ink is chosen for you by measured contrast, not picked.",
              "type": "string",
              "default": "oklch(0.18 0 0)"
            },
            "onPrimary": {
              "description": "Auto measures white and near-black against the fill and takes whichever clears 4.5:1.",
              "type": "string",
              "default": "auto"
            },
            "tintHue": {
              "description": "Neutral hue",
              "type": "number",
              "minimum": 0,
              "maximum": 360,
              "default": 0
            },
            "tintChroma": {
              "description": "Bleeds a hue into the greys. A little reads as warmth; a lot reads as a colour cast.",
              "type": "number",
              "minimum": 0,
              "maximum": 0.03,
              "default": 0
            },
            "surfaceStep": {
              "description": "How far cards sit from the page. Zero keeps the kit's own values.",
              "type": "number",
              "minimum": -0.04,
              "maximum": 0.06,
              "default": 0
            },
            "outlineStrength": {
              "description": "Hairline weight",
              "type": "number",
              "minimum": -0.08,
              "maximum": 0.14,
              "default": 0
            }
          },
          "additionalProperties": false
        },
        "layout": {
          "type": "object",
          "title": "Layout",
          "description": "How blocks sit in the column.",
          "properties": {
            "align": {
              "description": "Alignment",
              "type": "string",
              "enum": [
                "start",
                "center",
                "end",
                "stretch"
              ],
              "default": "stretch"
            },
            "order": {
              "description": "Reverses the painted order only. The document order, and therefore the reading and tab order, is unchanged — which is why this is the wrong tool for reordering blocks.",
              "type": "string",
              "enum": [
                "column",
                "column-reverse"
              ],
              "default": "column"
            },
            "fullBleed": {
              "description": "Full-bleed media",
              "type": "boolean",
              "default": false
            }
          },
          "additionalProperties": false
        },
        "spacing": {
          "type": "object",
          "title": "Spacing",
          "description": "The rhythm between blocks, and how tight the whole page sits.",
          "properties": {
            "gap": {
              "description": "Block gap",
              "type": "number",
              "minimum": 0,
              "maximum": 48,
              "default": 12
            },
            "density": {
              "description": "Scales the internal padding of every component. It never shrinks type below its token size or a tap target below 44px.",
              "type": "string",
              "enum": [
                "compact",
                "default",
                "spacious"
              ],
              "default": "default"
            },
            "top": {
              "description": "Space above",
              "type": "number",
              "minimum": 0,
              "maximum": 160,
              "default": 40
            },
            "bottom": {
              "description": "Space below",
              "type": "number",
              "minimum": 0,
              "maximum": 160,
              "default": 64
            }
          },
          "additionalProperties": false
        },
        "container": {
          "type": "object",
          "title": "Container",
          "description": "How wide the reading column is allowed to get.",
          "properties": {
            "width": {
              "description": "A link page is read on a phone. Past about 720px the eye starts to lose the start of the next line.",
              "type": "number",
              "minimum": 320,
              "maximum": 960,
              "default": 600
            },
            "gutter": {
              "description": "Side gutter",
              "type": "number",
              "minimum": 0,
              "maximum": 48,
              "default": 16
            }
          },
          "additionalProperties": false
        },
        "radius": {
          "type": "object",
          "title": "Radius",
          "description": "Two families: what you press, and what contains.",
          "properties": {
            "controls": {
              "description": "Buttons, pills and fields.",
              "type": "number",
              "minimum": 0,
              "maximum": 999,
              "default": 999
            },
            "containers": {
              "description": "Cards, panels and media. Scaled as a family so the relationships between sizes survive.",
              "type": "number",
              "minimum": 0,
              "maximum": 40,
              "default": 24
            }
          },
          "additionalProperties": false
        },
        "shadow": {
          "type": "object",
          "title": "Shadows",
          "description": "Neue prefers a hairline to a shadow. Elevation is for things that genuinely float.",
          "properties": {
            "level": {
              "description": "Elevation",
              "type": "string",
              "enum": [
                "none",
                "hairline",
                "raised",
                "floating"
              ],
              "default": "hairline"
            },
            "strength": {
              "description": "Strength",
              "type": "number",
              "minimum": 20,
              "maximum": 260,
              "default": 100
            },
            "tintShadow": {
              "description": "Tint with primary",
              "type": "boolean",
              "default": false
            }
          },
          "additionalProperties": false
        },
        "custom": {
          "type": "object",
          "title": "Custom code",
          "description": "An escape hatch for anything the settings above cannot express. Applies to the whole page.",
          "properties": {
            "css": {
              "description": "Emitted after every generated rule, so it wins without !important. Not the same as a Code Snippet block, which displays code as content and never runs it.",
              "type": "string",
              "default": ""
            },
            "head": {
              "description": "Written into <head> of an exported page — meta tags, a font link, an analytics snippet. It is not applied inside the editor's preview, because the preview is not your page.",
              "type": "string",
              "default": ""
            }
          },
          "additionalProperties": false
        },
        "motion": {
          "type": "object",
          "title": "Motion",
          "description": "Movement that explains a change. Everything here yields to prefers-reduced-motion.",
          "properties": {
            "enabled": {
              "description": "Transitions",
              "type": "boolean",
              "default": true
            },
            "speed": {
              "description": "Speed",
              "type": "number",
              "minimum": 40,
              "maximum": 220,
              "default": 100
            },
            "easing": {
              "description": "Easing",
              "type": "string",
              "enum": [
                "ease",
                "ease-out",
                "ease-in-out",
                "ease-spring"
              ],
              "default": "ease"
            },
            "reveal": {
              "description": "Blocks fade up as they enter. Content is present without JavaScript and the effect is skipped entirely under a reduced-motion preference.",
              "type": "boolean",
              "default": false
            },
            "stagger": {
              "description": "Stagger",
              "type": "number",
              "minimum": 0,
              "maximum": 200,
              "default": 60
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "blocks": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "type"
        ],
        "additionalProperties": false,
        "properties": {
          "$id": {
            "type": "string",
            "description": "Stable across edits; per-block styles are scoped to it."
          },
          "$name": {
            "type": [
              "string",
              "null"
            ],
            "description": "What this block is called in the editor. Prefixed because seven components have a `name` prop."
          },
          "type": {
            "type": "string",
            "enum": [
              "accordion-links",
              "achievement-badges",
              "affiliate-card",
              "alert",
              "announcement-banner",
              "apple-music-embed",
              "audio-player",
              "availability",
              "avatar",
              "bio",
              "booking-widget",
              "buy-button",
              "calendar",
              "card",
              "card-link",
              "carousel",
              "click-count",
              "code-snippet",
              "command-palette",
              "comments",
              "contact-buttons",
              "container",
              "copy-link",
              "countdown",
              "coupon-banner",
              "course-card",
              "cover-banner",
              "digital-download",
              "donation-widget",
              "email-capture",
              "event-card",
              "expandable-section",
              "faq",
              "featured-link",
              "featured-product",
              "file-downloads",
              "floating-cta",
              "follow-buttons",
              "follower-count",
              "footer",
              "glass-button",
              "gradient-button",
              "grid",
              "grouped-links",
              "hero",
              "icon-link",
              "image-gallery",
              "language-switcher",
              "live-activity",
              "location",
              "markdown-block",
              "masonry",
              "membership-cta",
              "messaging-apps",
              "newsletter-signup",
              "partner-logos",
              "pdf-preview",
              "pinned-link",
              "podcast-player",
              "poll",
              "pricing-card",
              "primary-button",
              "product-card",
              "profile-header",
              "promo-banner",
              "pronouns",
              "qr-code",
              "quote-block",
              "rating",
              "recent-links",
              "rich-link-preview",
              "search",
              "secondary-button",
              "section",
              "share-widget",
              "social-counters",
              "social-icons",
              "social-proof",
              "split-layout",
              "spotify-embed",
              "stack",
              "status-indicator",
              "survey",
              "tabs",
              "testimonials",
              "theme-toggle",
              "timeline",
              "tip-jar",
              "trust-badges",
              "verified-badge",
              "video-embed",
              "view-count",
              "visitor-counter",
              "waitlist",
              "youtube-embed"
            ]
          },
          "tag": {
            "type": "string",
            "description": "Host element name. Defaults to div."
          },
          "props": {
            "type": "object",
            "description": "Component props. Validate against the component's own schema."
          },
          "style": {
            "type": "object",
            "description": "Per-block token overrides. Anything absent inherits from the page.",
            "properties": {
              "text": {
                "type": "object",
                "title": "Text",
                "description": "",
                "properties": {
                  "size": {
                    "description": "Size",
                    "type": "number",
                    "minimum": 70,
                    "maximum": 180,
                    "default": 100
                  },
                  "weight": {
                    "description": "Weight",
                    "type": "string",
                    "enum": [
                      "inherit",
                      400,
                      500,
                      600
                    ],
                    "default": "inherit"
                  },
                  "tracking": {
                    "description": "Tracking",
                    "type": "number",
                    "minimum": -4,
                    "maximum": 8,
                    "default": 0
                  },
                  "lineHeight": {
                    "description": "Line height",
                    "type": "number",
                    "minimum": 0,
                    "maximum": 2.4,
                    "default": 0
                  },
                  "transform": {
                    "description": "Case",
                    "type": "string",
                    "enum": [
                      "none",
                      "uppercase",
                      "capitalize"
                    ],
                    "default": "none"
                  }
                },
                "additionalProperties": false
              },
              "background": {
                "type": "object",
                "title": "Background",
                "description": "",
                "properties": {
                  "style": {
                    "description": "Fill",
                    "type": "string",
                    "enum": [
                      "inherit",
                      "solid",
                      "gradient",
                      "none"
                    ],
                    "default": "inherit"
                  },
                  "color": {
                    "description": "Colour",
                    "type": "string",
                    "default": "oklch(1 0 0)"
                  },
                  "from": {
                    "description": "From",
                    "type": "string",
                    "default": "oklch(0.75 0.14 250)"
                  },
                  "to": {
                    "description": "To",
                    "type": "string",
                    "default": "oklch(0.62 0.18 300)"
                  },
                  "angle": {
                    "description": "Angle",
                    "type": "number",
                    "minimum": 0,
                    "maximum": 360,
                    "default": 120
                  }
                },
                "additionalProperties": false
              },
              "colors": {
                "type": "object",
                "title": "Colours",
                "description": "",
                "properties": {
                  "text": {
                    "description": "Text",
                    "type": "string",
                    "default": ""
                  },
                  "secondary": {
                    "description": "Secondary text",
                    "type": "string",
                    "default": ""
                  },
                  "accent": {
                    "description": "The filled control inside this block. Its ink is measured, not chosen.",
                    "type": "string",
                    "default": ""
                  }
                },
                "additionalProperties": false
              },
              "border": {
                "type": "object",
                "title": "Border",
                "description": "",
                "properties": {
                  "width": {
                    "description": "Width",
                    "type": "number",
                    "minimum": 0,
                    "maximum": 6,
                    "default": 0
                  },
                  "color": {
                    "description": "Colour",
                    "type": "string",
                    "default": ""
                  },
                  "style": {
                    "description": "Style",
                    "type": "string",
                    "enum": [
                      "solid",
                      "dashed",
                      "dotted"
                    ],
                    "default": "solid"
                  }
                },
                "additionalProperties": false
              },
              "radius": {
                "type": "object",
                "title": "Radius",
                "description": "",
                "properties": {
                  "controls": {
                    "description": "Controls",
                    "type": [
                      "number",
                      "null"
                    ],
                    "minimum": 0,
                    "maximum": 999
                  },
                  "containers": {
                    "description": "Containers",
                    "type": [
                      "number",
                      "null"
                    ],
                    "minimum": 0,
                    "maximum": 40
                  }
                },
                "additionalProperties": false
              },
              "shadow": {
                "type": "object",
                "title": "Shadow",
                "description": "",
                "properties": {
                  "level": {
                    "description": "Elevation",
                    "type": "string",
                    "enum": [
                      "inherit",
                      "none",
                      "raised",
                      "floating"
                    ],
                    "default": "inherit"
                  },
                  "strength": {
                    "description": "Strength",
                    "type": "number",
                    "minimum": 20,
                    "maximum": 260,
                    "default": 100
                  }
                },
                "additionalProperties": false
              },
              "spacing": {
                "type": "object",
                "title": "Padding & margin",
                "description": "",
                "properties": {
                  "padding": {
                    "description": "Padding",
                    "type": "object",
                    "minimum": 0,
                    "maximum": 80
                  },
                  "margin": {
                    "description": "Margin",
                    "type": "object",
                    "minimum": -40,
                    "maximum": 80
                  }
                },
                "additionalProperties": false
              },
              "alignment": {
                "type": "object",
                "title": "Alignment",
                "description": "",
                "properties": {
                  "self": {
                    "description": "Block",
                    "type": "string",
                    "enum": [
                      "inherit",
                      "start",
                      "center",
                      "end",
                      "stretch"
                    ],
                    "default": "inherit"
                  },
                  "text": {
                    "description": "Text",
                    "type": "string",
                    "enum": [
                      "inherit",
                      "start",
                      "center",
                      "end"
                    ],
                    "default": "inherit"
                  },
                  "width": {
                    "description": "Width",
                    "type": "number",
                    "minimum": 30,
                    "maximum": 100,
                    "default": 100
                  }
                },
                "additionalProperties": false
              },
              "columns": {
                "type": "object",
                "title": "Columns",
                "description": "",
                "properties": {
                  "count": {
                    "description": "Columns",
                    "type": [
                      "number",
                      "null"
                    ],
                    "minimum": 1,
                    "maximum": 6
                  },
                  "gap": {
                    "description": "Column gap",
                    "type": [
                      "number",
                      "null"
                    ],
                    "minimum": 0,
                    "maximum": 40
                  }
                },
                "additionalProperties": false
              },
              "icon": {
                "type": "object",
                "title": "Icon",
                "description": "",
                "properties": {
                  "size": {
                    "description": "Size",
                    "type": [
                      "number",
                      "null"
                    ],
                    "minimum": 12,
                    "maximum": 40
                  },
                  "color": {
                    "description": "Colour",
                    "type": "string",
                    "default": ""
                  },
                  "stroke": {
                    "description": "Stroke",
                    "type": [
                      "number",
                      "null"
                    ],
                    "minimum": 1,
                    "maximum": 2.5
                  }
                },
                "additionalProperties": false
              },
              "thumbnail": {
                "type": "object",
                "title": "Thumbnail",
                "description": "",
                "properties": {
                  "ratio": {
                    "description": "Aspect ratio",
                    "type": "string",
                    "enum": [
                      "",
                      "1 / 1",
                      "4 / 3",
                      "3 / 2",
                      "16 / 9",
                      "21 / 9"
                    ],
                    "default": ""
                  },
                  "fit": {
                    "description": "Fit",
                    "type": "string",
                    "enum": [
                      "",
                      "cover",
                      "contain"
                    ],
                    "default": ""
                  },
                  "radius": {
                    "description": "Corner",
                    "type": [
                      "number",
                      "null"
                    ],
                    "minimum": 0,
                    "maximum": 40
                  }
                },
                "additionalProperties": false
              },
              "button": {
                "type": "object",
                "title": "Buttons",
                "description": "",
                "properties": {
                  "height": {
                    "description": "Never below 44px on a touch target — the kit keeps that floor regardless.",
                    "type": [
                      "number",
                      "null"
                    ],
                    "minimum": 36,
                    "maximum": 76
                  },
                  "padding": {
                    "description": "Side padding",
                    "type": [
                      "number",
                      "null"
                    ],
                    "minimum": 8,
                    "maximum": 48
                  },
                  "fullWidth": {
                    "description": "Full width",
                    "type": "boolean"
                  }
                },
                "additionalProperties": false
              },
              "animation": {
                "type": "object",
                "title": "Animation",
                "description": "",
                "properties": {
                  "reveal": {
                    "description": "Entrance",
                    "type": "string",
                    "enum": [
                      "inherit",
                      "none",
                      "fade",
                      "rise",
                      "scale"
                    ],
                    "default": "inherit"
                  },
                  "delay": {
                    "description": "Delay",
                    "type": "number",
                    "minimum": 0,
                    "maximum": 800,
                    "default": 0
                  },
                  "hover": {
                    "description": "On hover",
                    "type": "string",
                    "enum": [
                      "inherit",
                      "none",
                      "lift",
                      "press",
                      "glow"
                    ],
                    "default": "inherit"
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false
          },
          "rules": {
            "$ref": "#/$defs/rules"
          }
        }
      }
    }
  },
  "$defs": {
    "rules": {
      "type": "object",
      "description": "Whether this block is painted for a given reader.",
      "properties": {
        "visible": {
          "type": "boolean",
          "description": "false hides the block unconditionally."
        },
        "match": {
          "type": "string",
          "enum": [
            "all",
            "any"
          ],
          "default": "all"
        },
        "conditions": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "type"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "device",
                  "viewport",
                  "country",
                  "language",
                  "browser",
                  "os",
                  "scheme",
                  "schedule",
                  "weekday",
                  "hour",
                  "audience",
                  "tag"
                ]
              },
              "op": {
                "type": "string",
                "enum": [
                  "is",
                  "is not",
                  "at least",
                  "at most",
                  "starts with",
                  "between",
                  "before",
                  "after",
                  "has",
                  "does not have"
                ]
              },
              "value": {},
              "from": {},
              "to": {}
            }
          }
        }
      },
      "additionalProperties": false
    }
  }
}
