/**
 * Nexus KB — theme styles.
 *
 * Order: reset, focus system, layout, banner, navigation, search, content,
 * footer, utilities, print, forced colours.
 *
 * The focus system sits second, immediately after the reset, because it is
 * the one thing in this file that must never be accidentally overridden by
 * something later.
 */

/* ---------------------------------------------------------------- Reset */

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

body {
	margin: 0;
	background: var(--nkbt-paper);
	color: var(--nkbt-ink);
	font-family: var(--nkbt-sans);
	font-size: var(--nkbt-scale-base);
	line-height: 1.65;
	-webkit-text-size-adjust: 100%;
	text-underline-offset: 0.16em;
}

img,
svg,
video {
	max-width: 100%;
	height: auto;
}

/* ------------------------------------------------------- Focus: signature */

/**
 * Two layers. The inner ring reads against light surfaces, the outer yellow
 * bar against dark ones, so one treatment works everywhere and nobody has
 * to remember to write a variant.
 *
 * :focus-visible rather than :focus, so mouse users are not given a ring
 * they did not ask for — but the fallback below covers browsers without
 * :focus-visible, because no ring at all is far worse than an unwanted one.
 */

:focus {
	outline: var(--nkbt-focus-width) solid var(--nkbt-focus-inner);
	outline-offset: 0.125rem;
}

@supports selector( :focus-visible ) {
	:focus {
		outline: none;
	}

	:focus-visible {
		outline: var(--nkbt-focus-width) solid var(--nkbt-focus-inner);
		outline-offset: 0.125rem;
		box-shadow: 0 0 0 calc( var(--nkbt-focus-width) * 2 ) var(--nkbt-focus-outer);
		border-radius: 0.125rem;
	}
}

/**
 * WCAG 2.2 SC 2.4.11 — a focused element must not be hidden behind sticky
 * furniture. The banner is not sticky here, but plugin pages use a sticky
 * contents rail, so every scroll target keeps clear air above it.
 */
:target,
[id] {
	scroll-margin-top: 1.5rem;
}

/* -------------------------------------------------------------- Skip links */

.nkbt-skip ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.nkbt-skip a {
	position: absolute;
	left: -9999px;
	z-index: 1000;
	padding: 0.75rem 1.25rem;
	background: var(--nkbt-navy);
	color: #fff;
	font-weight: 500;
	text-decoration: underline;
}

.nkbt-skip a:focus {
	left: 0.5rem;
	top: 0.5rem;
}

/* ------------------------------------------------------------------ Layout */

.nkbt-content {
	display: block;
	max-width: 76rem;
	margin: 0 auto;
	padding: 2rem 1.25rem 4rem;
}

.nkbt-content:focus {
	outline: none;
}

.nkbt-prose {
	max-width: var(--nkbt-measure);
}

/* ------------------------------------------------------------------ Banner */

.nkbt-banner {
	border-bottom: 1px solid var(--nkbt-rule);
	background: var(--nkbt-paper);
}

.nkbt-banner__inner {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem 1.5rem;
	align-items: flex-end;
	max-width: 76rem;
	margin: 0 auto;
	padding: 1.25rem;
}

.nkbt-brand {
	margin: 0;
	flex: 1 1 14rem;
}

.nkbt-brand a {
	text-decoration: none;
	color: inherit;
	display: inline-block;
}

.nkbt-brand a:hover .nkbt-brand__name {
	text-decoration: underline;
}

.nkbt-brand__name {
	display: block;
	font-size: var(--nkbt-scale-xl);
	font-weight: 600;
	letter-spacing: -0.01em;
	color: var(--nkbt-navy);
}

.nkbt-brand__tag {
	display: block;
	font-size: var(--nkbt-scale-xs);
	color: var(--nkbt-ink-faint);
	margin-top: 0.15rem;
}

.nkbt-banner__search {
	flex: 1 1 22rem;
	max-width: 34rem;
}

/* -------------------------------------------------------------- Navigation */

.nkbt-nav {
	border-top: 1px solid var(--nkbt-rule);
	background: var(--nkbt-wash);
}

.nkbt-nav__list {
	display: flex;
	flex-wrap: wrap;
	list-style: none;
	max-width: 76rem;
	margin: 0 auto;
	padding: 0 1.25rem;
	gap: 0.25rem;
}

.nkbt-nav__list a {
	display: flex;
	align-items: center;
	/* SC 2.5.8 — every target clears the 24px minimum with room to spare. */
	min-height: var(--nkbt-tap);
	padding: 0 0.85rem;
	font-size: var(--nkbt-scale-sm);
	color: var(--nkbt-ink-soft);
	text-decoration: none;
	border-bottom: 0.1875rem solid transparent;
}

.nkbt-nav__list a:hover {
	color: var(--nkbt-navy);
	text-decoration: underline;
}

.nkbt-nav__list a[aria-current] {
	color: var(--nkbt-navy);
	font-weight: 500;
	border-bottom-color: var(--nkbt-navy);
}

.nkbt-nav-toggle {
	display: none;
	font: inherit;
	font-size: var(--nkbt-scale-sm);
	min-height: var(--nkbt-tap);
	padding: 0 1rem;
	background: var(--nkbt-paper);
	color: var(--nkbt-ink);
	border: 1px solid var(--nkbt-rule-strong);
	border-radius: var(--nkbt-radius);
	cursor: pointer;
}

@media ( max-width: 48rem ) {
	.nkbt-nav-toggle {
		display: block;
	}

	.nkbt-nav[hidden] {
		display: none;
	}

	.nkbt-nav__list {
		flex-direction: column;
		padding: 0.5rem 1.25rem;
	}

	.nkbt-nav__list a {
		border-bottom: 0;
		border-left: 0.1875rem solid transparent;
		padding-left: 0.75rem;
	}

	.nkbt-nav__list a[aria-current] {
		border-left-color: var(--nkbt-navy);
	}
}

/* ------------------------------------------------------------------ Search */

.nkbt-search__label {
	display: block;
	font-size: var(--nkbt-scale-xs);
	font-weight: 500;
	color: var(--nkbt-ink-soft);
	margin-bottom: 0.3rem;
}

.nkbt-search__row {
	display: flex;
	gap: 0.5rem;
}

.nkbt-search__input {
	flex: 1;
	min-width: 0;
	font: inherit;
	font-size: var(--nkbt-scale-base);
	min-height: var(--nkbt-tap);
	padding: 0.4rem 0.75rem;
	color: var(--nkbt-ink);
	background: var(--nkbt-paper);
	border: 1px solid var(--nkbt-rule-strong);
	border-radius: var(--nkbt-radius);
}

.nkbt-search__submit {
	font: inherit;
	font-size: var(--nkbt-scale-sm);
	font-weight: 500;
	min-height: var(--nkbt-tap);
	padding: 0 1.25rem;
	color: #fff;
	background: var(--nkbt-navy);
	border: 1px solid var(--nkbt-navy);
	border-radius: var(--nkbt-radius);
	cursor: pointer;
}

.nkbt-search__submit:hover {
	background: var(--nkbt-link-hover);
	border-color: var(--nkbt-link-hover);
}

.nkbt-search__hint {
	font-size: var(--nkbt-scale-xs);
	color: var(--nkbt-ink-faint);
	margin: 0.35rem 0 0;
}

.nkbt-banner__search .nkbt-search__hint {
	display: none;
}

/* ----------------------------------------------------------------- Content */

h1,
h2,
h3,
h4 {
	color: var(--nkbt-navy);
	line-height: 1.25;
	font-weight: 600;
	margin: 2rem 0 0.75rem;
	max-width: var(--nkbt-measure);
}

h1 {
	font-size: var(--nkbt-scale-3xl);
	letter-spacing: -0.015em;
	margin-top: 0;
}

h2 {
	font-size: var(--nkbt-scale-2xl);
}

h3 {
	font-size: var(--nkbt-scale-lg);
}

p,
ul,
ol,
dl {
	max-width: var(--nkbt-measure);
}

a {
	color: var(--nkbt-link);
	text-decoration-thickness: 0.0625rem;
}

a:hover {
	color: var(--nkbt-link-hover);
	text-decoration-thickness: 0.125rem;
}

a:visited {
	color: var(--nkbt-visited);
}

code,
kbd,
samp,
pre {
	font-family: var(--nkbt-mono);
	font-size: 0.9em;
}

:not( pre ) > code {
	background: var(--nkbt-wash);
	padding: 0.1em 0.35em;
	border-radius: 0.1875rem;
}

pre {
	background: var(--nkbt-wash);
	border: 1px solid var(--nkbt-rule);
	border-radius: var(--nkbt-radius);
	padding: 1rem;
	overflow-x: auto;
	max-width: 100%;
}

blockquote {
	margin: 1.5rem 0;
	padding-left: 1rem;
	border-left: 0.1875rem solid var(--nkbt-rule-strong);
	color: var(--nkbt-ink-soft);
}

table {
	width: 100%;
	border-collapse: collapse;
	font-size: var(--nkbt-scale-sm);
}

th,
td {
	text-align: left;
	padding: 0.6rem 0.85rem;
	border-bottom: 1px solid var(--nkbt-rule);
	vertical-align: top;
}

thead th {
	background: var(--nkbt-wash);
	font-size: var(--nkbt-scale-xs);
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--nkbt-ink-soft);
}

hr {
	border: 0;
	border-top: 1px solid var(--nkbt-rule);
	margin: 2.5rem 0;
}

/* ---------------------------------------------------------------- Footer */

.nkbt-footer {
	border-top: 1px solid var(--nkbt-rule);
	background: var(--nkbt-wash);
	margin-top: 4rem;
}

.nkbt-footer__inner {
	max-width: 76rem;
	margin: 0 auto;
	padding: 2rem 1.25rem;
}

.nkbt-footer__list {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1.25rem;
	list-style: none;
	margin: 0 0 1rem;
	padding: 0;
	font-size: var(--nkbt-scale-sm);
}

.nkbt-footer__list a {
	display: inline-flex;
	align-items: center;
	min-height: var(--nkbt-tap);
	color: var(--nkbt-ink-soft);
}

.nkbt-footer__meta {
	font-size: var(--nkbt-scale-sm);
	color: var(--nkbt-ink-soft);
	margin: 0 0 0.35rem;
}

.nkbt-footer__build {
	font-family: var(--nkbt-mono);
	font-size: var(--nkbt-scale-xs);
	color: var(--nkbt-ink-faint);
	margin: 0;
}

/* -------------------------------------------------------------- Utilities */

.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	clip-path: inset( 50% );
	white-space: nowrap;
	border: 0;
}

.screen-reader-text:focus {
	position: static !important;
	width: auto;
	height: auto;
	margin: 0;
	overflow: visible;
	clip: auto;
	clip-path: none;
	white-space: normal;
}

.nkbt-pagination {
	margin-top: 2.5rem;
	padding-top: 1.5rem;
	border-top: 1px solid var(--nkbt-rule);
}

.nkbt-pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: var(--nkbt-tap);
	min-height: var(--nkbt-tap);
	padding: 0 0.5rem;
	text-decoration: none;
	border-radius: var(--nkbt-radius);
}

.nkbt-pagination .current {
	background: var(--nkbt-navy);
	color: #fff;
	font-weight: 500;
}

/* ------------------------------------------------------------------ Motion */

/**
 * Motion is opt-in, not opt-out. Nothing in this theme animates by default,
 * so this block exists to catch anything the plugin or editor introduces.
 */
@media ( prefers-reduced-motion: reduce ) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}

/* --------------------------------------------------------- Forced colours */

/**
 * Windows high-contrast mode discards author colours. Borders and outlines
 * survive, so anything that carried meaning through colour alone must be
 * restated here — otherwise the current nav item and the focus ring both
 * vanish for the readers who need them most.
 */
@media ( forced-colors: active ) {
	:focus-visible {
		outline: 0.1875rem solid CanvasText;
		outline-offset: 0.125rem;
		box-shadow: none;
	}

	.nkbt-nav__list a[aria-current] {
		border-bottom-color: LinkText;
		forced-color-adjust: none;
	}

	.nkbt-search__submit,
	.nkbt-pagination .current {
		border: 0.125rem solid ButtonText;
	}

	.nkbt-skip a {
		border: 0.125rem solid CanvasText;
	}
}

/* ------------------------------------------------------------------ Print */

@media print {
	.nkbt-skip,
	.nkbt-nav,
	.nkbt-nav-toggle,
	.nkbt-banner__search,
	.nkbt-footer__nav {
		display: none;
	}

	body {
		font-size: 11pt;
		color: #000;
		background: #fff;
	}

	/* Print the destination of every link — a printed spec is useless if
	   its cross-references are invisible. */
	.nkbt-content a[href^="http"]::after {
		content: " (" attr( href ) ")";
		font-size: 0.85em;
		word-break: break-all;
	}

	pre,
	table {
		page-break-inside: avoid;
	}
}
