/* ============================================================================
   Verso-DemoKit manual — modern theme
   Dark by default; light via <html data-theme="light"> (toggle button in page).
   ========================================================================== */

:root {
	color-scheme: dark;
	--bg:            #0b0d13;
	--surface:       #14171f;
	--surface-2:     #1a1e28;
	--border:        rgba(255, 255, 255, 0.075);
	--border-strong: rgba(255, 255, 255, 0.14);
	--text:          #cbd0d9;
	--text-strong:   #f5f7fb;
	--muted:         #868e9d;
	--accent:        #8b9bff;
	--accent-soft:   rgba(139, 155, 255, 0.14);
	--accent-line:   rgba(139, 155, 255, 0.30);
	--link:          #93a5ff;
	--link-hover:    #bcc7ff;
	--sel:           rgba(139, 155, 255, 0.28);
	--tok-string:    #86ca86;
	--tok-number:    #74b6f5;
	--tok-object:    #e39ec9;
	--tok-keyword:   #cb8f5a;
	--tok-builtin:   #d9bb73;
	--code-bg:       #0d1017;
	--code-fg:       #c3cad5;
	--shadow:        0 1px 2px rgba(0, 0, 0, 0.40), 0 12px 34px rgba(0, 0, 0, 0.32);
	--maxw:          64rem;
}

:root[data-theme="light"] {
	color-scheme: light;
	--bg:            #f7f8fa;
	--surface:       #ffffff;
	--surface-2:     #eef1f6;
	--border:        rgba(18, 21, 27, 0.10);
	--border-strong: rgba(18, 21, 27, 0.18);
	--text:          #333a45;
	--text-strong:   #10131a;
	--muted:         #626b79;
	--accent:        #5b5bd6;
	--accent-soft:   rgba(91, 91, 214, 0.10);
	--accent-line:   rgba(91, 91, 214, 0.28);
	--link:          #3a54d6;
	--link-hover:    #24379c;
	--sel:           rgba(91, 91, 214, 0.16);
	--tok-string:    #2f7d3a;
	--tok-number:    #1f6fb0;
	--tok-object:    #a2478a;
	--tok-keyword:   #b0561c;
	--tok-builtin:   #86680f;
	--code-bg:       #e8ecf3;
	--code-fg:       #2c3340;
	--shadow:        0 1px 2px rgba(18, 21, 27, 0.06), 0 10px 30px rgba(18, 21, 27, 0.09);
}

* { box-sizing: border-box; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

html { scroll-behavior: smooth; }

html, body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 16.5px;
	line-height: 1.7;
	overflow-wrap: break-word;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

body {
	max-width: var(--maxw);
	margin: 0 auto;
	padding: clamp(1.25rem, 4vw, 3.5rem);
	padding-top: 3.25rem; /* clearance for the fixed toggle buttons (drawer + theme) */
	-webkit-text-size-adjust: 100%;
	transition: background-color 0.3s ease, color 0.3s ease;
}

::selection { background: var(--sel); color: var(--text-strong); }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- typography ---------- */
h1, h2, h3, h4, h5 { color: var(--text-strong); line-height: 1.2; }
h1 {
	font-size: clamp(1.6rem, 1.1rem + 1.7vw, 2.1rem);
	font-weight: 800;
	letter-spacing: -0.03em;
	line-height: 1.1;
	margin: 0;
}
/* Page header: title + tagline on one baseline row, compact (sits level with the toggle). */
.pagehead {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	column-gap: 0.7rem;
	row-gap: 0.15rem;
	margin: 0 0 1.4rem;
}
.tagline {
	margin: 0;
	color: var(--muted);
	font-size: clamp(0.95rem, 0.85rem + 0.4vw, 1.12rem);
	font-weight: 500;
	letter-spacing: -0.01em;
}
.doc-meta {
	margin: 0 0 1.4rem;
	color: var(--muted);
	font-size: 0.82rem;
	font-variant-numeric: tabular-nums;
}
.doc-meta .doc-version { color: var(--text); font-weight: 600; }
h2 {
	font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2rem);
	font-weight: 740;
	letter-spacing: -0.02em;
	margin: 3rem 0 1rem;
	padding-bottom: 0.4rem;
	border-bottom: 1px solid var(--border);
}
h3 { font-size: 1.32rem; font-weight: 680; letter-spacing: -0.01em; margin: 2.2rem 0 0.7rem; }
h4 { font-size: 1.04rem; font-weight: 680; color: var(--accent); margin: 1.7rem 0 0.5rem; }
:where(h1, h2, h3, h4)[id] { scroll-margin-top: 5.5rem; }

p { margin: 0 0 1rem; }
ul, ol { margin: 0.3rem 0 1.1rem; padding-left: 1.5rem; }
li { margin: 0.35rem 0; padding-left: 0.15rem; }
li::marker { color: var(--accent); }

a { color: var(--link); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--link-hover); text-decoration: underline; text-underline-offset: 0.15em; }

strong, .bold { font-weight: 700; color: var(--text-strong); }
em { color: var(--muted); font-style: italic; }
.line-through { text-decoration: line-through; opacity: 0.6; }

/* ---------- code ---------- */
code, pre, tt {
	font-family: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
	font-feature-settings: "liga" 0;
}
:not(pre) > code {
	background: var(--accent-soft);
	color: var(--text-strong);
	font-size: 0.84em;
	padding: 0.14em 0.42em;
	border: 1px solid var(--border);
	border-radius: 6px;
	overflow-wrap: anywhere;
	-webkit-box-decoration-break: clone;
	box-decoration-break: clone;
}
pre {
	background: var(--code-bg);
	color: var(--code-fg);
	padding: 1.1rem 1.25rem;
	border: 1px solid var(--border-strong);
	border-radius: 14px;
	overflow-x: auto;
	line-height: 1.55;
	font-size: 0.86rem;
	box-shadow: var(--shadow);
	transition: border-color 0.3s ease;
}
pre code { background: none; border: 0; padding: 0; font-size: inherit; white-space: pre; }
pre code.hljs { background: transparent; padding: 0; color: var(--code-fg); }
code.json a { color: inherit; text-decoration: none; }
code.json a:hover { text-decoration: underline; }

/* Syntax highlighting (highlight.js) — theme-aware via CSS variables (overrides darcula.css). */
.hljs .hljs-string { color: var(--tok-string); }
.hljs .hljs-number, .hljs .hljs-literal, .hljs .hljs-quote,
.hljs .hljs-regexp, .hljs .hljs-bullet { color: var(--tok-number); }
.hljs .hljs-attr { color: var(--tok-object); }
.hljs .hljs-keyword, .hljs .hljs-selector-tag, .hljs .hljs-section,
.hljs .hljs-attribute, .hljs .hljs-name, .hljs .hljs-variable { color: var(--tok-keyword); }
.hljs .hljs-type, .hljs .hljs-built_in, .hljs .hljs-builtin-name,
.hljs .hljs-symbol, .hljs .hljs-subst, .hljs .hljs-selector-id { color: var(--tok-builtin); }
.hljs .hljs-comment, .hljs .hljs-meta, .hljs .hljs-deletion { color: var(--muted); }
.hljs .hljs-strong { font-weight: 700; }
.hljs .hljs-emphasis { font-style: italic; }
kbd {
	font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
	font-size: 0.8em;
	background: var(--surface-2);
	color: var(--text-strong);
	border: 1px solid var(--border-strong);
	border-bottom-width: 2px;
	border-radius: 6px;
	padding: 0.12em 0.5em;
	white-space: nowrap;
}

/* ---------- tables (param definitions) ---------- */
table {
	width: 100%;
	border-collapse: separate;
	border-spacing: 0;
	margin: 0.7rem 0 1.7rem;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 14px;
	overflow: hidden;
	box-shadow: var(--shadow);
	font-size: 0.95rem;
	transition: background-color 0.3s ease, border-color 0.3s ease;
}
table tr.odd, table tbody tr:nth-child(even) { background: var(--surface-2); }
table th, table td {
	text-align: left;
	vertical-align: top;
	padding: 0.6rem 0.95rem;
	border-top: 1px solid var(--border);
}
table tr:first-child > * { border-top: 0; }
table th {
	font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
	font-weight: 600;
	color: var(--accent);
	white-space: nowrap;
}
th.title { font-size: 1.05rem; }

/* ---------- semantic JSON tokens ---------- */
span.string, span.string a, span.hex { color: var(--tok-string); }
span.hex { font-weight: bold; }
span.number, span.number a, span.boolean, span.boolean a { color: var(--tok-number); }
span.object, span.object a, span.array, span.array a, span.null, span.null a { color: var(--tok-object); }

/* value badges */
span.required, span.optional, span.default, span.keyframable {
	display: inline-block;
	color: #fff;
	font-size: 0.66rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	line-height: 1.5;
	vertical-align: 0.12em;
	margin-left: 0.4em;
	padding: 0.05em 0.55em;
	border-radius: 999px;
}
span.required { background: #d84a63; }
span.optional { background: #4f9d54; }
span.default  { background: #4c8f9a; }
span.keyframable { background: #7a6cd6; }

/* ---------- layout: sidebar table of contents ---------- */
.layout { display: block; }
.toc-title {
	font-size: 0.72rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
	color: var(--muted); margin: 0 0 0.55rem; padding-left: 0.55rem;
}
#toc > div { padding: 0; }
#toc a {
	display: block; color: var(--muted); font-size: 0.87rem; line-height: 1.3;
	padding: 0.2rem 0.55rem 0.2rem 1.4rem; border-radius: 6px; text-decoration: none;
}
#toc a:hover { color: var(--text-strong); background: var(--accent-soft); }
/* Top-level sections (§N): brighter (dark) / darker (light) + bolder; sub-topics sit indented beneath. */
#toc > div.toc-h2 > a { color: var(--text-strong); font-weight: 650; padding-left: 0.55rem; }
#toc > div.toc-h2:not(:first-child) > a { margin-top: 0.3rem; }
#toc > div.line-through a { text-decoration: line-through; opacity: 0.5; }
#toc-toggle, #toc-backdrop { display: none; }

/* desktop: sticky sidebar beside the content */
@media (min-width: 60rem) {
	body { padding-top: 1.25rem; }
	.pagehead { padding-right: 7.5rem; } /* clear the fixed theme toggle, top-right */
	.layout { display: flex; align-items: flex-start; gap: clamp(1.5rem, 3vw, 3rem); }
	#sidebar {
		position: sticky; top: 0; align-self: flex-start;
		flex: 0 0 14rem; max-height: 100vh; overflow-y: auto;
		padding: 0.6rem 0.4rem 2rem 0;
	}
	#content { flex: 1 1 auto; min-width: 0; }
}

/* narrower: the TOC becomes an off-canvas drawer opened by the ☰ button */
@media (max-width: 59.99rem) {
	#sidebar {
		position: fixed; top: 0; left: 0; z-index: 200;
		width: min(84vw, 19rem); height: 100vh; overflow-y: auto;
		padding: 4.2rem 1.1rem 2rem 1.25rem;
		background: var(--bg); border-right: 1px solid var(--border-strong);
		box-shadow: var(--shadow);
		transform: translateX(-100%); transition: transform 0.25s ease;
	}
	#sidebar.open { transform: translateX(0); }
	#toc a { font-size: 0.95rem; padding: 0.35rem 0.55rem 0.35rem 1.5rem; }
	#toc-backdrop { position: fixed; inset: 0; z-index: 150; background: rgba(0, 0, 0, 0.5); }
	#toc-backdrop.open { display: block; }
	#toc-toggle {
		display: inline-flex; align-items: center; gap: 0.35rem;
		position: fixed; top: 0.6rem; left: 0.6rem; z-index: 210;
		background: var(--surface); color: var(--text);
		border: 1px solid var(--border-strong); border-radius: 999px;
		padding: 0.45rem 0.85rem; font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer;
		box-shadow: var(--shadow);
	}
	#toc-toggle:hover { border-color: var(--accent); }
}

/* ---------- theme toggle ---------- */
#theme-toggle {
	position: fixed;
	top: 1rem;
	right: 1rem;
	z-index: 1000;
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	min-width: 6.3rem;
	justify-content: center;
	background: var(--surface);
	color: var(--text);
	border: 1px solid var(--border-strong);
	border-radius: 999px;
	padding: 0.5rem 0.95rem;
	font: inherit;
	font-size: 0.85rem;
	font-weight: 600;
	cursor: pointer;
	box-shadow: var(--shadow);
	transition: transform 0.12s ease, background-color 0.3s ease, border-color 0.2s ease;
}
#theme-toggle:hover { transform: translateY(-1px); border-color: var(--accent); }
#theme-toggle:active { transform: translateY(0); }
#theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#theme-toggle .tt-icon { font-size: 1.05em; line-height: 1; }

/* ---------- misc ---------- */
div.center { text-align: center; }
img { max-width: 100%; height: auto; }
img.thumb { width: 10em; }
div.textlogo {
	display: inline-block;
	padding: 0.1em 0.35em;
	font-size: 2em;
	border: 1px solid var(--border-strong);
	border-radius: 2em;
	margin-bottom: 0.5em;
}

/* ---------- responsive ---------- */
@media (max-width: 640px) {
	html, body { font-size: 15.5px; }
	body { padding: 1rem; padding-top: 3.5rem; }
	h2 { margin-top: 2rem; }
	/* let wide definition tables scroll instead of overflowing the page */
	table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
	/* icon-only circular toggle on phones so it never covers heading text */
	#theme-toggle { top: 0.6rem; right: 0.6rem; min-width: 0; width: 2.6rem; height: 2.6rem; padding: 0; gap: 0; font-size: 1rem; }
	#theme-toggle .tt-label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto; }
	*, ::before, ::after { transition: none !important; }
}

/* ------------------------------------------------------------------ *
 * Collapsible code blocks — full example sources (§ Full examples).
 * <details class="code-toggle"><summary>file.json</summary><pre>…</pre>
 * ------------------------------------------------------------------ */
details.code-toggle {
	margin: 0.7rem 0 1.1rem;
	border: 1px solid var(--border-strong);
	border-radius: 12px;
	background: var(--surface);
	overflow: hidden;
}
details.code-toggle > summary {
	cursor: pointer;
	list-style: none;
	display: flex;
	align-items: center;
	gap: 0.55rem;
	padding: 0.55rem 0.9rem;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.9rem;
	font-weight: 600;
	color: var(--text-strong);
	background: var(--accent-soft);
	user-select: none;
}
details.code-toggle > summary::-webkit-details-marker { display: none; }
details.code-toggle > summary::before {
	content: "\25B8";           /* ▸ */
	color: var(--accent);
	font-size: 0.95em;
}
details.code-toggle[open] > summary::before { content: "\25BE"; }  /* ▾ */
details.code-toggle > summary:hover { color: var(--link-hover); }
details.code-toggle pre {
	margin: 0;
	border: 0;
	border-top: 1px solid var(--border);
	border-radius: 0;
	overflow-x: auto;
}

/* At-a-glance part-types table (§2) — simple 2-column reference. */
table.glance { width: 100%; border-collapse: collapse; margin: 0.6rem 0 1rem; }
table.glance th, table.glance td {
	text-align: left; padding: 0.42rem 0.7rem; vertical-align: top;
	border-bottom: 1px solid var(--border);
}
table.glance th { color: var(--text-strong); border-bottom: 1px solid var(--border-strong); }
table.glance td:first-child { white-space: nowrap; }
table.glance tr:hover td { background: var(--accent-soft); }

/* ================================================================== *
 * Readability helpers: callouts, quick-start, pipeline diagram,
 * TOC filter, copy buttons, glossary.
 * ================================================================== */

/* Callout boxes — gotchas & tips */
.callout {
	margin: 1rem 0; padding: 0.7rem 1rem 0.7rem 2.5rem;
	border-radius: 10px; border-left: 4px solid var(--accent);
	background: var(--accent-soft); position: relative; line-height: 1.55;
}
.callout::before { position: absolute; left: 0.85rem; top: 0.62rem; font-size: 1.05em; }
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }
.callout.gotcha { border-left-color: #e6a700; background: rgba(230, 167, 0, 0.12); }
.callout.gotcha::before { content: "\26A0\FE0F"; }        /* warning sign */
.callout.tip { border-left-color: #4f9d54; background: rgba(79, 157, 84, 0.13); }
.callout.tip::before { content: "\1F4A1"; }               /* light bulb */

/* Quick-start numbered on-ramp */
ol.quickstart { margin: 0.3rem 0 0; padding-left: 1.35rem; }
ol.quickstart li { margin: 0.28rem 0; }

/* Pipeline / mental-model diagram */
.pipeline { display: flex; flex-wrap: wrap; align-items: stretch; gap: 0.4rem; margin: 1.1rem 0; font-size: 0.9rem; }
.pipeline .stage {
	flex: 1 1 auto; min-width: 6.5rem; text-align: center;
	padding: 0.55rem 0.7rem; border: 1px solid var(--border-strong);
	border-radius: 10px; background: var(--surface); color: var(--text-strong);
}
.pipeline .stage small { display: block; margin-top: 0.15rem; color: var(--muted); font-size: 0.8em; font-weight: 400; }
.pipeline .arrow { align-self: center; color: var(--accent); font-weight: 700; }
@media (max-width: 640px) { .pipeline { flex-direction: column; } .pipeline .arrow { transform: rotate(90deg); } }

/* TOC filter box */
#toc-filter {
	width: 100%; box-sizing: border-box; margin: 0 0 0.6rem; padding: 0.4rem 0.6rem;
	font: inherit; font-size: 0.9rem; color: var(--text); background: var(--surface);
	border: 1px solid var(--border-strong); border-radius: 8px;
}
#toc-filter::placeholder { color: var(--muted); }
#toc-filter:focus { outline: none; border-color: var(--accent); }
#toc > div.tf-hide { display: none; }

/* Copy button on code blocks */
.codewrap { position: relative; }
.codewrap > .copy-btn {
	position: absolute; top: 0.5rem; right: 0.5rem; z-index: 2;
	padding: 0.2rem 0.55rem; font: inherit; font-size: 0.78rem; color: var(--text);
	background: var(--surface); border: 1px solid var(--border-strong);
	border-radius: 7px; cursor: pointer; opacity: 0; transition: opacity 0.12s ease;
}
.codewrap:hover > .copy-btn, .codewrap > .copy-btn:focus { opacity: 1; }
.copy-btn.copied { color: #fff; background: #4f9d54; border-color: #4f9d54; }

/* Glossary definition list */
dl.glossary { margin: 0.6rem 0; }
dl.glossary dt { font-weight: 700; color: var(--text-strong); margin-top: 0.65rem; }
dl.glossary dd { margin: 0.12rem 0 0; padding-left: 1rem; }

/* OS command tabs — macOS/Linux vs Windows (synced across the page). */
.ostabs { margin: 0.8rem 0 1rem; }
.ostabs-bar { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; margin-bottom: 0.5rem; }
.ostab {
	padding: 0.34rem 0.95rem; font: inherit; font-size: 0.84rem; font-weight: 600;
	color: var(--muted); background: var(--surface); border: 0; cursor: pointer;
	transition: background 0.12s ease, color 0.12s ease;
}
.ostab + .ostab { border-left: 1px solid var(--border-strong); }
.ostab:hover { color: var(--text-strong); }
.ostabs[data-active="unix"] .ostab[data-os="unix"],
.ostabs[data-active="win"]  .ostab[data-os="win"]  { background: var(--accent-soft); color: var(--text-strong); }
.ostab-panel { display: none; }
.ostabs[data-active="unix"] .ostab-panel[data-os="unix"],
.ostabs[data-active="win"]  .ostab-panel[data-os="win"]  { display: block; }
.ostabs .codewrap, .ostab-panel pre { margin: 0; }
