/* ============================================================
   driftless — documentation page styles
   Used by /docs/mcp. Built on the existing design tokens.
   Responsive: TOC sidebar collapses on mobile; tables and code
   blocks scroll horizontally on narrow viewports.
   ============================================================ */

/* ===== Docs layout: sticky TOC + prose ===== */
.docs {
	padding-top: 16px;
	padding-bottom: 96px;
	background: var(--surface-page);
}
.docs-container {
	display: grid;
	grid-template-columns: 240px minmax(0, 1fr);
	gap: 48px;
	align-items: start;
}

/* ===== Table of contents ===== */
.docs-toc {
	position: sticky;
	top: 88px;
	font-size: var(--text-sm);
	line-height: var(--leading-relaxed);
}
.docs-toc-title {
	font-family: var(--font-mono);
	font-size: var(--text-2xs);
	font-weight: var(--fw-medium);
	letter-spacing: var(--tracking-caps);
	text-transform: uppercase;
	color: var(--text-muted);
	margin-bottom: var(--space-3);
}
.docs-toc ul {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
}
.docs-toc ul ul {
	margin-top: 6px;
	padding-left: 14px;
	gap: 4px;
}
.docs-toc-tools {
	max-height: 320px;
	overflow-y: auto;
}
.docs-toc a {
	color: var(--text-body);
	text-decoration: none;
}
.docs-toc a:hover {
	color: var(--text-accent);
	text-decoration: underline;
}
.docs-toc code {
	font-family: var(--font-mono);
	font-size: 0.85em;
	color: inherit;
	background: none;
}

/* ===== Prose column ===== */
.docs-prose {
	max-width: 820px;
	min-width: 0; /* allow grid item to shrink, enabling overflow scroll */
}
.docs-header {
	margin-bottom: var(--space-7);
	padding-bottom: var(--space-5);
	border-bottom: 1px solid var(--border-subtle);
}
.docs-title {
	font-size: var(--text-3xl);
	line-height: var(--leading-tight);
	margin-top: var(--space-2);
}
.docs-lede {
	margin-top: var(--space-4);
	font-size: var(--text-md);
	line-height: var(--leading-relaxed);
	color: var(--text-body);
	max-width: 70ch;
}

.docs-section {
	margin-top: var(--space-8);
}
.docs-section > h2 {
	font-size: var(--text-xl);
	margin-bottom: var(--space-4);
	padding-bottom: var(--space-2);
	border-bottom: 1px solid var(--border-subtle);
}
.docs-h3 {
	font-size: var(--text-lg);
	margin-top: var(--space-6);
	margin-bottom: var(--space-3);
}
.docs-prose p {
	margin-top: var(--space-3);
	line-height: var(--leading-relaxed);
	color: var(--text-body);
}
.docs-prose strong {
	color: var(--text-strong);
	font-weight: var(--fw-semibold);
}
.docs-prose a {
	color: var(--text-link);
	text-decoration: underline;
	text-underline-offset: 2px;
}
.docs-prose a:hover {
	color: var(--teal-600);
}

/* Inline code */
.docs-prose code,
.docs-prose p code,
.docs-prose li code,
.docs-prose td code,
.docs-prose th code {
	font-family: var(--font-mono);
	font-size: 0.875em;
	background: var(--surface-sunken);
	color: var(--ink-900);
	padding: 1px 5px;
	border-radius: var(--radius-xs);
	border: 1px solid var(--border-subtle);
	white-space: nowrap;
}

/* ===== Ordered steps ===== */
.docs-steps {
	margin: var(--space-4) 0;
	padding-left: 20px;
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	line-height: var(--leading-relaxed);
	color: var(--text-body);
}

/* ===== Code blocks ===== */
.code-block {
	margin: var(--space-4) 0;
	border-radius: var(--radius-md);
	border: 1px solid var(--border-default);
	background: var(--ink-950);
	overflow: hidden;
}
.code-block pre {
	margin: 0;
	padding: var(--space-4) var(--space-5);
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}
.code-block code {
	font-family: var(--font-mono);
	font-size: var(--text-sm);
	line-height: var(--leading-relaxed);
	color: #d7dce2;
	background: none;
	border: none;
	padding: 0;
	white-space: pre;
	tab-size: 2;
}

/* ===== Callout ===== */
.callout {
	margin: var(--space-4) 0;
	padding: var(--space-4) var(--space-5);
	border-radius: var(--radius-md);
	border: 1px solid var(--teal-100);
	background: var(--surface-accent-subtle);
	color: var(--ink-800);
	line-height: var(--leading-relaxed);
}
.callout strong {
	color: var(--teal-800);
}
.callout code {
	background: rgba(255, 255, 255, 0.7);
}

/* ===== Tables ===== */
.table-wrap {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	margin: var(--space-4) 0;
	border: 1px solid var(--border-subtle);
	border-radius: var(--radius-md);
}
.docs-prose table {
	width: 100%;
	border-collapse: collapse;
	font-size: var(--text-sm);
	background: var(--surface-card);
}
.docs-prose thead th {
	text-align: left;
	font-family: var(--font-mono);
	font-size: var(--text-2xs);
	font-weight: var(--fw-semibold);
	letter-spacing: var(--tracking-caps);
	text-transform: uppercase;
	color: var(--text-muted);
	background: var(--surface-sunken);
	padding: 10px 14px;
	border-bottom: 1px solid var(--border-default);
	white-space: nowrap;
}
.docs-prose tbody td {
	padding: 10px 14px;
	border-bottom: 1px solid var(--border-subtle);
	vertical-align: top;
	line-height: var(--leading-normal);
	color: var(--text-body);
}
.docs-prose tbody tr:last-child td {
	border-bottom: none;
}
.docs-prose tbody tr:hover td {
	background: var(--ink-50);
}

/* Key/value table (endpoint, rate limits) */
.kv-table th {
	width: 34%;
	font-weight: var(--fw-semibold);
	color: var(--text-strong);
	background: var(--surface-sunken);
	white-space: nowrap;
}

/* Tool quick-reference index */
.tool-index .tool-index-name {
	white-space: nowrap;
}
.tool-index a code {
	background: none;
	border: none;
	color: var(--text-link);
	padding: 0;
}
.tool-index a:hover code {
	color: var(--teal-600);
	text-decoration: underline;
}

/* ===== Tool reference cards ===== */
.tool {
	margin-top: var(--space-7);
	padding-top: var(--space-5);
	border-top: 1px solid var(--border-subtle);
	scroll-margin-top: 88px;
}
.tool:first-of-type {
	border-top: none;
	padding-top: 0;
}
.tool-title {
	font-size: var(--text-lg);
	display: flex;
	align-items: baseline;
	gap: var(--space-3);
}
.tool-title code {
	font-family: var(--font-mono);
	font-size: var(--text-md);
	background: var(--ink-950);
	color: var(--teal-300);
	padding: 3px 8px;
	border-radius: var(--radius-sm);
	border: none;
}
.tool-permalink {
	color: var(--text-subtle);
	text-decoration: none;
	font-weight: var(--fw-regular);
}
.tool-permalink:hover {
	color: var(--text-accent);
}
.tool-desc {
	margin-top: var(--space-2);
	color: var(--text-body);
	line-height: var(--leading-relaxed);
}
.tool-subhead {
	font-size: var(--text-sm);
	font-weight: var(--fw-semibold);
	text-transform: uppercase;
	letter-spacing: var(--tracking-caps);
	color: var(--text-muted);
	margin-top: var(--space-4);
	margin-bottom: var(--space-2);
}
.tool-noparams {
	margin-top: var(--space-2);
	color: var(--text-muted);
	font-style: italic;
}
.tool-returns {
	margin-top: var(--space-4);
	padding: var(--space-3) var(--space-4);
	background: var(--surface-sunken);
	border-radius: var(--radius-sm);
	font-size: var(--text-sm);
	line-height: var(--leading-relaxed);
	color: var(--text-body);
}
.tool-returns strong {
	color: var(--text-strong);
}
.tool-returns code {
	background: var(--surface-card);
}
.docs-returns-note {
	margin-top: var(--space-3);
	padding: var(--space-3) var(--space-4);
	background: var(--surface-sunken);
	border-radius: var(--radius-sm);
	font-size: var(--text-sm);
	line-height: var(--leading-relaxed);
	color: var(--text-body);
}

/* Parameter table cells */
.param-name { white-space: nowrap; }
.param-name code { background: none; border: none; padding: 0; color: var(--ink-900); }
.param-type { white-space: nowrap; color: var(--text-muted); font-family: var(--font-mono); font-size: 0.8rem; }
.param-req { white-space: nowrap; }
.param-desc { min-width: 220px; }
.req-badge, .opt-badge {
	font-family: var(--font-mono);
	font-size: var(--text-2xs);
	font-weight: var(--fw-medium);
	text-transform: uppercase;
	letter-spacing: var(--tracking-caps);
	padding: 2px 7px;
	border-radius: var(--radius-pill);
}
.req-badge { color: var(--teal-800); background: var(--teal-50); border: 1px solid var(--teal-100); }
.opt-badge { color: var(--text-muted); background: var(--ink-100); border: 1px solid var(--border-subtle); }
.enum-values {
	display: block;
	margin-top: 4px;
	font-size: var(--text-2xs);
	color: var(--text-muted);
}
.enum-values code {
	font-size: 0.8rem;
	background: none;
	border: none;
	padding: 0;
	color: var(--purple-700);
}

/* Nested parameter blocks */
.nested-props {
	margin-top: var(--space-3);
	margin-left: var(--space-4);
	padding-left: var(--space-4);
	border-left: 2px solid var(--border-subtle);
}
.nested-label {
	font-family: var(--font-mono);
	font-size: var(--text-2xs);
	font-weight: var(--fw-medium);
	color: var(--text-muted);
	margin-bottom: var(--space-2);
}
.param-table--nested {
	font-size: var(--text-xs);
}
.param-table--nested .param-desc { min-width: 160px; }

/* ============================================================
   RESPONSIVE — Media queries
   ============================================================ */

/* ===== Tablet (max-width: 1024px) ===== */
@media (max-width: 1024px) {
	.docs-container {
		grid-template-columns: 200px minmax(0, 1fr);
		gap: 32px;
	}
}

/* ===== Mobile (max-width: 768px) ===== */
@media (max-width: 768px) {
	.docs-container {
		grid-template-columns: minmax(0, 1fr);
		gap: 0;
	}
	/* Hide the sidebar TOC on mobile; the in-page section headings suffice. */
	.docs-toc {
		display: none;
	}
	.docs-prose {
		max-width: 100%;
	}
	.docs-title {
		font-size: var(--text-2xl);
	}
	.docs-section > h2 {
		font-size: var(--text-lg);
	}
	.docs-h3 {
		font-size: var(--text-md);
	}
	/* Code blocks and table wrappers scroll horizontally instead of breaking layout. */
	.code-block pre,
	.table-wrap {
		overflow-x: auto;
	}
	.tool-title {
		flex-wrap: wrap;
	}
	/* Stack the kv-table rows into label/value pairs on narrow screens. */
	.kv-table th,
	.kv-table td {
		display: block;
		width: 100%;
	}
	.kv-table th {
		border-bottom: none;
		padding-bottom: 2px;
	}
}

/* ===== Small phone (max-width: 480px) ===== */
@media (max-width: 480px) {
	.docs-title {
		font-size: var(--text-xl);
	}
	.code-block pre {
		padding: var(--space-3);
		font-size: 0.8rem;
	}
	.docs-prose tbody td,
	.docs-prose thead th {
		padding: 8px 10px;
	}
}

/* ===== HTTP method badges (API reference / /docs/api) ===== */
.method-badge {
	display: inline-block;
	min-width: 3.4em;
	padding: 2px 8px;
	margin-right: var(--space-2);
	border-radius: 4px;
	font-family: var(--font-mono);
	font-size: 0.72rem;
	font-weight: 600;
	text-align: center;
	color: var(--ink-900);
	background: var(--ink-100);
	border: 1px solid var(--border-subtle);
	vertical-align: middle;
}
.method-get { color: #157a52; background: #e6f4ec; border-color: #c3e6d4; }
.method-post { color: #1d5fb0; background: #e6f0fb; border-color: #c3d9f3; }
.method-put { color: #9a6b00; background: #fbf3e0; border-color: #f0e0b8; }
.method-patch { color: #8a5a00; background: #fbf0e0; border-color: #efd9b0; }
.method-delete { color: #b3261e; background: #fbe9e8; border-color: #f3c9c6; }

/* API endpoint quick-reference index — let long paths wrap */
.api-index .tool-index-name code { white-space: normal; word-break: break-all; }

/* Benchmarks — task-number list: monospace data tokens that wrap on mobile */
.task-ids {
	font-family: var(--font-mono);
	font-size: 0.85rem;
	line-height: 1.9;
	word-spacing: 0.15em;
	color: var(--ink-800);
	margin: 0;
}