"""Option metadata: types, valid values, categories, and platform filters.

Descriptions come from `ghostty +show-config --docs` at runtime.
This module provides the structural metadata that can't be extracted from the CLI.
"""

from __future__ import annotations

import platform

# Ordered list of categories for tab display
CATEGORIES = [
    "Font",
    "Colors",
    "Cursor",
    "Window",
    "Background",
    "Input",
    "Shell",
    "Advanced",
]

# Schema for each Ghostty config option
# Types: string, boolean, enum, integer, float, color, path, duration, repeatable
SCHEMA: dict[str, dict] = {
    # ── Font ──────────────────────────────────────────────
    "font-family": {
        "type": "string",
        "default": "",
        "category": "Font",
        "repeatable": True,
        "hot_reload": False,
    },
    "font-family-bold": {
        "type": "string",
        "default": "",
        "category": "Font",
        "hot_reload": False,
    },
    "font-family-italic": {
        "type": "string",
        "default": "",
        "category": "Font",
        "hot_reload": False,
    },
    "font-family-bold-italic": {
        "type": "string",
        "default": "",
        "category": "Font",
        "hot_reload": False,
    },
    "font-style": {
        "type": "string",
        "default": "default",
        "category": "Font",
        "hot_reload": False,
    },
    "font-style-bold": {
        "type": "string",
        "default": "default",
        "category": "Font",
        "hot_reload": False,
    },
    "font-style-italic": {
        "type": "string",
        "default": "default",
        "category": "Font",
        "hot_reload": False,
    },
    "font-style-bold-italic": {
        "type": "string",
        "default": "default",
        "category": "Font",
        "hot_reload": False,
    },
    "font-synthetic-style": {
        "type": "string",
        "default": "bold,italic,bold-italic",
        "category": "Font",
        "hot_reload": False,
    },
    "font-feature": {
        "type": "string",
        "default": "",
        "category": "Font",
        "repeatable": True,
        "hot_reload": False,
    },
    "font-size": {
        "type": "float",
        "default": "13",
        "category": "Font",
        "hot_reload": False,
    },
    "font-variation": {
        "type": "string",
        "default": "",
        "category": "Font",
        "repeatable": True,
        "hot_reload": False,
    },
    "font-variation-bold": {
        "type": "string",
        "default": "",
        "category": "Font",
        "repeatable": True,
        "hot_reload": False,
    },
    "font-variation-italic": {
        "type": "string",
        "default": "",
        "category": "Font",
        "repeatable": True,
        "hot_reload": False,
    },
    "font-variation-bold-italic": {
        "type": "string",
        "default": "",
        "category": "Font",
        "repeatable": True,
        "hot_reload": False,
    },
    "font-codepoint-map": {
        "type": "string",
        "default": "",
        "category": "Font",
        "repeatable": True,
        "hot_reload": False,
    },
    "font-thicken": {
        "type": "boolean",
        "default": "false",
        "category": "Font",
        "hot_reload": False,
    },
    "font-thicken-strength": {
        "type": "integer",
        "default": "255",
        "category": "Font",
        "hot_reload": False,
    },
    "font-shaping-break": {
        "type": "enum",
        "values": ["cursor", "grapheme", "word", "none"],
        "default": "cursor",
        "category": "Font",
        "hot_reload": False,
    },
    "alpha-blending": {
        "type": "enum",
        "values": ["native", "linear"],
        "default": "native",
        "category": "Font",
        "hot_reload": False,
    },
    "adjust-cell-width": {
        "type": "string",
        "default": "",
        "category": "Font",
        "hot_reload": False,
    },
    "adjust-cell-height": {
        "type": "string",
        "default": "",
        "category": "Font",
        "hot_reload": False,
    },
    "adjust-font-baseline": {
        "type": "string",
        "default": "",
        "category": "Font",
        "hot_reload": False,
    },
    "adjust-underline-position": {
        "type": "string",
        "default": "",
        "category": "Font",
        "hot_reload": False,
    },
    "adjust-underline-thickness": {
        "type": "string",
        "default": "",
        "category": "Font",
        "hot_reload": False,
    },
    "adjust-strikethrough-position": {
        "type": "string",
        "default": "",
        "category": "Font",
        "hot_reload": False,
    },
    "adjust-strikethrough-thickness": {
        "type": "string",
        "default": "",
        "category": "Font",
        "hot_reload": False,
    },
    "adjust-overline-position": {
        "type": "string",
        "default": "",
        "category": "Font",
        "hot_reload": False,
    },
    "adjust-overline-thickness": {
        "type": "string",
        "default": "",
        "category": "Font",
        "hot_reload": False,
    },
    "adjust-cursor-thickness": {
        "type": "string",
        "default": "",
        "category": "Font",
        "hot_reload": False,
    },
    "adjust-cursor-height": {
        "type": "string",
        "default": "",
        "category": "Font",
        "hot_reload": False,
    },
    "adjust-box-thickness": {
        "type": "string",
        "default": "",
        "category": "Font",
        "hot_reload": False,
    },
    "adjust-icon-height": {
        "type": "string",
        "default": "",
        "category": "Font",
        "hot_reload": False,
    },
    "grapheme-width-method": {
        "type": "enum",
        "values": ["unicode", "wcswidth"],
        "default": "unicode",
        "category": "Font",
        "hot_reload": False,
    },
    "freetype-load-flags": {
        "type": "string",
        "default": "hinting,no-force-autohint,no-monochrome,autohint",
        "category": "Font",
        "platform": "linux",
        "hot_reload": False,
    },
    "window-title-font-family": {
        "type": "string",
        "default": "",
        "category": "Font",
        "hot_reload": False,
    },
    # ── Colors ────────────────────────────────────────────
    "foreground": {
        "type": "color",
        "default": "#ffffff",
        "category": "Colors",
        "hot_reload": True,
    },
    "background": {
        "type": "color",
        "default": "#282c34",
        "category": "Colors",
        "hot_reload": True,
    },
    "bold-color": {
        "type": "color",
        "default": "",
        "category": "Colors",
        "hot_reload": True,
    },
    "selection-foreground": {
        "type": "color",
        "default": "",
        "category": "Colors",
        "hot_reload": True,
    },
    "selection-background": {
        "type": "color",
        "default": "",
        "category": "Colors",
        "hot_reload": True,
    },
    "minimum-contrast": {
        "type": "float",
        "default": "1",
        "category": "Colors",
        "hot_reload": True,
    },
    "palette": {
        "type": "string",
        "default": "",
        "category": "Colors",
        "repeatable": True,
        "hot_reload": True,
    },
    "bold-is-bright": {
        "type": "boolean",
        "default": "false",
        "category": "Colors",
        "hot_reload": True,
    },
    "faint-opacity": {
        "type": "float",
        "default": "0.5",
        "category": "Colors",
        "hot_reload": True,
    },
    "split-divider-color": {
        "type": "color",
        "default": "",
        "category": "Colors",
        "hot_reload": True,
    },
    "unfocused-split-fill": {
        "type": "color",
        "default": "",
        "category": "Colors",
        "hot_reload": True,
    },
    "osc-color-report-format": {
        "type": "enum",
        "values": ["none", "8-bit", "16-bit"],
        "default": "16-bit",
        "category": "Colors",
        "hot_reload": False,
    },
    "selection-clear-on-typing": {
        "type": "boolean",
        "default": "true",
        "category": "Colors",
        "hot_reload": False,
    },
    "selection-clear-on-copy": {
        "type": "boolean",
        "default": "false",
        "category": "Colors",
        "hot_reload": False,
    },
    # ── Cursor ────────────────────────────────────────────
    "cursor-style": {
        "type": "enum",
        "values": ["block", "bar", "underline", "block_hollow"],
        "default": "block",
        "category": "Cursor",
        "hot_reload": True,
    },
    "cursor-style-blink": {
        "type": "string",
        "default": "",
        "category": "Cursor",
        "hot_reload": True,
    },
    "cursor-color": {
        "type": "color",
        "default": "",
        "category": "Cursor",
        "hot_reload": True,
    },
    "cursor-text": {
        "type": "color",
        "default": "",
        "category": "Cursor",
        "hot_reload": True,
    },
    "cursor-opacity": {
        "type": "float",
        "default": "1",
        "category": "Cursor",
        "hot_reload": True,
    },
    "cursor-click-to-move": {
        "type": "boolean",
        "default": "true",
        "category": "Cursor",
        "hot_reload": False,
    },
    # ── Window ────────────────────────────────────────────
    "window-padding-x": {
        "type": "string",
        "default": "2",
        "category": "Window",
        "hot_reload": True,
    },
    "window-padding-y": {
        "type": "string",
        "default": "2",
        "category": "Window",
        "hot_reload": True,
    },
    "window-padding-balance": {
        "type": "boolean",
        "default": "false",
        "category": "Window",
        "hot_reload": True,
    },
    "window-padding-color": {
        "type": "enum",
        "values": ["background", "extend", "extend-always"],
        "default": "background",
        "category": "Window",
        "hot_reload": True,
    },
    "window-decoration": {
        "type": "enum",
        "values": ["auto", "client", "server", "none"],
        "default": "auto",
        "category": "Window",
        "hot_reload": False,
    },
    "window-width": {
        "type": "integer",
        "default": "0",
        "category": "Window",
        "hot_reload": False,
    },
    "window-height": {
        "type": "integer",
        "default": "0",
        "category": "Window",
        "hot_reload": False,
    },
    "window-step-resize": {
        "type": "boolean",
        "default": "false",
        "category": "Window",
        "hot_reload": False,
    },
    "window-inherit-font-size": {
        "type": "boolean",
        "default": "true",
        "category": "Window",
        "hot_reload": False,
    },
    "window-inherit-working-directory": {
        "type": "boolean",
        "default": "true",
        "category": "Window",
        "hot_reload": False,
    },
    "window-colorspace": {
        "type": "enum",
        "values": ["srgb", "display-p3"],
        "default": "srgb",
        "category": "Window",
        "hot_reload": False,
    },
    "window-vsync": {
        "type": "boolean",
        "default": "true",
        "category": "Window",
        "hot_reload": False,
    },
    "window-new-tab-position": {
        "type": "enum",
        "values": ["current", "end"],
        "default": "current",
        "category": "Window",
        "hot_reload": False,
    },
    "window-save-state": {
        "type": "enum",
        "values": ["default", "never", "always"],
        "default": "default",
        "category": "Window",
        "hot_reload": False,
    },
    "window-show-tab-bar": {
        "type": "enum",
        "values": ["auto", "always", "never"],
        "default": "auto",
        "category": "Window",
        "hot_reload": False,
    },
    "window-subtitle": {
        "type": "boolean",
        "default": "false",
        "category": "Window",
        "hot_reload": False,
    },
    "window-theme": {
        "type": "enum",
        "values": ["auto", "system", "dark", "light", "ghostty"],
        "default": "auto",
        "category": "Window",
        "hot_reload": True,
    },
    "window-titlebar-background": {
        "type": "color",
        "default": "",
        "category": "Window",
        "hot_reload": True,
    },
    "window-titlebar-foreground": {
        "type": "color",
        "default": "",
        "category": "Window",
        "hot_reload": True,
    },
    "window-position-x": {
        "type": "string",
        "default": "",
        "category": "Window",
        "hot_reload": False,
    },
    "window-position-y": {
        "type": "string",
        "default": "",
        "category": "Window",
        "hot_reload": False,
    },
    "maximize": {
        "type": "boolean",
        "default": "false",
        "category": "Window",
        "hot_reload": False,
    },
    "fullscreen": {
        "type": "boolean",
        "default": "false",
        "category": "Window",
        "hot_reload": False,
    },
    "title": {
        "type": "string",
        "default": "",
        "category": "Window",
        "hot_reload": False,
    },
    "title-report": {
        "type": "boolean",
        "default": "false",
        "category": "Window",
        "hot_reload": False,
    },
    "resize-overlay": {
        "type": "enum",
        "values": ["always", "never", "after-first"],
        "default": "after-first",
        "category": "Window",
        "hot_reload": False,
    },
    "resize-overlay-duration": {
        "type": "duration",
        "default": "750ms",
        "category": "Window",
        "hot_reload": False,
    },
    "resize-overlay-position": {
        "type": "enum",
        "values": ["center", "top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"],
        "default": "center",
        "category": "Window",
        "hot_reload": False,
    },
    "initial-window": {
        "type": "boolean",
        "default": "true",
        "category": "Window",
        "hot_reload": False,
    },
    "class": {
        "type": "string",
        "default": "",
        "category": "Window",
        "platform": "linux",
        "hot_reload": False,
    },
    # ── Background ────────────────────────────────────────
    "background-opacity": {
        "type": "float",
        "default": "1",
        "category": "Background",
        "hot_reload": True,
    },
    "background-opacity-cells": {
        "type": "boolean",
        "default": "false",
        "category": "Background",
        "hot_reload": True,
    },
    "background-blur": {
        "type": "string",
        "default": "false",
        "category": "Background",
        "hot_reload": True,
    },
    "background-image": {
        "type": "path",
        "default": "",
        "category": "Background",
        "hot_reload": True,
    },
    "background-image-opacity": {
        "type": "float",
        "default": "1",
        "category": "Background",
        "hot_reload": True,
    },
    "background-image-position": {
        "type": "enum",
        "values": ["center", "top-left", "top-center", "top-right", "left", "right", "bottom-left", "bottom-center", "bottom-right"],
        "default": "center",
        "category": "Background",
        "hot_reload": True,
    },
    "background-image-fit": {
        "type": "enum",
        "values": ["contain", "cover", "stretch", "fill", "none"],
        "default": "contain",
        "category": "Background",
        "hot_reload": True,
    },
    "background-image-repeat": {
        "type": "boolean",
        "default": "false",
        "category": "Background",
        "hot_reload": True,
    },
    "unfocused-split-opacity": {
        "type": "float",
        "default": "0.7",
        "category": "Background",
        "hot_reload": True,
    },
    # ── Input ─────────────────────────────────────────────
    "mouse-hide-while-typing": {
        "type": "boolean",
        "default": "false",
        "category": "Input",
        "hot_reload": False,
    },
    "mouse-scroll-multiplier": {
        "type": "string",
        "default": "precision:1,discrete:3",
        "category": "Input",
        "hot_reload": False,
    },
    "mouse-shift-capture": {
        "type": "boolean",
        "default": "false",
        "category": "Input",
        "hot_reload": False,
    },
    "focus-follows-mouse": {
        "type": "boolean",
        "default": "false",
        "category": "Input",
        "hot_reload": False,
    },
    "click-repeat-interval": {
        "type": "integer",
        "default": "0",
        "category": "Input",
        "hot_reload": False,
    },
    "clipboard-read": {
        "type": "enum",
        "values": ["allow", "deny", "ask"],
        "default": "ask",
        "category": "Input",
        "hot_reload": False,
    },
    "clipboard-write": {
        "type": "enum",
        "values": ["allow", "deny", "ask"],
        "default": "allow",
        "category": "Input",
        "hot_reload": False,
    },
    "clipboard-paste-protection": {
        "type": "boolean",
        "default": "true",
        "category": "Input",
        "hot_reload": False,
    },
    "clipboard-paste-bracketed-safe": {
        "type": "boolean",
        "default": "true",
        "category": "Input",
        "hot_reload": False,
    },
    "clipboard-trim-trailing-spaces": {
        "type": "boolean",
        "default": "true",
        "category": "Input",
        "hot_reload": False,
    },
    "copy-on-select": {
        "type": "boolean",
        "default": "true",
        "category": "Input",
        "hot_reload": False,
    },
    "scrollback-limit": {
        "type": "integer",
        "default": "10000000",
        "category": "Input",
        "hot_reload": False,
    },
    "scroll-to-bottom": {
        "type": "string",
        "default": "keystroke,no-output",
        "category": "Input",
        "hot_reload": False,
    },
    "link-url": {
        "type": "boolean",
        "default": "true",
        "category": "Input",
        "hot_reload": False,
    },
    "link-previews": {
        "type": "boolean",
        "default": "true",
        "category": "Input",
        "hot_reload": False,
    },
    "right-click-action": {
        "type": "enum",
        "values": ["context-menu", "paste"],
        "default": "context-menu",
        "category": "Input",
        "hot_reload": False,
    },
    "bell-audio-path": {
        "type": "path",
        "default": "",
        "category": "Input",
        "hot_reload": False,
    },
    "bell-audio-volume": {
        "type": "float",
        "default": "0.5",
        "category": "Input",
        "hot_reload": False,
    },
    "bell-features": {
        "type": "string",
        "default": "no-system,no-audio,attention,title,no-border",
        "category": "Input",
        "hot_reload": False,
    },
    "desktop-notifications": {
        "type": "boolean",
        "default": "true",
        "category": "Input",
        "hot_reload": False,
    },
    "app-notifications": {
        "type": "string",
        "default": "clipboard-copy,config-reload",
        "category": "Input",
        "hot_reload": False,
    },
    "keybind": {
        "type": "string",
        "default": "",
        "category": "Input",
        "repeatable": True,
        "hot_reload": False,
    },
    "input": {
        "type": "string",
        "default": "",
        "category": "Input",
        "repeatable": True,
        "hot_reload": False,
    },
    # ── Shell ─────────────────────────────────────────────
    "command": {
        "type": "string",
        "default": "",
        "category": "Shell",
        "hot_reload": False,
    },
    "initial-command": {
        "type": "string",
        "default": "",
        "category": "Shell",
        "hot_reload": False,
    },
    "wait-after-command": {
        "type": "boolean",
        "default": "false",
        "category": "Shell",
        "hot_reload": False,
    },
    "abnormal-command-exit-runtime": {
        "type": "integer",
        "default": "250",
        "category": "Shell",
        "hot_reload": False,
    },
    "shell-integration": {
        "type": "enum",
        "values": ["none", "detect", "bash", "elvish", "fish", "zsh"],
        "default": "detect",
        "category": "Shell",
        "hot_reload": False,
    },
    "shell-integration-features": {
        "type": "string",
        "default": "cursor,no-sudo,title,no-ssh-env,no-ssh-terminfo,path",
        "category": "Shell",
        "hot_reload": False,
    },
    "env": {
        "type": "string",
        "default": "",
        "category": "Shell",
        "repeatable": True,
        "hot_reload": False,
    },
    "working-directory": {
        "type": "path",
        "default": "",
        "category": "Shell",
        "hot_reload": False,
    },
    "term": {
        "type": "string",
        "default": "xterm-ghostty",
        "category": "Shell",
        "hot_reload": False,
    },
    "enquiry-response": {
        "type": "string",
        "default": "",
        "category": "Shell",
        "hot_reload": False,
    },
    "vt-kam-allowed": {
        "type": "boolean",
        "default": "false",
        "category": "Shell",
        "hot_reload": False,
    },
    "undo-timeout": {
        "type": "duration",
        "default": "5s",
        "category": "Shell",
        "hot_reload": False,
    },
    # ── Advanced ──────────────────────────────────────────
    "theme": {
        "type": "string",
        "default": "",
        "category": "Advanced",
        "hot_reload": True,
    },
    "image-storage-limit": {
        "type": "integer",
        "default": "320000000",
        "category": "Advanced",
        "hot_reload": False,
    },
    "custom-shader": {
        "type": "path",
        "default": "",
        "category": "Advanced",
        "repeatable": True,
        "hot_reload": True,
    },
    "custom-shader-animation": {
        "type": "boolean",
        "default": "true",
        "category": "Advanced",
        "hot_reload": True,
    },
    "config-default-files": {
        "type": "boolean",
        "default": "true",
        "category": "Advanced",
        "hot_reload": False,
    },
    "config-file": {
        "type": "path",
        "default": "",
        "category": "Advanced",
        "repeatable": True,
        "hot_reload": False,
    },
    "confirm-close-surface": {
        "type": "boolean",
        "default": "true",
        "category": "Advanced",
        "hot_reload": False,
    },
    "quit-after-last-window-closed": {
        "type": "boolean",
        "default": "false",
        "category": "Advanced",
        "hot_reload": False,
    },
    "quit-after-last-window-closed-delay": {
        "type": "duration",
        "default": "",
        "category": "Advanced",
        "hot_reload": False,
    },
    "auto-update": {
        "type": "enum",
        "values": ["off", "check", "download"],
        "default": "",
        "category": "Advanced",
        "platform": "macos",
        "hot_reload": False,
    },
    "auto-update-channel": {
        "type": "enum",
        "values": ["stable", "tip"],
        "default": "",
        "category": "Advanced",
        "platform": "macos",
        "hot_reload": False,
    },
    "async-backend": {
        "type": "enum",
        "values": ["auto", "io_uring", "epoll", "kqueue"],
        "default": "auto",
        "category": "Advanced",
        "hot_reload": False,
    },
    "command-palette-entry": {
        "type": "string",
        "default": "",
        "category": "Advanced",
        "repeatable": True,
        "hot_reload": False,
    },
    "quick-terminal-animation-duration": {
        "type": "float",
        "default": "0.2",
        "category": "Advanced",
        "hot_reload": False,
    },
    "quick-terminal-autohide": {
        "type": "boolean",
        "default": "true",
        "category": "Advanced",
        "hot_reload": False,
    },
    "quick-terminal-keyboard-interactivity": {
        "type": "enum",
        "values": ["none", "exclusive", "on-demand"],
        "default": "on-demand",
        "category": "Advanced",
        "hot_reload": False,
    },
    "quick-terminal-position": {
        "type": "enum",
        "values": ["top", "bottom", "left", "right", "center"],
        "default": "top",
        "category": "Advanced",
        "hot_reload": False,
    },
    "quick-terminal-screen": {
        "type": "enum",
        "values": ["main", "cursor", "macos-menu-bar"],
        "default": "main",
        "category": "Advanced",
        "hot_reload": False,
    },
    "quick-terminal-space-behavior": {
        "type": "enum",
        "values": ["move", "remain"],
        "default": "move",
        "category": "Advanced",
        "hot_reload": False,
    },
    # macOS-specific
    "macos-option-as-alt": {
        "type": "enum",
        "values": ["false", "true", "left", "right"],
        "default": "",
        "category": "Advanced",
        "platform": "macos",
        "hot_reload": False,
    },
    "macos-icon": {
        "type": "enum",
        "values": ["official", "custom-style"],
        "default": "official",
        "category": "Advanced",
        "platform": "macos",
        "hot_reload": False,
    },
    "macos-icon-frame": {
        "type": "enum",
        "values": [
            "aluminum", "beige", "plastic", "chrome",
        ],
        "default": "aluminum",
        "category": "Advanced",
        "platform": "macos",
        "hot_reload": False,
    },
    "macos-icon-ghost-color": {
        "type": "color",
        "default": "",
        "category": "Advanced",
        "platform": "macos",
        "hot_reload": False,
    },
    "macos-icon-screen-color": {
        "type": "color",
        "default": "",
        "category": "Advanced",
        "platform": "macos",
        "hot_reload": False,
    },
    "macos-custom-icon": {
        "type": "path",
        "default": "",
        "category": "Advanced",
        "platform": "macos",
        "hot_reload": False,
    },
    "macos-titlebar-style": {
        "type": "enum",
        "values": ["native", "transparent", "tabs", "hidden"],
        "default": "transparent",
        "category": "Advanced",
        "platform": "macos",
        "hot_reload": False,
    },
    "macos-titlebar-proxy-icon": {
        "type": "enum",
        "values": ["visible", "hidden"],
        "default": "visible",
        "category": "Advanced",
        "platform": "macos",
        "hot_reload": False,
    },
    "macos-window-buttons": {
        "type": "enum",
        "values": ["visible", "hidden", "hidden-when-no-title"],
        "default": "visible",
        "category": "Advanced",
        "platform": "macos",
        "hot_reload": False,
    },
    "macos-window-shadow": {
        "type": "boolean",
        "default": "true",
        "category": "Advanced",
        "platform": "macos",
        "hot_reload": True,
    },
    "macos-auto-secure-input": {
        "type": "boolean",
        "default": "true",
        "category": "Advanced",
        "platform": "macos",
        "hot_reload": False,
    },
    "macos-secure-input-indication": {
        "type": "boolean",
        "default": "true",
        "category": "Advanced",
        "platform": "macos",
        "hot_reload": False,
    },
    "macos-non-native-fullscreen": {
        "type": "boolean",
        "default": "false",
        "category": "Advanced",
        "platform": "macos",
        "hot_reload": False,
    },
    "macos-hidden": {
        "type": "enum",
        "values": ["never", "always", "initial"],
        "default": "never",
        "category": "Advanced",
        "platform": "macos",
        "hot_reload": False,
    },
    "macos-shortcuts": {
        "type": "enum",
        "values": ["always", "never", "ask"],
        "default": "ask",
        "category": "Advanced",
        "platform": "macos",
        "hot_reload": False,
    },
    "macos-dock-drop-behavior": {
        "type": "enum",
        "values": ["new-window", "new-tab"],
        "default": "new-tab",
        "category": "Advanced",
        "platform": "macos",
        "hot_reload": False,
    },
    # GTK/Linux-specific
    "gtk-single-instance": {
        "type": "enum",
        "values": ["detect", "true", "false"],
        "default": "detect",
        "category": "Advanced",
        "platform": "linux",
        "hot_reload": False,
    },
    "gtk-tabs-location": {
        "type": "enum",
        "values": ["top", "bottom", "left", "right", "hidden"],
        "default": "top",
        "category": "Advanced",
        "platform": "linux",
        "hot_reload": False,
    },
    "gtk-titlebar": {
        "type": "boolean",
        "default": "true",
        "category": "Advanced",
        "platform": "linux",
        "hot_reload": False,
    },
    "gtk-titlebar-hide-when-maximized": {
        "type": "boolean",
        "default": "false",
        "category": "Advanced",
        "platform": "linux",
        "hot_reload": False,
    },
    "gtk-titlebar-style": {
        "type": "enum",
        "values": ["native", "custom"],
        "default": "native",
        "category": "Advanced",
        "platform": "linux",
        "hot_reload": False,
    },
    "gtk-toolbar-style": {
        "type": "enum",
        "values": ["flat", "raised", "raised-border"],
        "default": "raised",
        "category": "Advanced",
        "platform": "linux",
        "hot_reload": False,
    },
    "gtk-wide-tabs": {
        "type": "boolean",
        "default": "true",
        "category": "Advanced",
        "platform": "linux",
        "hot_reload": False,
    },
    "gtk-custom-css": {
        "type": "path",
        "default": "",
        "category": "Advanced",
        "platform": "linux",
        "repeatable": True,
        "hot_reload": False,
    },
    "gtk-opengl-debug": {
        "type": "boolean",
        "default": "false",
        "category": "Advanced",
        "platform": "linux",
        "hot_reload": False,
    },
    "gtk-quick-terminal-layer": {
        "type": "enum",
        "values": ["top", "bottom", "overlay", "background"],
        "default": "top",
        "category": "Advanced",
        "platform": "linux",
        "hot_reload": False,
    },
    "gtk-quick-terminal-namespace": {
        "type": "string",
        "default": "ghostty-quick-terminal",
        "category": "Advanced",
        "platform": "linux",
        "hot_reload": False,
    },
    "linux-cgroup": {
        "type": "enum",
        "values": ["never", "always", "single-instance"],
        "default": "never",
        "category": "Advanced",
        "platform": "linux",
        "hot_reload": False,
    },
    "linux-cgroup-hard-fail": {
        "type": "boolean",
        "default": "false",
        "category": "Advanced",
        "platform": "linux",
        "hot_reload": False,
    },
    "linux-cgroup-memory-limit": {
        "type": "integer",
        "default": "",
        "category": "Advanced",
        "platform": "linux",
        "hot_reload": False,
    },
    "linux-cgroup-processes-limit": {
        "type": "integer",
        "default": "",
        "category": "Advanced",
        "platform": "linux",
        "hot_reload": False,
    },
    "x11-instance-name": {
        "type": "string",
        "default": "",
        "category": "Advanced",
        "platform": "linux",
        "hot_reload": False,
    },
}


def current_platform() -> str:
    """Return 'macos' or 'linux'."""
    return "macos" if platform.system() == "Darwin" else "linux"


def get_options_for_category(category: str, plat: str | None = None) -> list[tuple[str, dict]]:
    """Return list of (option_name, meta) for a category, filtered by platform."""
    if plat is None:
        plat = current_platform()
    result = []
    for name, meta in SCHEMA.items():
        if meta["category"] != category:
            continue
        opt_platform = meta.get("platform")
        if opt_platform and opt_platform != plat:
            continue
        result.append((name, meta))
    return result


def is_hot_reloadable(option_name: str) -> bool:
    """Check if an option supports live reload via SIGUSR2."""
    meta = SCHEMA.get(option_name)
    return meta.get("hot_reload", False) if meta else False


def is_repeatable(option_name: str) -> bool:
    """Check if an option can have multiple values."""
    meta = SCHEMA.get(option_name)
    return meta.get("repeatable", False) if meta else False
