/**
 * Kelverse Knowledge Base — public styles.
 *
 * Deliberately small and unopinionated: the theme owns typography and
 * colour, this only lays things out. Everything is scoped to .kkb so a
 * theme override can drop it entirely.
 *
 * Colour rule (KD-14): every colour here is derived from `currentColor`,
 * the text colour the theme already set. There is deliberately no
 * `prefers-color-scheme` block. That query says what the visitor's system
 * prefers, not what this page renders — and a plugin that only lays out
 * content has no way to know the second from the first.
 */

.kkb {
	--kkb-gap: 1.5rem;
	--kkb-radius: 8px;
	/* Fallbacks first, for a browser without color-mix; the page is far more
	   often light than dark, so a light-page guess is the safer one to land on. */
	--kkb-line: rgba(0, 0, 0, 0.14);
	--kkb-line: color-mix(in srgb, currentColor 18%, transparent);
	--kkb-border: 1px solid var(--kkb-line);
	--kkb-muted: rgba(0, 0, 0, 0.62);
	--kkb-muted: color-mix(in srgb, currentColor 72%, transparent);
	--kkb-tint: rgba(0, 0, 0, 0.04);
	--kkb-tint: color-mix(in srgb, currentColor 7%, transparent);
	max-width: 56rem;
	margin: 0 auto;
	padding: var(--kkb-gap);
}

/**
 * Focus (spec §30).
 *
 * A fallback, not a preference: plenty of themes reset `outline` to none and
 * leave nothing behind, and then none of the controls below can be used by
 * anyone navigating with a keyboard. `currentColor` is the text colour, which
 * the theme already had to make readable against its background, so the ring
 * inherits that contrast (1.4.11). A theme that has its own indicator can put
 * it back with the same selector.
 */
.kkb :focus-visible,
.kkb-search :focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.kkb-hero {
	margin-bottom: calc(var(--kkb-gap) * 2);
}

.kkb-hero__title {
	margin: 0 0 var(--kkb-gap);
}

/* Search */

.kkb-search__label {
	display: block;
	margin-bottom: 0.5rem;
	font-weight: 600;
}

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

.kkb-search__input {
	flex: 1 1 18rem;
	padding: 0.7rem 0.9rem;
	border: var(--kkb-border);
	border-radius: var(--kkb-radius);
	font-size: 1rem;
}

.kkb-search__submit {
	padding: 0.7rem 1.2rem;
	border-radius: var(--kkb-radius);
	cursor: pointer;
}

/* Sections */

.kkb-section {
	margin-bottom: calc(var(--kkb-gap) * 2);
}

.kkb-section__title {
	margin: 0 0 var(--kkb-gap);
	font-size: 1.15rem;
}

/* Cards */

.kkb-cards {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
	gap: var(--kkb-gap);
}

.kkb-card {
	border: var(--kkb-border);
	border-radius: var(--kkb-radius);
}

.kkb-card__link {
	display: block;
	height: 100%;
	padding: 1rem;
	text-decoration: none;
	color: inherit;
}

.kkb-card__link:hover,
.kkb-card__link:focus-visible {
	background: var(--kkb-tint);
}

.kkb-card__type,
.kkb-card__count {
	display: block;
	font-size: 0.8rem;
	color: var(--kkb-muted);
}

.kkb-card__title {
	margin: 0.25rem 0 0.5rem;
	font-size: 1.05rem;
}

.kkb-card__excerpt {
	margin: 0 0 0.5rem;
	color: var(--kkb-muted);
	font-size: 0.92rem;
}

/* Lists */

.kkb-list,
.kkb-results {
	margin: 0;
	padding: 0;
	list-style: none;
}

.kkb-list__item,
.kkb-results__item {
	padding: 0.75rem 0;
	border-bottom: var(--kkb-border);
}

.kkb-list__link,
.kkb-results__link {
	font-weight: 600;
}

.kkb-list__meta {
	display: block;
	margin-top: 0.2rem;
	font-size: 0.85rem;
	color: var(--kkb-muted);
}

.kkb-list__meta > * + *::before {
	content: " · ";
}

.kkb-results__excerpt {
	margin: 0.3rem 0 0;
	color: var(--kkb-muted);
}

.kkb-results__back {
	margin-top: var(--kkb-gap);
}

/* Empty state */

.kkb-empty {
	padding: calc(var(--kkb-gap) * 1.5);
	border: 1px dashed var(--kkb-line);
	border-radius: var(--kkb-radius);
	text-align: center;
}

.kkb-empty__title {
	margin: 0 0 0.4rem;
	font-weight: 600;
}

.kkb-empty__message {
	margin: 0;
	color: var(--kkb-muted);
}

/* Archives */

.kkb-breadcrumbs {
	margin-bottom: var(--kkb-gap);
	font-size: 0.85rem;
	color: var(--kkb-muted);
}

.kkb-breadcrumbs__list {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.kkb-breadcrumbs__item + .kkb-breadcrumbs__item::before {
	content: "/";
	margin-right: 0.35rem;
	opacity: 0.6;
}

.kkb-archive__header {
	margin-bottom: calc(var(--kkb-gap) * 1.5);
}

.kkb-archive__title {
	margin: 0 0 0.5rem;
}

.kkb-archive__description {
	color: var(--kkb-muted);
}

.kkb-archive__toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--kkb-gap);
}

.kkb-sort {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	font-size: 0.9rem;
}

.kkb-sort__select,
.kkb-sort__submit {
	padding: 0.35rem 0.5rem;
	border: var(--kkb-border);
	border-radius: calc(var(--kkb-radius) / 2);
}

.kkb-sort__submit {
	cursor: pointer;
}

/* Article */

.kkb-article__header {
	margin-bottom: var(--kkb-gap);
}

.kkb-article__title {
	margin: 0 0 0.5rem;
}

.kkb-article__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	margin: 0;
	font-size: 0.85rem;
	color: var(--kkb-muted);
}

.kkb-article__content {
	margin-bottom: calc(var(--kkb-gap) * 2);
}

.kkb-feedback {
	margin-bottom: calc(var(--kkb-gap) * 2);
	padding: var(--kkb-gap);
	border: var(--kkb-border);
	border-radius: var(--kkb-radius);
}

.kkb-feedback__title {
	margin: 0 0 0.75rem;
	font-size: 1rem;
}

.kkb-article-nav {
	display: flex;
	flex-wrap: wrap;
	gap: var(--kkb-gap);
	justify-content: space-between;
	padding-top: var(--kkb-gap);
	border-top: var(--kkb-border);
}

.kkb-article-nav__link {
	display: block;
	max-width: 22rem;
	text-decoration: none;
}

.kkb-article-nav__link--next {
	margin-left: auto;
	text-align: right;
}

.kkb-article-nav__label {
	display: block;
	font-size: 0.8rem;
	color: var(--kkb-muted);
}

/* Live search suggestions */

.kkb-search--live {
	position: relative;
}

/**
 * The popup is the one place that cannot inherit its background: it floats
 * over whatever is underneath, so it has to be opaque. Foreground and
 * background are therefore declared together and never drift apart — a block
 * theme's own pair when it exposes one, otherwise a plain light surface.
 */
.kkb-suggest {
	position: absolute;
	z-index: 20;
	top: 100%;
	left: 0;
	right: 0;
	max-height: 22rem;
	margin: 0.25rem 0 0;
	overflow-y: auto;
	background: var(--wp--preset--color--base, #fff);
	color: var(--wp--preset--color--contrast, #111);
	border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
	border-radius: var(--kkb-radius);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.kkb-suggest[hidden] {
	display: none;
}

.kkb-suggest__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.kkb-suggest__item {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.75rem;
	padding: 0.6rem 0.9rem;
	cursor: pointer;
}

.kkb-suggest__item.is-active,
.kkb-suggest__item:hover {
	background: color-mix(in srgb, currentColor 9%, transparent);
}

.kkb-suggest__title {
	flex: 1 1 auto;
}

.kkb-suggest__type {
	flex: none;
	font-size: 0.75rem;
	opacity: 0.72;
}

.kkb-suggest__message {
	margin: 0;
	padding: 0.6rem 0.9rem;
	opacity: 0.72;
}

.kkb-suggest__message[hidden] {
	display: none;
}

.kkb-suggest__status {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* FAQ accordion */

.kkb-faq__item {
	border-bottom: var(--kkb-border);
}

.kkb-faq__question {
	margin: 0;
	font-size: 1rem;
}

.kkb-faq__toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	width: 100%;
	padding: 0.9rem 0;
	background: none;
	/* Taking the background away means taking the text colour with it. A
	   button does not inherit `color`; the browser gives it `buttontext`, and
	   a theme that styles buttons for its own filled background can leave that
	   white — white on the page's own background, which is nothing at all. */
	color: inherit;
	border: 0;
	font: inherit;
	text-align: left;
	cursor: pointer;
}

.kkb-faq__marker {
	flex: none;
	width: 0.6rem;
	height: 0.6rem;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg);
	transition: transform 0.15s ease;
}

.kkb-faq__toggle[aria-expanded="true"] .kkb-faq__marker {
	transform: rotate(-135deg);
}

@media (prefers-reduced-motion: reduce) {
	.kkb-faq__marker {
		transition: none;
	}
}

.kkb-faq__panel[hidden] {
	display: none;
}

.kkb-faq__answer {
	padding-bottom: 1rem;
}

.kkb-faq__more {
	margin-bottom: 0;
	font-size: 0.9rem;
}

/* "Was this helpful?" */

.kkb-feedback__buttons {
	display: flex;
	gap: 0.5rem;
}

.kkb-feedback__button {
	padding: 0.45rem 1.4rem;
	border: var(--kkb-border);
	border-radius: var(--kkb-radius);
	background: none;
	/* See .kkb-faq__toggle: no background means no inherited text colour
	   either, and "Tak"/"Nie" went white on white on a theme that styles its
	   buttons filled. Reported from a live site, reproduced with one line. */
	color: inherit;
	font: inherit;
	cursor: pointer;
}

.kkb-feedback__button[aria-disabled="true"] {
	cursor: default;
	opacity: 0.6;
}

.kkb-feedback__button.is-chosen {
	border-color: currentColor;
	font-weight: 600;
	opacity: 1;
}

.kkb-feedback__stats,
.kkb-feedback__message {
	margin: 0.6rem 0 0;
	font-size: 0.85rem;
	color: var(--kkb-muted);
}

.kkb-feedback__message:empty {
	margin: 0;
}
