/* Identidad de soul: los mismos tokens que DEFAULT_THEME de @jun/soul/ui
   (marfil + dorado, Fraunces para titulos, Inter para texto). La doc se ve
   como lo que documenta. */
:root {
	--bg: #fbf8f1;
	--surface: #fffdf8;
	--surface-alt: #f3eee0;
	--border: #e7e2d3;
	--border-strong: #dcd5c3;
	--text: #2f2a22;
	--text-muted: #6f6754;
	--text-faint: #a99f88;
	--primary: #c9a23e;
	--primary-hover: #b08f32;
	--danger: #b4452f;
	--danger-soft: #f8ede7;
	--success: #2f7d46;
	--success-soft: #e7f3ea;
	--link: #a08a4e;
	--link-hover: #8a6a22;
	--font-body: "Inter", ui-sans-serif, system-ui, sans-serif;
	--font-display: "Fraunces", Georgia, serif;
	--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
	--radius: 10px;
	--radius-sm: 6px;
	--sidebar-w: 268px;
	--toc-w: 200px;
	--topbar-h: 60px;
	--content-max: 780px;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 16px); }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font-body);
	font-size: 15px;
	line-height: 1.65;
	-webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

.skip {
	position: absolute; left: -9999px; top: 0; z-index: 100;
	background: var(--text); color: #fff; padding: 10px 16px; border-radius: 0 0 var(--radius-sm) 0;
}
.skip:focus { left: 0; }

/* ---------- Topbar ---------- */
.topbar {
	position: sticky; top: 0; z-index: 40;
	height: var(--topbar-h);
	display: flex; align-items: center; gap: 14px;
	padding: 0 20px;
	background: rgba(255, 253, 248, .92);
	backdrop-filter: blur(8px);
	border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); font-weight: 600; }
.brand:hover { text-decoration: none; color: var(--text); }
.brand-mark { color: var(--primary); font-size: 20px; line-height: 1; }
.brand-name { font-family: var(--font-display); font-size: 19px; letter-spacing: -.01em; }
.version {
	font-size: 11px; font-weight: 600; letter-spacing: .04em;
	color: var(--primary); background: var(--surface-alt);
	border: 1px solid var(--border-strong); border-radius: 999px; padding: 2px 9px;
}

.search { margin-left: auto; position: relative; width: min(320px, 42vw); }
.search input {
	width: 100%; height: 36px; padding: 0 12px;
	font: inherit; font-size: 14px; color: var(--text);
	background: var(--surface); border: 1px solid var(--border-strong);
	border-radius: var(--radius-sm);
}
.search input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.search-results {
	position: absolute; top: 42px; right: 0; width: min(460px, 86vw);
	max-height: 60vh; overflow-y: auto;
	background: var(--surface); border: 1px solid var(--border-strong);
	border-radius: var(--radius); box-shadow: 0 12px 32px rgba(47, 42, 34, .14);
	padding: 6px;
}
.search-results a { display: block; padding: 9px 12px; border-radius: var(--radius-sm); color: var(--text); }
.search-results a:hover, .search-results a.is-sel { background: var(--surface-alt); text-decoration: none; }
.search-results strong { display: block; font-size: 14px; font-weight: 600; }
.search-results span { display: block; font-size: 12.5px; color: var(--text-muted); }
.search-empty { padding: 14px; color: var(--text-muted); font-size: 14px; }

.menu-btn {
	display: none; flex-direction: column; gap: 4px; justify-content: center;
	width: 34px; height: 34px; padding: 0 6px;
	background: none; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer;
}
.menu-btn span { display: block; height: 2px; background: var(--text); border-radius: 2px; }

/* ---------- Layout ---------- */
.shell { display: flex; align-items: flex-start; }

.sidebar {
	position: sticky; top: var(--topbar-h);
	width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
	height: calc(100vh - var(--topbar-h));
	overflow-y: auto;
	padding: 26px 14px 40px 20px;
	border-right: 1px solid var(--border);
}
.nav-group { margin-bottom: 22px; }
.nav-heading {
	margin: 0 0 7px 10px; font-size: 11px; font-weight: 600;
	letter-spacing: .09em; text-transform: uppercase; color: var(--text-faint);
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li a {
	display: flex; align-items: baseline; gap: 7px;
	padding: 6px 10px; border-radius: var(--radius-sm);
	color: var(--text-muted); font-size: 14.5px;
}
.sidebar li a:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }
.sidebar li a.is-active {
	background: var(--surface-alt); color: var(--text); font-weight: 600;
	box-shadow: inset 2px 0 0 var(--primary);
}
.nav-pkg { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }

main {
	flex: 1 1 auto; min-width: 0;
	display: flex; gap: 32px; align-items: flex-start;
	padding: 34px 28px 90px;
}
.doc { flex: 1 1 auto; min-width: 0; max-width: var(--content-max); }

/* ---------- Cabecera de pagina ---------- */
.doc-head { margin-bottom: 22px; }
.doc-pkg { margin: 0 0 8px; }
.doc-pkg code {
	font-family: var(--font-mono); font-size: 12.5px; color: var(--primary);
	background: var(--surface-alt); border: 1px solid var(--border);
	border-radius: 999px; padding: 3px 11px;
}
.doc h1 {
	font-family: var(--font-display); font-weight: 600;
	font-size: 38px; line-height: 1.12; letter-spacing: -.02em; margin: 0;
}
.doc-tagline { margin: 10px 0 0; font-size: 17px; color: var(--text-muted); }

/* ---------- Pestañas ---------- */
.tabs {
	display: flex; gap: 4px; margin: 26px 0 0;
	border-bottom: 1px solid var(--border);
}
.tabs button {
	appearance: none; background: none; border: 0; cursor: pointer;
	font: inherit; font-size: 14.5px; font-weight: 500; color: var(--text-muted);
	padding: 9px 15px; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
	border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--text); background: var(--surface-alt); }
.tabs button[aria-selected="true"] { color: var(--text); font-weight: 600; border-bottom-color: var(--primary); }
.tabs button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.panel { padding-top: 26px; }
/* Sin JS las dos secciones se muestran seguidas: la doc sigue siendo legible. */
.panel[hidden] { display: none; }

/* ---------- Contenido ---------- */
.doc h2 {
	font-family: var(--font-display); font-weight: 600; font-size: 25px;
	letter-spacing: -.01em; margin: 38px 0 12px; scroll-margin-top: 80px;
}
.doc h2:first-child { margin-top: 0; }
.doc h3 { font-size: 17px; font-weight: 600; margin: 26px 0 8px; scroll-margin-top: 80px; }
.anchor { margin-left: 8px; color: var(--text-faint); font-weight: 400; opacity: 0; transition: opacity .12s; }
.doc h2:hover .anchor { opacity: 1; }

.doc p { margin: 0 0 14px; }
.doc ul, .doc ol { margin: 0 0 14px; padding-left: 22px; }
.doc li { margin-bottom: 6px; }
.doc li::marker { color: var(--text-faint); }

.doc :not(pre) > code {
	font-family: var(--font-mono); font-size: .88em;
	background: var(--surface-alt); border: 1px solid var(--border);
	border-radius: 5px; padding: 1.5px 5px;
}

.doc strong { font-weight: 600; }

/* ---------- Bloques de codigo ---------- */
.code {
	margin: 0 0 18px; border: 1px solid var(--border-strong);
	border-radius: var(--radius); overflow: hidden; background: #2b2721;
}
.code figcaption {
	display: flex; align-items: center; justify-content: space-between;
	padding: 7px 12px; background: #211e19; border-bottom: 1px solid #3a352c;
}
.code-lang { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: #a99f88; }
.copy {
	appearance: none; background: none; border: 1px solid #4a443a; color: #cfc7b4;
	font: inherit; font-size: 11.5px; padding: 2px 10px; border-radius: 5px; cursor: pointer;
}
.copy:hover { background: #322d26; color: #fff; }
.copy.done { color: #8fd6a4; border-color: #3f6b4c; }
.code pre { margin: 0; padding: 14px 16px; overflow-x: auto; }
.code code {
	font-family: var(--font-mono); font-size: 13px; line-height: 1.65;
	color: #ece5d6; white-space: pre;
}
.code .k { color: #d9a55f; }
.code .s { color: #9fc98a; }
.code .c { color: #7d7566; font-style: italic; }
.code .n { color: #cf9bd1; }

/* ---------- Callouts ---------- */
.callout {
	display: flex; flex-direction: column; gap: 4px;
	margin: 0 0 18px; padding: 13px 16px;
	border-left: 3px solid var(--primary); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
	background: var(--surface-alt); font-size: 14.5px;
}
.callout strong { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.callout div > :last-child { margin-bottom: 0; }
.callout--warn { border-left-color: var(--danger); background: var(--danger-soft); }
.callout--tip { border-left-color: var(--success); background: var(--success-soft); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; margin: 0 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
td code { white-space: nowrap; }

/* ---------- Lista de API ---------- */
.api { margin: 0 0 18px; }
.api dt { margin-top: 14px; }
.api dt code {
	font-family: var(--font-mono); font-size: 13px; color: var(--text);
	background: var(--surface-alt); border: 1px solid var(--border);
	border-radius: var(--radius-sm); padding: 3px 8px; display: inline-block;
	white-space: pre-wrap;
}
.api dd { margin: 6px 0 0; padding-left: 2px; color: var(--text-muted); font-size: 14.5px; }

/* ---------- Grid de tarjetas (portada) ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 14px; margin: 0 0 22px; }
.card {
	display: block; padding: 16px 18px; background: var(--surface);
	border: 1px solid var(--border); border-radius: var(--radius); color: var(--text);
}
.card:hover { border-color: var(--primary); text-decoration: none; color: var(--text); box-shadow: 0 4px 14px rgba(47, 42, 34, .06); }
.card b { display: block; font-size: 15px; margin-bottom: 3px; }
.card code { font-family: var(--font-mono); font-size: 11.5px; color: var(--primary); }
.card span { display: block; font-size: 13.5px; color: var(--text-muted); margin-top: 5px; }

/* ---------- Prev / next ---------- */
.prevnext { display: flex; justify-content: space-between; gap: 14px; margin-top: 52px; padding-top: 22px; border-top: 1px solid var(--border); }
.pn {
	display: flex; flex-direction: column; gap: 2px; padding: 12px 16px;
	border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
	max-width: 48%;
}
.pn:hover { border-color: var(--primary); text-decoration: none; }
.pn span { font-size: 12px; color: var(--text-faint); }
.pn strong { font-size: 14.5px; color: var(--text); font-weight: 600; }
.pn--next { text-align: right; margin-left: auto; }

/* ---------- Indice lateral derecho ---------- */
.toc {
	position: sticky; top: calc(var(--topbar-h) + 34px);
	width: var(--toc-w); flex: 0 0 var(--toc-w);
	max-height: calc(100vh - var(--topbar-h) - 60px); overflow-y: auto;
	font-size: 13.5px;
}
.toc-title { margin: 0 0 8px; font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--text-faint); }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin-bottom: 3px; }
.toc-sep { margin-top: 12px !important; font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--text-faint); }
.toc a { display: block; padding: 3px 10px; border-left: 2px solid var(--border); color: var(--text-muted); }
.toc a:hover { color: var(--text); border-left-color: var(--border-strong); text-decoration: none; }
.toc a.is-active { color: var(--text); border-left-color: var(--primary); font-weight: 500; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
	.toc { display: none; }
}
@media (max-width: 860px) {
	.menu-btn { display: flex; }
	.sidebar {
		position: fixed; top: var(--topbar-h); left: 0; z-index: 30;
		height: calc(100vh - var(--topbar-h));
		background: var(--surface); box-shadow: 0 10px 40px rgba(47, 42, 34, .16);
		transform: translateX(-100%); transition: transform .18s ease;
	}
	.sidebar.is-open { transform: none; }
	main { padding: 26px 18px 70px; }
	.doc h1 { font-size: 30px; }
	.search { width: auto; flex: 1 1 auto; }
	.brand-name, .version { display: none; }
}
