/*
 * WDM Documentation Template - front-end design system
 * Light mode only, per brief. Brand Red is reserved for the flow rail,
 * critical severity, and hover/active states - everywhere else stays quiet.
 *
 * Type roles:
 *   Display  - Space Grotesk (headings, hero, module labels)
 *   Body     - Inter (paragraphs, list items, nav)
 *   Utility  - IBM Plex Mono (file/class references in "Where to Look")
 *
 * If self-hosting fonts is preferred over this CDN import (perf/GDPR),
 * swap this @import for local @font-face rules - nothing else changes.
 */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

/*
 * Tokens are declared on both selectors so the standalone <body> (which is
 * outside .wdm-doc-theme) can use them too - see templates/parts/shell-open.php.
 */
.wdm-doc-theme,
body.wdm-doc-standalone {
	--wdm-red: #A30000;
	--wdm-red-soft: #A3000014;
	--wdm-primary-dark: #2C2C2C;
	--wdm-text-dark: #1C1C1C;
	--wdm-text-secondary: #555555;
	--wdm-light-gray: #CCCCCC;
	--wdm-off-white: #F0EFF0;
	--wdm-white: #FFFFFF;
	--wdm-border: #D9D9D9;

	--wdm-font-display: 'Space Grotesk', 'Arial Black', sans-serif;
	--wdm-font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	--wdm-font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

	--wdm-radius: 10px;
	--wdm-radius-sm: 6px;
	--wdm-shadow: 0 1px 2px rgba(28,28,28,0.04), 0 6px 20px rgba(28,28,28,0.05);

	color: var(--wdm-text-dark);
	font-family: var(--wdm-font-body);
	background: var(--wdm-white);
	-webkit-font-smoothing: antialiased;
}

.wdm-doc-theme * { box-sizing: border-box; }

/* ---------- Standalone shell ----------
 * We own <html>/<body> now, but the active theme's global stylesheet still
 * loads through wp_head() and can put a margin, padding, or max-width on
 * body. Neutralize just enough that our own layout owns the page.
 */
body.wdm-doc-standalone {
	margin: 0;
	padding: 0;
	background: var(--wdm-white);
}

.wdm-doc-container {
	max-width: 1180px;
	margin: 0 auto;
	padding: 0 24px;
}

/* The issue page carries three columns, so it gets the full 90% of the
 * viewport instead of the archive's fixed 1180px. The 5% gutters either side
 * replace the container padding rather than eating into the 90%. */
.wdm-doc-single .wdm-doc-container {
	width: 90%;
	max-width: none;
	padding: 0;
}

/* ---------- Hero ---------- */
.wdm-doc-hero {
	background: var(--wdm-off-white);
	border-bottom: 1px solid var(--wdm-border);
	padding: 56px 0 40px;
}

.wdm-doc-eyebrow {
	font-family: var(--wdm-font-mono);
	font-size: 12px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--wdm-red);
	margin: 0 0 10px;
	font-weight: 500;
}

.wdm-doc-hero-title {
	font-family: var(--wdm-font-display);
	font-size: 40px;
	font-weight: 700;
	color: var(--wdm-text-dark);
	margin: 0 0 10px;
	letter-spacing: -0.01em;
}

.wdm-doc-hero-sub {
	font-size: 16px;
	color: var(--wdm-text-secondary);
	margin: 0 0 28px;
	max-width: 560px;
}

.wdm-doc-search {
	display: flex;
	max-width: 520px;
	background: var(--wdm-white);
	border: 1px solid var(--wdm-border);
	border-radius: var(--wdm-radius);
	overflow: hidden;
	box-shadow: var(--wdm-shadow);
}

.wdm-doc-search input[type="search"] {
	flex: 1;
	border: 0;
	padding: 14px 16px;
	font-family: var(--wdm-font-body);
	font-size: 14px;
	color: var(--wdm-text-dark);
	outline: none;
	background: transparent;
}

.wdm-doc-search button {
	border: 0;
	background: var(--wdm-primary-dark);
	color: var(--wdm-white);
	padding: 0 22px;
	font-family: var(--wdm-font-body);
	font-weight: 600;
	font-size: 14px;
	cursor: pointer;
	transition: background 0.15s ease;
}

.wdm-doc-search button:hover,
.wdm-doc-search button:focus-visible {
	background: var(--wdm-red);
}

.wdm-doc-search--embed {
	max-width: 380px;
	margin: 0;
}

/* ---------- Breadcrumb ---------- */
.wdm-doc-breadcrumb-fallback {
	font-size: 13px;
	color: var(--wdm-text-secondary);
	padding: 18px 0 0;
}

.wdm-doc-breadcrumb-fallback a {
	color: var(--wdm-text-secondary);
	text-decoration: none;
}

.wdm-doc-breadcrumb-fallback a:hover { color: var(--wdm-red); }

.wdm-doc-breadcrumb-fallback span { color: var(--wdm-text-dark); font-weight: 500; }

/* ---------- Layout ---------- */
.wdm-doc-layout {
	display: grid;
	grid-template-columns: 240px 1fr;
	gap: 40px;
	padding: 32px 0 80px;
	align-items: start;
}

/* Issue Tree | content | At a Glance + On This Page. Both rails are clamped
 * rather than fixed so the middle column keeps a readable measure across the
 * whole range this layout is allowed at (>= 1200px, see Responsive). */
.wdm-doc-single-layout {
	display: grid;
	grid-template-columns: clamp(220px, 17vw, 280px) minmax(0, 1fr) clamp(240px, 19vw, 300px);
	gap: clamp(24px, 2.2vw, 44px);
	padding: 12px 0 80px;
	align-items: start;
}

/* A doc with no parent and no children has no Issue Tree to show, and the left
 * aside is not rendered at all - so drop its column instead of leaving a gap. */
.wdm-doc-single-layout--no-tree {
	grid-template-columns: minmax(0, 1fr) clamp(240px, 19vw, 300px);
}

/* The whole aside sticks, not an individual panel. Capped to the viewport with
 * its own scroll so a long tree or outline can't run off-screen. Applies to
 * both rails. */
.wdm-doc-single-sidebar {
	position: sticky;
	top: 24px;
	max-height: calc(100vh - 48px);
	overflow-y: auto;
	overscroll-behavior: contain;
}

/* ---------- Sidebar / panels ---------- */
.wdm-doc-panel {
	background: var(--wdm-white);
	border: 1px solid var(--wdm-border);
	border-radius: var(--wdm-radius);
	padding: 20px;
	margin-bottom: 20px;
}

.wdm-doc-panel--sticky { position: sticky; top: 24px; }

.wdm-doc-panel-title {
	font-family: var(--wdm-font-display);
	font-size: 13px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--wdm-text-secondary);
	margin: 0 0 14px;
	font-weight: 600;
}

/* ---------- Sidebar trees ----------
 * Shared by "On This Page" (content outline) and "Issue Tree" (doc hierarchy).
 * Nesting is expressed with a guide rail on the nested <ul> rather than bullets
 * or indentation alone, so depth stays readable at small type sizes.
 */
.wdm-doc-tree,
.wdm-doc-tree ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.wdm-doc-tree ul {
	margin: 2px 0 2px 9px;
	padding-left: 11px;
	border-left: 1px solid var(--wdm-border);
}

.wdm-doc-tree-item { margin: 0; }

.wdm-doc-tree-link {
	display: block;
	padding: 5px 8px 5px 10px;
	margin-left: -10px;
	border-radius: var(--wdm-radius-sm);
	font-size: 13.5px;
	line-height: 1.4;
	color: var(--wdm-text-secondary);
	text-decoration: none;
	border-left: 2px solid transparent;
	transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.wdm-doc-tree-link:hover {
	color: var(--wdm-red);
	background: var(--wdm-off-white);
}

/* Top-level nodes carry a bit more weight than their nested children. */
.wdm-doc-tree--depth-0 > .wdm-doc-tree-item > .wdm-doc-tree-link,
.wdm-doc-tree--issues > .wdm-doc-tree-item > .wdm-doc-tree-link {
	font-weight: 600;
	color: var(--wdm-text-dark);
	font-size: 14px;
}

/* is-active = scroll position (outline, set by JS); is-current = the doc you
 * are on (issue tree, set server-side). Both use the brand rail. */
.wdm-doc-tree-link.is-active,
.wdm-doc-tree-link.is-current {
	color: var(--wdm-red);
	border-left-color: var(--wdm-red);
	background: var(--wdm-red-soft);
	font-weight: 600;
}

.wdm-doc-tree-link.is-current { cursor: default; }

.wdm-doc-panel--tree { padding: 18px; }

.wdm-doc-pills { display: flex; flex-wrap: wrap; gap: 8px; }

.wdm-doc-pill {
	display: inline-block;
	padding: 6px 14px;
	border-radius: 999px;
	background: var(--wdm-off-white);
	color: var(--wdm-text-dark);
	font-size: 13px;
	font-weight: 500;
	text-decoration: none;
	border: 1px solid transparent;
	transition: border-color 0.15s ease, color 0.15s ease;
}

.wdm-doc-pill:hover { border-color: var(--wdm-red); color: var(--wdm-red); }

.wdm-doc-pill.is-active {
	background: var(--wdm-primary-dark);
	color: var(--wdm-white);
}

.wdm-doc-jumpnav { display: flex; flex-direction: column; gap: 4px; }

.wdm-doc-jumpnav a {
	font-size: 14px;
	color: var(--wdm-text-dark);
	text-decoration: none;
	padding: 6px 8px;
	border-radius: var(--wdm-radius-sm);
}

.wdm-doc-jumpnav a:hover { background: var(--wdm-off-white); color: var(--wdm-red); }

/* ---------- Module sections / accordion ---------- */
.wdm-doc-module-section {
	margin-bottom: 28px;
	scroll-margin-top: 24px;
}

.wdm-doc-module-toggle {
	width: 100%;
	display: flex;
	align-items: center;
	gap: 10px;
	background: transparent;
	border: none;
	border-bottom: 2px solid var(--wdm-text-dark);
	padding: 0 0 10px;
	margin-bottom: 18px;
	cursor: pointer;
	text-align: left;
}

.wdm-doc-module-name {
	font-family: var(--wdm-font-display);
	font-size: 20px;
	font-weight: 600;
	color: var(--wdm-text-dark);
}

.wdm-doc-module-count {
	font-family: var(--wdm-font-mono);
	font-size: 12px;
	color: var(--wdm-white);
	background: var(--wdm-red);
	border-radius: 999px;
	padding: 2px 9px;
}

.wdm-doc-chevron {
	margin-left: auto;
	width: 10px;
	height: 10px;
	border-right: 2px solid var(--wdm-text-secondary);
	border-bottom: 2px solid var(--wdm-text-secondary);
	transform: rotate(45deg);
	transition: transform 0.2s ease;
}

.wdm-doc-module-section.is-collapsed .wdm-doc-chevron { transform: rotate(-45deg); }
.wdm-doc-module-section.is-collapsed .wdm-doc-card-grid { display: none; }

/* ---------- Cards ---------- */
.wdm-doc-card-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 16px;
}

.wdm-doc-card {
	display: flex;
	flex-direction: column;
	gap: 8px;
	background: var(--wdm-white);
	border: 1px solid var(--wdm-border);
	border-radius: var(--wdm-radius);
	padding: 18px;
	text-decoration: none;
	color: inherit;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.wdm-doc-card:hover {
	border-color: var(--wdm-red);
	box-shadow: var(--wdm-shadow);
	transform: translateY(-1px);
}

.wdm-doc-card-title {
	font-family: var(--wdm-font-display);
	font-size: 16px;
	font-weight: 600;
	margin: 0;
	color: var(--wdm-text-dark);
}

.wdm-doc-card-excerpt {
	font-size: 13px;
	color: var(--wdm-text-secondary);
	margin: 0;
	line-height: 1.5;
}

.wdm-doc-card-link {
	margin-top: auto;
	font-size: 13px;
	font-weight: 600;
	color: var(--wdm-red);
}

/* ---------- Badges / tags ----------
 * .wdm-doc-badge   = a wdm_doc_tag term (several per doc)
 * .wdm-doc-tag     = the wdm_doc_module chip on the single page (one per doc).
 *   Yes, the class names read backwards since the taxonomy rename - they are
 *   style hooks only, kept as-is so the rename stayed a one-file change.
 */
.wdm-doc-badges {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	align-self: flex-start;
}

.wdm-doc-badge {
	display: inline-block;
	align-self: flex-start;
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	padding: 3px 10px;
	border-radius: 999px;
	text-decoration: none;
	background: var(--wdm-off-white);
	color: var(--wdm-text-secondary);
}

.wdm-doc-badge--blocks-all-users { background: var(--wdm-red-soft); color: var(--wdm-red); }
.wdm-doc-badge--single-site { background: #2c2c2c14; color: var(--wdm-primary-dark); }
.wdm-doc-badge--cosmetic { background: var(--wdm-off-white); color: var(--wdm-text-secondary); }

.wdm-doc-tag {
	display: inline-block;
	font-size: 12px;
	font-weight: 600;
	color: var(--wdm-primary-dark);
	background: var(--wdm-off-white);
	padding: 4px 12px;
	border-radius: 999px;
	text-decoration: none;
}

.wdm-doc-tag:hover { color: var(--wdm-red); }

/* ---------- Single: header ---------- */
.wdm-doc-single-header { padding: 28px 0 8px; }

.wdm-doc-single-meta { display: flex; gap: 10px; margin-bottom: 14px; }

.wdm-doc-single-title {
	font-family: var(--wdm-font-display);
	font-size: 34px;
	font-weight: 700;
	color: var(--wdm-text-dark);
	margin: 0;
	letter-spacing: -0.01em;
}

/* ---------- Sections ---------- */
.wdm-doc-section { margin-bottom: 32px; }

.wdm-doc-section-title {
	font-family: var(--wdm-font-display);
	font-size: 16px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--wdm-text-dark);
	margin: 0 0 12px;
}

.wdm-doc-symptom p { font-size: 15px; line-height: 1.7; color: var(--wdm-text-dark); }

.wdm-doc-code-box {
	background: var(--wdm-off-white);
	border: 1px solid var(--wdm-border);
	border-radius: var(--wdm-radius-sm);
	padding: 14px 16px;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.wdm-doc-code-box code {
	font-family: var(--wdm-font-mono);
	font-size: 13px;
	color: var(--wdm-primary-dark);
	background: none;
}

/* ---------- Signature: flow rail ---------- */
.wdm-doc-flow {
	position: relative;
	padding-left: 34px;
	margin: 40px 0;
}

.wdm-doc-flow::before {
	content: "";
	position: absolute;
	left: 15px;
	top: 6px;
	bottom: 6px;
	width: 2px;
	background: linear-gradient(to bottom, var(--wdm-red), var(--wdm-border));
}

.wdm-doc-flow-stage {
	position: relative;
	margin-bottom: 32px;
}

.wdm-doc-flow-marker {
	position: absolute;
	left: -34px;
	top: 0;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: var(--wdm-white);
	border: 2px solid var(--wdm-red);
	display: flex;
	align-items: center;
	justify-content: center;
}

.wdm-doc-flow-num {
	font-family: var(--wdm-font-mono);
	font-size: 13px;
	font-weight: 500;
	color: var(--wdm-red);
}

.wdm-doc-flow-stage--resolve .wdm-doc-flow-marker { background: var(--wdm-red); }
.wdm-doc-flow-stage--resolve .wdm-doc-flow-num { color: var(--wdm-white); }

.wdm-doc-flow-list {
	margin: 0;
	padding-left: 20px;
	font-size: 15px;
	line-height: 1.8;
	color: var(--wdm-text-dark);
}

.wdm-doc-flow-list li { margin-bottom: 4px; }

/* ---------- Related ---------- */
.wdm-doc-related-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 12px;
}

.wdm-doc-related-card {
	display: flex;
	justify-content: space-between;
	align-items: center;
	background: var(--wdm-off-white);
	border-radius: var(--wdm-radius-sm);
	padding: 12px 14px;
	font-size: 14px;
	font-weight: 500;
	color: var(--wdm-text-dark);
	text-decoration: none;
	transition: background 0.15s ease;
}

.wdm-doc-related-card:hover { background: var(--wdm-light-gray); color: var(--wdm-red); }

/* ---------- At-a-glance / buttons ---------- */
.wdm-doc-glance { margin: 0 0 18px; }
.wdm-doc-glance dt {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--wdm-text-secondary);
	margin-top: 12px;
}
.wdm-doc-glance dt:first-child { margin-top: 0; }
.wdm-doc-glance dd {
	margin: 2px 0 0;
	font-size: 14px;
	font-weight: 600;
	color: var(--wdm-text-dark);
}

.wdm-doc-btn {
	display: inline-block;
	width: 100%;
	text-align: center;
	padding: 10px 14px;
	border-radius: var(--wdm-radius-sm);
	font-size: 13px;
	font-weight: 600;
	text-decoration: none;
}

.wdm-doc-btn--ghost {
	border: 1px solid var(--wdm-border);
	color: var(--wdm-text-dark);
}

.wdm-doc-btn--ghost:hover { border-color: var(--wdm-red); color: var(--wdm-red); }

.wdm-doc-empty {
	color: var(--wdm-text-secondary);
	font-size: 15px;
	padding: 40px 0;
}

/* Anchor targets clear the admin bar / viewport edge when jumped to from the
 * outline. Applies to sections and to individual flow steps. */
.wdm-doc-section,
.wdm-doc-flow-stage,
.wdm-doc-flow-list li {
	scroll-margin-top: 56px;
}

@media (prefers-reduced-motion: no-preference) {
	html { scroll-behavior: smooth; }
}

/* ---------- Responsive ---------- */

/* The issue page collapses well before the archive does: three columns need
 * roughly 1200px before the middle one stops being readable. */
@media (max-width: 1199px) {
	.wdm-doc-single-layout,
	.wdm-doc-single-layout--no-tree { grid-template-columns: 1fr; }
	/* DOM order is left aside, main, right aside. Stacked, both asides belong
	 * above the content - an outline underneath what it indexes is useless. */
	.wdm-doc-single-sidebar--left { order: -2; }
	.wdm-doc-single-sidebar--right { order: -1; }
	/* Asides stop sticking and stop capping their height once stacked. */
	.wdm-doc-single-sidebar {
		position: static;
		max-height: none;
		overflow-y: visible;
	}
	/* But bound each tree so the stacked nav panels can't push the actual
	 * content off the first few screens. Scoped to the single page: this
	 * breakpoint is 1199px and the archive still has its sidebar up here. */
	.wdm-doc-single .wdm-doc-panel--tree .wdm-doc-tree {
		max-height: 38vh;
		overflow-y: auto;
	}
	.wdm-doc-single .wdm-doc-panel--tree .wdm-doc-tree .wdm-doc-tree {
		max-height: none;
		overflow-y: visible;
	}
}

@media (max-width: 860px) {
	.wdm-doc-layout { grid-template-columns: 1fr; }
	.wdm-doc-panel--sticky { position: static; }
	.wdm-doc-hero-title { font-size: 30px; }
	.wdm-doc-single-title { font-size: 26px; }
}
