/*
 * База знань (/knowledge-base/) — стилі поверх koala.css.
 * Нічого зі старого Echo KB (.epkb-*) не використовується: усе побудовано на змінних теми
 * (--caccent/--cbold/--clight/--cbackground/--radius), шрифті Inter і тих самих скругленнях,
 * що й картки категорій та блогу на головній. Усі селектори мають префікс .kb-, тож стилі
 * не можуть зачепити жодну іншу сторінку.
 */

.kb-page {
	padding-bottom: 96px;
}

/* --------------------------------- хлібні крихти ------------------------- */

.kb-crumbs {
	font-size: 1rem;
	letter-spacing: -0.02rem;
	color: var(--clight);
	margin-top: 24px;
	margin-bottom: 29px;
}

.kb-crumbs a {
	color: var(--clight);
	text-decoration: none;
	margin: 0 12px;
}

.kb-crumbs a:first-child {
	margin-left: 0;
}

.kb-crumbs a:hover {
	text-decoration: underline;
}

.kb-crumbs span {
	margin-left: 12px;
	color: var(--cbold);
}

/* ------------------------------------ хіро ------------------------------- */

.kb-hero {
	margin-bottom: 40px;
}

.kb-hero .h2 {
	margin-bottom: 19px;
}

/* ------------------------------------ пошук ------------------------------ */

.kb-search {
	position: relative;
	max-width: 620px;
	margin: 0 auto 56px;
}

.kb-search input {
	width: 100%;
	box-sizing: border-box;
	height: 60px;
	padding: 0 52px 0 52px;
	border: 1px solid var(--cdarkgrey);
	border-radius: 999px;
	background: var(--cwhite);
	font-family: "Inter", sans-serif;
	font-size: 1rem;
	letter-spacing: -0.02rem;
	color: var(--cbold);
	outline: none;
	transition: 0.2s;
}

/* нативний хрестик type=search — свій кнопкою .kb-search-clear */
.kb-search input::-webkit-search-cancel-button,
.kb-search input::-webkit-search-decoration {
	-webkit-appearance: none;
	appearance: none;
	display: none;
}

.kb-search input::placeholder {
	color: var(--culight);
}

.kb-search input:focus {
	border-color: var(--caccent);
	box-shadow: 0 0 0 4px rgba(59, 113, 254, 0.1);
}

.kb-search-icon {
	position: absolute;
	left: 20px;
	top: 50%;
	transform: translateY(-50%);
	pointer-events: none;
	display: flex;
}

.kb-search-clear {
	position: absolute;
	right: 12px;
	top: 50%;
	transform: translateY(-50%);
	width: 32px;
	height: 32px;
	border: 0;
	border-radius: 50%;
	background: var(--cbackground);
	color: var(--clight);
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	transition: 0.2s;
}

.kb-search-clear:hover {
	background: var(--cdarkgrey);
	color: var(--cbold);
}

/* ------------------------------- секції та заголовки --------------------- */

.kb-section {
	margin-bottom: 64px;
}

.kb-section-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 24px;
}

.kb-section-head h2,
.kb-section-head h3 {
	font-size: 1.5rem;
	line-height: 1.4;
	font-weight: 600;
	letter-spacing: -0.031rem;
	color: var(--cheader);
	margin: 0;
}

.kb-section-count {
	font-size: 0.875rem;
	color: var(--clight);
	white-space: nowrap;
}

/* ------------------------------- плитки категорій ------------------------ */

.kb-cats {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 20px;
}

.kb-cat {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
	box-sizing: border-box;
	width: 100%;
	min-height: 100%;
	padding: 24px;
	border: 1px solid var(--cdarkgrey);
	border-radius: 20px;
	background: var(--cwhite);
	text-align: left;
	text-decoration: none;
	font-family: "Inter", sans-serif;
	cursor: pointer;
	transition: 0.2s;
}

.kb-cat:hover {
	border-color: var(--culight);
	box-shadow: 0 12px 24px -12px rgba(35, 38, 47, 0.16);
	transform: translateY(-2px);
}

.kb-cat.is-active {
	border-color: var(--caccent);
	box-shadow: 0 0 0 1px var(--caccent) inset;
}

.kb-cat-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	margin-bottom: 8px;
	border-radius: 14px;
	background: var(--cbackground);
	font-size: 22px;
	line-height: 1;
	overflow: hidden;
}

.kb-cat.is-active .kb-cat-icon {
	background: rgba(59, 113, 254, 0.1);
}

.kb-cat-icon img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.kb-cat-name {
	font-size: 1.125rem;
	line-height: 1.35;
	font-weight: 600;
	letter-spacing: -0.02rem;
	color: var(--cheader);
}

.kb-cat-desc {
	font-size: 0.9375rem;
	line-height: 1.55;
	letter-spacing: -0.02rem;
	color: var(--clight);
	margin: 0;
}

.kb-cat-count {
	margin-top: auto;
	padding-top: 12px;
	font-size: 0.8125rem;
	color: var(--culight);
}

.kb-cat.is-active .kb-cat-count {
	color: var(--caccent);
}

/* --------------------------------- картки статей ------------------------- */

.kb-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	gap: 24px;
	list-style: none;
	margin: 0;
	padding: 0;
}

.kb-card {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--cdarkgrey);
	border-radius: 20px;
	background: var(--cwhite);
	text-decoration: none;
	transition: 0.2s;
}

.kb-card:hover {
	border-color: var(--culight);
	box-shadow: 0 16px 32px -16px rgba(35, 38, 47, 0.2);
	transform: translateY(-2px);
}

.kb-card-image {
	position: relative;
	aspect-ratio: 16 / 10;
	background: var(--cbackground);
	overflow: hidden;
}

/* Статті без обкладинки (в імпорті з WP лишився woocommerce-placeholder) — нейтральна плитка */
.kb-card-image--empty {
	display: flex;
	align-items: center;
	justify-content: center;
	aspect-ratio: 16 / 6;
	background: linear-gradient(180deg, var(--cbackground) 0%, var(--cdarkgrey) 100%);
}

.kb-card-image--empty svg {
	width: 32px;
	height: 32px;
	opacity: 0.35;
}

.kb-card-image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: 0.4s;
}

.kb-card:hover .kb-card-image img {
	transform: scale(1.04);
}

.kb-card-body {
	display: flex;
	flex-direction: column;
	gap: 10px;
	flex-grow: 1;
	padding: 20px 24px 24px;
}

.kb-card-title {
	font-size: 1.0625rem;
	line-height: 1.4;
	font-weight: 600;
	letter-spacing: -0.02rem;
	color: var(--cheader);
	margin: 0;
}

.kb-card:hover .kb-card-title {
	color: var(--caccent);
}

.kb-card-excerpt {
	font-size: 0.9375rem;
	line-height: 1.6;
	letter-spacing: -0.02rem;
	color: var(--clight);
	margin: 0;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.kb-card-meta {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: auto;
	padding-top: 12px;
	font-size: 0.8125rem;
	color: var(--culight);
}

.kb-badge {
	display: inline-block;
	padding: 4px 12px;
	border-radius: 999px;
	background: var(--cbackground);
	font-size: 0.75rem;
	line-height: 1.5;
	font-weight: 500;
	letter-spacing: -0.01rem;
	color: var(--cbold);
	text-decoration: none;
}

a.kb-badge:hover {
	background: var(--cdarkgrey);
}

.kb-empty {
	padding: 40px 24px;
	border: 1px dashed var(--cdarkgrey);
	border-radius: 20px;
	text-align: center;
	color: var(--clight);
	font-size: 1rem;
}

/* --------------------------------- сторінка статті ----------------------- */

.kb-article-head {
	max-width: 820px;
	margin-bottom: 32px;
}

.kb-article-head h1 {
	font-size: 2.5rem;
	line-height: 1.2;
	font-weight: 700;
	letter-spacing: -0.08rem;
	color: var(--cheader);
	margin: 16px 0 0;
}

.kb-article-meta {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 12px;
	font-size: 0.875rem;
	color: var(--culight);
}

.kb-cover {
	margin-bottom: 40px;
	border-radius: var(--radius);
	overflow: hidden;
	background: var(--cbackground);
}

.kb-cover img {
	width: 100%;
	max-height: 460px;
	object-fit: cover;
	display: block;
}

.kb-layout {
	display: grid;
	grid-template-columns: 280px minmax(0, 1fr);
	gap: 48px;
	align-items: start;
}

/* ------------------------------------- зміст ----------------------------- */

.kb-toc {
	position: sticky;
	top: 108px;
	box-sizing: border-box;
	padding: 20px;
	border: 1px solid var(--cdarkgrey);
	border-radius: 20px;
	background: var(--cwhite);
}

.kb-toc-toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 0;
	border: 0;
	background: none;
	font-family: "Inter", sans-serif;
	font-size: 0.9375rem;
	font-weight: 600;
	letter-spacing: -0.02rem;
	color: var(--cheader);
	text-align: left;
	cursor: default;
}

.kb-toc-toggle svg {
	display: none;
	transition: 0.2s;
	flex-shrink: 0;
}

.kb-toc-list {
	list-style: none;
	margin: 16px 0 0;
	padding: 0;
	max-height: calc(100vh - 220px);
	overflow-y: auto;
}

.kb-toc-list li + li {
	margin-top: 2px;
}

.kb-toc-list a {
	display: block;
	padding: 6px 10px;
	border-left: 2px solid var(--cdarkgrey);
	font-size: 0.875rem;
	line-height: 1.45;
	letter-spacing: -0.02rem;
	color: var(--clight);
	text-decoration: none;
	transition: 0.15s;
}

.kb-toc-list a:hover {
	color: var(--cbold);
	border-left-color: var(--culight);
}

.kb-toc-list .kb-toc-l3 a {
	padding-left: 22px;
	font-size: 0.8125rem;
}

.kb-toc-list a.is-active {
	color: var(--caccent);
	border-left-color: var(--caccent);
	font-weight: 500;
}

/* ------------------------------------- тіло ------------------------------ */

.kb-body {
	max-width: 780px;
	font-size: 1.0625rem;
	line-height: 1.7;
	letter-spacing: -0.02rem;
	color: var(--ctext);
}

.kb-body > *:first-child {
	margin-top: 0;
}

.kb-body h2 {
	font-size: 1.75rem;
	line-height: 1.3;
	font-weight: 700;
	letter-spacing: -0.045rem;
	color: var(--cheader);
	margin: 48px 0 16px;
	scroll-margin-top: 108px;
}

.kb-body h3 {
	font-size: 1.3125rem;
	line-height: 1.4;
	font-weight: 600;
	letter-spacing: -0.03rem;
	color: var(--cheader);
	margin: 36px 0 12px;
	scroll-margin-top: 108px;
}

.kb-body h2 strong,
.kb-body h3 strong {
	font-weight: inherit;
}

.kb-body p {
	font-size: inherit;
	line-height: inherit;
	margin: 0 0 18px;
}

.kb-body strong {
	color: var(--cbold);
	font-weight: 600;
}

.kb-body a {
	color: var(--caccent);
	text-decoration: underline;
	text-underline-offset: 3px;
}

.kb-body ul,
.kb-body ol {
	margin: 0 0 20px;
	padding-left: 22px;
}

.kb-body li {
	margin-bottom: 10px;
}

.kb-body li > p {
	margin-bottom: 0;
}

.kb-body li::marker {
	color: var(--culight);
}

.kb-body figure {
	margin: 28px 0;
}

.kb-body img {
	max-width: 100%;
	height: auto;
	border-radius: 20px;
	display: block;
}

.kb-body figcaption {
	margin-top: 10px;
	font-size: 0.875rem;
	color: var(--culight);
	text-align: center;
}

.kb-body video {
	max-width: 100%;
	height: auto;
	border-radius: 20px;
}

.kb-body hr {
	height: 1px;
	border: 0;
	background: var(--cdarkgrey);
	margin: 32px 0;
}

.kb-body blockquote {
	margin: 28px 0;
	padding: 16px 24px;
	border-left: 3px solid var(--caccent);
	background: var(--cbackground);
	border-radius: 0 16px 16px 0;
	color: var(--cbold);
}

.kb-body blockquote p:last-child {
	margin-bottom: 0;
}

.kb-embed {
	position: relative;
	aspect-ratio: 16 / 9;
	margin: 28px 0;
	border-radius: 20px;
	overflow: hidden;
	background: var(--cubold);
}

.kb-embed iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

.kb-table {
	margin: 28px 0;
	overflow-x: auto;
	border: 1px solid var(--cdarkgrey);
	border-radius: 16px;
}

.kb-table table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.9375rem;
}

.kb-table th,
.kb-table td {
	padding: 12px 16px;
	text-align: left;
	border-bottom: 1px solid var(--cdarkgrey);
}

.kb-table th {
	background: var(--cbackground);
	font-weight: 600;
	color: var(--cbold);
	white-space: nowrap;
}

.kb-table tr:last-child td {
	border-bottom: 0;
}

/* ------------------------- пов'язані товари / схожі статті --------------- */

.kb-related {
	margin-top: 64px;
}

.kb-related .woocommerce ul.products {
	margin-bottom: 0;
}

.kb-help {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 24px;
	margin-top: 64px;
	padding: 40px;
	border-radius: var(--radius);
	background: var(--cbackground);
}

.kb-help h2 {
	font-size: 1.5rem;
	line-height: 1.35;
	font-weight: 600;
	letter-spacing: -0.031rem;
	color: var(--cheader);
	margin: 0 0 8px;
}

.kb-help p {
	max-width: 560px;
	margin: 0;
	font-size: 1rem;
	line-height: 1.6;
	color: var(--clight);
}

.kb-help-btn {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 14px 28px;
	border-radius: 999px;
	background: var(--caccent);
	color: var(--cwhite);
	font-size: 0.9375rem;
	font-weight: 500;
	letter-spacing: -0.02rem;
	text-decoration: none;
	white-space: nowrap;
	transition: 0.2s;
}

.kb-help-btn:hover {
	opacity: 0.88;
	color: var(--cwhite);
}

/* --------------------------------- адаптив ------------------------------- */

@media (max-width: 1023px) {
	.kb-layout {
		grid-template-columns: minmax(0, 1fr);
		gap: 24px;
	}

	.kb-toc {
		position: static;
		padding: 16px 20px;
	}

	.kb-toc-toggle {
		cursor: pointer;
	}

	.kb-toc-toggle svg {
		display: block;
	}

	.kb-toc[data-open="false"] .kb-toc-list {
		display: none;
	}

	.kb-toc[data-open="true"] .kb-toc-toggle svg {
		transform: rotate(180deg);
	}

	.kb-toc-list {
		max-height: none;
	}
}

@media (max-width: 819px) {
	.kb-page {
		padding-bottom: 64px;
	}

	.kb-crumbs {
		margin-top: 16px;
		margin-bottom: 20px;
		font-size: 0.875rem;
	}

	.kb-crumbs a,
	.kb-crumbs span {
		margin: 0 6px;
	}

	.kb-crumbs a:first-child {
		margin-left: 0;
	}

	.kb-search {
		margin-bottom: 40px;
	}

	.kb-search input {
		height: 54px;
	}

	.kb-section {
		margin-bottom: 48px;
	}

	.kb-cats {
		grid-template-columns: minmax(0, 1fr);
		gap: 12px;
	}

	.kb-cat {
		flex-direction: row;
		align-items: center;
		flex-wrap: wrap;
		padding: 16px;
		gap: 4px 14px;
	}

	.kb-cat-icon {
		width: 40px;
		height: 40px;
		margin-bottom: 0;
		font-size: 18px;
	}

	.kb-cat-name {
		flex: 1;
		font-size: 1rem;
	}

	.kb-cat-desc {
		flex-basis: 100%;
	}

	.kb-cat-count {
		margin-top: 0;
		padding-top: 0;
	}

	.kb-list {
		grid-template-columns: minmax(0, 1fr);
		gap: 16px;
	}

	.kb-card-body {
		padding: 16px 18px 20px;
	}

	.kb-article-head h1 {
		font-size: 1.625rem;
		letter-spacing: -0.03rem;
	}

	.kb-cover {
		margin-bottom: 28px;
		border-radius: 20px;
	}

	.kb-cover img {
		max-height: 260px;
	}

	.kb-body {
		font-size: 1rem;
	}

	.kb-body h2 {
		font-size: 1.375rem;
		margin: 32px 0 12px;
	}

	.kb-body h3 {
		font-size: 1.125rem;
		margin: 26px 0 10px;
	}

	.kb-body img,
	.kb-embed,
	.kb-body video {
		border-radius: 14px;
	}

	.kb-help {
		margin-top: 48px;
		padding: 24px;
		border-radius: 20px;
	}

	.kb-help-btn {
		width: 100%;
		justify-content: center;
	}
}
