/* docs.html: the documentation page. Script-free (CSP script-src 'none'): the mobile contents use <details>, the
   active section highlight uses :target only, and the benchmark bars are inline SVG sized by attributes (no inline
   styles). Builds on the tokens and components of site.css. */

.page-docs {
	--prose: color-mix(in oklab, var(--text) 74%, var(--text-2));
	--side-w: 216px;
	--article-w: 760px;
}

/* --- page head --------------------------------------------------------------------------------------------------- */

.docs-head .lead { max-width: 58ch; }

.docs-status {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

/* --- layout: sidebar | article ----------------------------------------------------------------------------------- */

.docs {
	display: grid;
	grid-template-columns: var(--side-w) minmax(0, var(--article-w));
	align-items: start;
	gap: clamp(40px, 6vw, 96px);
	padding-top: clamp(40px, 5vw, 64px);
}

.docs-side {
	position: sticky;
	top: calc(var(--header-h) + 28px);
	max-height: calc(100vh - var(--header-h) - 44px);
	margin: -4px;
	padding: 4px 4px 24px;
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
	scrollbar-color: var(--line-2) transparent;
}

/* sidebar navigation (the same markup sits in the mobile <details>) */
.docs-nav {
	display: grid;
	gap: 26px;
}

.docs-nav-label {
	margin-bottom: 8px;
	color: var(--text-3);
	font: 500 11.5px/1.4 var(--font-mono);
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.docs-nav ol {
	margin: 0;
	padding: 0;
	border-left: 1px solid var(--line);
	list-style: none;
}

.docs-nav a {
	display: block;
	margin-left: -1px;
	padding: 4px 0 4px 14px;
	border-left: 1px solid transparent;
	color: var(--text-2);
	font-size: 14px;
	line-height: 1.5;
	text-decoration: none;
	transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.docs-nav a:hover {
	border-left-color: var(--line-2);
	color: var(--text);
}

/* the section you jumped to (CSS :target only, no script) */
.docs:has(#agent:target) .docs-nav a[href='#agent'],
.docs:has(#install:target) .docs-nav a[href='#install'],
.docs:has(#auto:target) .docs-nav a[href='#auto'],
.docs:has(#three:target) .docs-nav a[href='#three'],
.docs:has(#gltf:target) .docs-nav a[href='#gltf'],
.docs:has(#raw:target) .docs-nav a[href='#raw'],
.docs:has(#worker:target) .docs-nav a[href='#worker'],
.docs:has(#build:target) .docs-nav a[href='#build'],
.docs:has(#authoring:target) .docs-nav a[href='#authoring'],
.docs:has(#formats:target) .docs-nav a[href='#formats'],
.docs:has(#options:target) .docs-nav a[href='#options'],
.docs:has(#csp:target) .docs-nav a[href='#csp'],
.docs:has(#limits:target) .docs-nav a[href='#limits'],
.docs:has(#bench:target) .docs-nav a[href='#bench'],
.docs:has(#license:target) .docs-nav a[href='#license'] {
	border-left-color: var(--accent);
	color: var(--text);
	font-weight: 500;
}

/* mobile contents: a <details> that works without JavaScript */
.docs-toc {
	display: none;
	border: 1px solid var(--line);
	border-radius: var(--radius-l);
	background: var(--surface);
}

.docs-toc summary {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	min-height: 48px;
	padding: 0 18px;
	border-radius: var(--radius-l);
	color: var(--text);
	font-size: 15px;
	font-weight: 600;
	list-style: none;
	cursor: pointer;
}

.docs-toc summary::-webkit-details-marker { display: none; }

.docs-toc summary::after {
	content: '';
	width: 7px;
	height: 7px;
	border-right: 1.5px solid var(--text-2);
	border-bottom: 1.5px solid var(--text-2);
	transform: translateY(-2px) rotate(45deg);
	transition: transform 0.2s var(--ease);
}

.docs-toc[open] summary { border-bottom: 1px solid var(--line); border-radius: var(--radius-l) var(--radius-l) 0 0; }
.docs-toc[open] summary::after { transform: translateY(2px) rotate(-135deg); }

.docs-toc .docs-nav {
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 22px 20px;
	padding: 20px 18px 22px;
}

/* --- article ----------------------------------------------------------------------------------------------------- */

.docs-article {
	min-width: 0;
	color: var(--prose);
	font-size: 16px;
	line-height: 1.7;
}

.docs-article :where(p, ul, ol, dl, figure) { margin: 0; }

/* part dividers: 01 Start, 02 Guides, … */
.doc-part {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-top: clamp(72px, 8vw, 104px);
	color: var(--text-3);
	font: 500 12px/1.4 var(--font-mono);
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.doc-part:first-child { margin-top: 0; }
.doc-part span { color: var(--accent); }

.doc-part::after {
	content: '';
	flex: 1;
	height: 1px;
	background: var(--line);
}

/* sections */
.doc {
	position: relative;
	margin-top: clamp(48px, 6vw, 72px);
	padding-top: clamp(28px, 3.5vw, 40px);
	border-top: 1px solid var(--line);
}

.doc-part + .doc {
	margin-top: 28px;
	padding-top: 0;
	border-top: 0;
}

/* the jumped-to section gets a short accent mark on its hairline */
.doc::before {
	content: '';
	position: absolute;
	top: -1px;
	left: 0;
	width: 0;
	height: 1px;
	background: var(--accent);
	transition: width 0.5s var(--ease);
}

.doc:target::before { width: 64px; }
.doc-part + .doc::before { display: none; }

.doc > * + * { margin-top: 18px; }

.doc h2 {
	font-size: clamp(1.55rem, 1.3rem + 0.8vw, 1.95rem);
	letter-spacing: -0.03em;
}

.doc h2 + * { margin-top: 16px; }

.doc :where(p, li) { max-width: 68ch; }

.doc-lede {
	color: var(--text-2);
	font-size: 1.0625rem;
	line-height: 1.65;
}

.doc-note {
	color: var(--text-2);
	font-size: 14px;
	line-height: 1.6;
}

.doc a {
	color: var(--text);
	text-decoration-color: color-mix(in oklab, var(--accent) 55%, transparent);
}

.doc a:hover {
	color: var(--accent-strong);
	text-decoration-color: currentColor;
}

/* lists */
.doc ul { padding-left: 1.15em; }
.doc ul > li { padding-left: 0.25em; }
.doc li + li { margin-top: 8px; }
.doc li::marker { color: var(--text-3); }

/* inline code: the site.css chip in prose, plain monospace in tables */
.docs-article code { color: var(--text); }

.docs-article :not(pre) > code {
	-webkit-box-decoration-break: clone;
	box-decoration-break: clone;
}

.doc :where(td, th) code {
	padding: 0;
	border: 0;
	background: none;
	font-size: 0.9em;
}

.doc th code { color: inherit; }

/* code blocks: the same 16px radius as every card and Home's code window */
.doc pre { border-radius: var(--radius-l); }

.code {
	overflow: hidden;
	border: 1px solid var(--line);
	border-radius: var(--radius-l);
	background: var(--surface);
}

.code figcaption {
	display: flex;
	justify-content: space-between;
	gap: 16px;
	padding: 9px 18px;
	border-bottom: 1px solid var(--line);
	color: var(--text-2);
	font: 500 12px/1.4 var(--font-mono);
}

.code figcaption span:last-child { color: var(--text-2); font-weight: 400; }

.code pre {
	border: 0;
	border-radius: 0;
	background: none;
}

.doc pre { color: var(--text); }

/* tables */
.doc .table-scroll { -webkit-overflow-scrolling: touch; }

.doc table { font-size: 14.5px; line-height: 1.55; }
.doc table.compact { font-size: 13.5px; }
.doc td { color: var(--prose); }
.doc td:first-child { color: var(--text); }

/* formats by GPU capability (Semantics and formats): the column name, then its example devices */
.doc-formats th {
	color: var(--text);
	font-size: 13px;
	font-weight: 600;
	vertical-align: bottom;
}

.doc-formats th:not(:first-child) { min-width: 17ch; }

.doc-formats .th-sub {
	display: block;
	margin-top: 4px;
	color: var(--text-2);
	font-size: 12px;
	font-weight: 400;
	line-height: 1.45;
	letter-spacing: 0;
	white-space: normal;
}

/* --- agent skill: what to ask once the skill is installed ---------------------------------------------------------- */

.prompts-label {
	color: var(--text-3);
	font: 500 11.5px/1.4 var(--font-mono);
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.doc > .prompts-label + .prompts { margin-top: 10px; }

.doc .prompts {
	display: grid;
	gap: 8px;
	padding: 0;
	list-style: none;
}

.doc .prompts > li {
	position: relative;
	max-width: none;
	margin: 0;
	padding: 11px 16px 11px 38px;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	color: var(--text);
	font-size: 15px;
	line-height: 1.55;
}

.doc .prompts > li::before {
	content: '›';
	position: absolute;
	top: 11px;
	left: 17px;
	color: var(--accent);
	font: 600 15px/1.55 var(--font-mono);
}

/* --- benchmarks: one small bar list per measure ------------------------------------------------------------------ */

/* each bar is an inline <svg>: a rounded <rect> whose width is the row's share of the card's largest value, and a
   square <rect> over its first half so the bar starts flat on the baseline */

.bench-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 20px;
	color: var(--text-2);
	font-size: 13px;
	line-height: 1.5;
}

.bench-legend span {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}

.bench-legend span::before {
	content: '';
	width: 10px;
	height: 10px;
	border-radius: 3px;
	background: var(--text-3);
}

.bench-legend .is-uft::before { background: var(--accent); }

.doc > .bench-legend + .bench-grid { margin-top: 12px; }

.bench-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px;
}

.bench {
	padding: 18px 20px 20px;
	border: 1px solid var(--line);
	border-radius: var(--radius-l);
	background: var(--surface);
}

.bench figcaption {
	display: grid;
	gap: 2px;
}

.bench-title {
	color: var(--text);
	font-size: 15px;
	font-weight: 600;
	letter-spacing: -0.01em;
	line-height: 1.4;
}

.bench-sub {
	color: var(--text-2);
	font-size: 12.5px;
	line-height: 1.45;
}

.doc .bench-rows {
	display: grid;
	gap: 12px;
	margin-top: 18px;
	padding: 0;
	list-style: none;
}

.doc .bench-rows > li {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: baseline;
	gap: 5px 12px;
	max-width: none;
	margin: 0;
	padding: 0;
}

.bench-label {
	overflow: hidden;
	color: var(--text-2);
	font-size: 13px;
	line-height: 1.4;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.is-uft .bench-label {
	color: var(--text);
	font-weight: 500;
}

.bench-val {
	color: var(--text);
	font-size: 13px;
	font-weight: 500;
	line-height: 1.4;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.bench-q {
	margin-left: 8px;
	color: var(--text-3);
	font-weight: 400;
}

.bench-bar {
	grid-column: 1 / -1;
	width: 100%;
	height: 8px;
	fill: var(--text-3);
}

.is-uft .bench-bar { fill: var(--accent); }

/* --- next step (after the article, like the closing band of the other pages) ---------------------------------- */

/* the shared .page-next of site.css; it follows the article, not another .section, so it draws its own top rule */

.page-docs .section.docs-next {
	margin-top: clamp(72px, 9vw, 120px);
	border-top: 1px solid var(--line);
}

/* --- responsive -------------------------------------------------------------------------------------------------- */

@media (max-width: 980px) {
	.docs {
		grid-template-columns: minmax(0, 1fr);
		gap: 0;
		padding-top: 28px;
	}

	.docs-side {
		position: static;
		max-height: none;
		margin: 0;
		padding: 0;
		overflow: visible;
	}

	.docs-side > .docs-nav-side { display: none; }
	.docs-toc { display: block; }
	.doc-part:first-child { margin-top: 48px; }
}

@media (max-width: 640px) {
	/* long identifiers wrap on phones instead of widening the page */
	.doc :where(p, li) > code {
		white-space: normal;
		overflow-wrap: anywhere;
	}

	/* list-like reference tables become stacked entries: name, then labelled values */
	.doc table.doc-stack,
	.doc table.doc-stack tbody,
	.doc table.doc-stack tr,
	.doc table.doc-stack td {
		display: block;
		width: auto;
	}

	.doc table.doc-stack thead {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
	}

	.doc table.doc-stack tr {
		padding: 14px 0;
		border-bottom: 1px solid var(--line);
	}

	.doc table.doc-stack tbody tr:first-child { border-top: 1px solid var(--line); }
	.doc table.doc-stack tbody tr:last-child { border-bottom: 1px solid var(--line); }

	.doc table.doc-stack td {
		padding: 0;
		border: 0;
	}

	.doc table.doc-stack td + td { margin-top: 4px; }
	.doc table.doc-stack td:first-child { font-weight: 500; }

	.doc table.doc-stack td[data-label]::before {
		content: attr(data-label) '  ';
		color: var(--text-2);
		font: 500 11px/1.4 var(--font-mono);
		letter-spacing: 0.06em;
		text-transform: uppercase;
		white-space: pre;
	}

	.doc table.doc-stack td code { white-space: normal; overflow-wrap: anywhere; }

	.bench-grid { grid-template-columns: minmax(0, 1fr); }
	.bench { padding: 16px 16px 18px; }
	.docs-toc .docs-nav { grid-template-columns: minmax(0, 1fr); }
	.doc pre { padding: 16px; font-size: 12.5px; }
	.code figcaption { padding-inline: 16px; }
}

/* --- print ------------------------------------------------------------------------------------------------------- */

@media print {
	.site-header,
	.site-footer,
	.docs-side,
	.docs-next,
	.skip-link { display: none; }

	.docs { grid-template-columns: minmax(0, 1fr); }
	.doc { break-inside: auto; }
	.doc pre { white-space: pre-wrap; }
	.bench { break-inside: avoid; }
}
