/* Developer docs — page layout (single-doc_page block template). */

.doc-layout {
	--doc-line: var(--wp--preset--color--light-grey, #e1e7eb);
	--doc-muted: var(--wp--preset--color--text-muted, #68787c);
	--doc-ink: var(--wp--preset--color--dark-blue, #041c38);
	--doc-accent: var(--wp--preset--color--accent-blue, #287cd5);

	display: grid;
	grid-template-columns: 13rem minmax(0, 1fr);
	gap: 0 2rem;
	box-sizing: content-box;
	width: calc(100% - 2rem);
	max-width: none;
	margin: 0 auto;
	padding: 0 1rem;
	align-items: start;
}

.doc-layout > * {
	min-width: 0;
	margin-block-start: 0;
}

/* ---------- Sidebar ---------- */

.doc-nav {
	position: sticky;
	top: 0;
	max-height: 100vh;
	overflow-y: auto;
	overscroll-behavior: auto;
	padding: 2.5rem 1rem 3rem 0;
	border-right: 1px solid var(--doc-line);
	font-size: 0.9rem;
}

.admin-bar .doc-nav {
	top: 32px;
	max-height: calc(100vh - 32px);
}

.doc-nav__brand {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	margin-bottom: 2rem;
}

.doc-nav__set {
	font-weight: 600;
	color: var(--doc-ink);
	text-decoration: none;
	line-height: 1.3;
}

.doc-nav__version,
.doc-nav__version-select {
	flex: none;
	font-size: 0.75rem;
	font-weight: 600;
	color: var(--doc-muted);
	background: var(--wp--preset--color--surface-subtle, #f3f5f7);
	border: 1px solid var(--doc-line);
	border-radius: 999px;
	padding: 0.15rem 0.6rem;
	font-family: inherit;
}

.doc-nav__section + .doc-nav__section {
	margin-top: 1.75rem;
}

.doc-nav__label {
	margin: 0 0 0.5rem;
	font-size: 0.7rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--doc-muted);
}

.doc-nav ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.doc-nav__link {
	display: block;
	padding: 0.35rem 0.75rem;
	margin-left: -0.75rem;
	border-left: 2px solid transparent;
	color: var(--doc-ink);
	font-weight: 400;
	text-decoration: none;
	line-height: 1.4;
}

.doc-nav__link:hover {
	color: var(--doc-accent);
}

.doc-nav__link.is-active {
	border-left-color: var(--wp--preset--color--primary, #fc8902);
	background: var(--wp--preset--color--surface-subtle, #f3f5f7);
	font-weight: 600;
}

/* ---------- Main column ---------- */

.doc-main {
	padding: 2.5rem 0 5rem;
	max-width: none;
}

.doc-breadcrumb ol {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 0.5rem;
	list-style: none;
	margin: 0 0 1.5rem;
	padding: 0;
	font-size: 0.8rem;
	color: var(--doc-muted);
}

.doc-breadcrumb li + li::before {
	content: "/";
	margin-right: 0.5rem;
	opacity: 0.5;
}

.doc-breadcrumb a {
	color: inherit;
	font-weight: 400;
	text-decoration: none;
}

.doc-breadcrumb a:hover {
	color: var(--doc-accent);
}

.doc-main .doc-title {
	margin: 0 0 1.5rem;
	font-size: var(--wp--preset--font-size--huge);
	line-height: 1.15;
}

/* ---------- Previous / next ---------- */

.doc-pagination {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1rem;
	margin-top: 4rem;
	padding-top: 2rem;
	border-top: 1px solid var(--doc-line);
}

.doc-pagination__link {
	display: flex;
	flex-direction: column;
	gap: 0.2rem;
	padding: 1rem 1.25rem;
	border: 1px solid var(--doc-line);
	border-radius: 8px;
	text-decoration: none;
	transition: border-color 0.15s;
}

.doc-pagination__link:hover {
	border-color: var(--doc-accent);
}

.doc-pagination__link.is-next {
	grid-column: 2;
	text-align: right;
}

.doc-pagination__dir {
	font-size: 0.75rem;
	color: var(--doc-muted);
}

.doc-pagination__title {
	color: var(--doc-ink);
	font-weight: 600;
}

/* ---------- Mobile ---------- */

@media (max-width: 900px) {
	.doc-layout {
		grid-template-columns: minmax(0, 1fr);
	}

	.doc-nav,
	.admin-bar .doc-nav {
		position: static;
		top: auto;
		overflow: visible;
		overscroll-behavior: auto;
		max-height: none;
		padding: 1.5rem 0;
		border-right: 0;
		border-bottom: 1px solid var(--doc-line);
	}

	.doc-nav__section ul {
		display: flex;
		flex-wrap: wrap;
		gap: 0.25rem 1rem;
	}

	.doc-nav__link {
		margin-left: 0;
		padding: .65rem .5rem;
		min-height: 44px;
		box-sizing: border-box;
		border-left: 0;
	}

	.doc-nav__link.is-active {
		background: none;
		color: var(--doc-accent);
	}

	.doc-main {
		padding-top: 1.5rem;
	}
}

/* Navigation stays in normal document flow on phones and tablets. */
.doc-nav__toggle { display: none; }
.doc-nav :is(a, button, select):focus-visible { outline: 2px solid var(--doc-accent); outline-offset: 3px; }
@media (max-width: 900px) {
	.doc-layout { padding-inline: 1rem; }
	.doc-nav__brand { margin-bottom: .75rem; }
	.doc-nav[data-collapsed] .doc-nav__toggle {
		display: flex; align-items: center; justify-content: space-between;
		width: 100%; min-height: 44px; padding: .65rem .85rem;
		border: 1px solid var(--doc-line); border-radius: 6px;
		background: var(--wp--preset--color--surface-subtle, #f3f5f7);
		color: var(--doc-ink); font: inherit; font-weight: 600; cursor: pointer;
	}
	.doc-nav[data-collapsed="true"] .doc-nav__content { display: none; }
	.doc-nav[data-collapsed="false"] .doc-nav__toggle span { transform: rotate(180deg); }
	.doc-nav__content { padding-top: 1rem; }
	.doc-nav__version-select { min-height: 44px; font-size: 16px; }
	.doc-nav__section ul { display: block; }
	.doc-nav__link.is-active { background: var(--wp--preset--color--surface-subtle, #f3f5f7); border-radius: 4px; }
	.doc-pagination { gap: .5rem; }
	.doc-pagination__link { min-width: 0; padding: .85rem; overflow-wrap: anywhere; }
}

/* The theme reserves only 152px for header actions; the language control
   overflows that slot at small desktop widths. Size it to its contents. */
@media (min-width: 901px) {
	.single-doc_page .site-header-secondary-menu { width: auto; flex-shrink: 0; }
}

@media (pointer: coarse) {
	.doc-nav__link { min-height: 44px; box-sizing: border-box; padding-block: .65rem; }
	.doc-nav__version-select { min-height: 44px; font-size: 16px; }
}

/* Match the global header's content width and 1rem side padding. */
@media (min-width: 1200px) {
	.doc-layout { max-width: var(--alignwide, 90rem); }
}
@media (max-width: 1199px) {
	.single-doc_page .doc-layout {
		width: auto;
		max-width: none;
		/* Escape the theme’s root padding, as the full-width header does. */
		margin-inline: calc(50% - 50vw);
	}
}
