/*
 * [kd_archive_search] — live article search for archive pages.
 * Sits on top of kdtc-shared.css but, like the FAQ and About blocks, it is
 * a flat strip above an article grid rather than a boxed calculator card,
 * so the base .kdtc-calc chrome (border, shadow, max-width, overflow) is
 * switched off here. It deliberately has no dark-mode flip: the site
 * itself is light, and a dark-ink-on-light-page mismatch is worse than no
 * dark mode.
 */

.kdtc-calc.kdtc-archive-search {
	max-width: 100%;
	width: 100%;
	margin: 0 0 1.75em;
	padding: 0;
	border: none;
	box-shadow: none;
	background: transparent;
	overflow: visible;
}

/* Hides the normal article grid and pagination while a search is active.
 * !important because Elementor sets display on its widgets directly. */
.kdtc-as-hidden {
	display: none !important;
}

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

/* ---------- search form ---------- */

.kdtc-as__form {
	display: flex;
	gap: 0.6em;
	align-items: stretch;
	margin: 0;
}

.kdtc-as__input {
	flex: 1 1 auto;
	min-width: 0;
	width: 100%;
	font: inherit;
	font-size: 1em;
	border: 1px solid var(--kdtc-border);
	border-radius: var(--kdtc-radius-sm);
	background-color: #fff;
	color: var(--kdtc-ink);
	background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%235b6472'%3e%3cpath fill-rule='evenodd' d='M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.45 4.39l3.08 3.08a.75.75 0 11-1.06 1.06l-3.08-3.08A7 7 0 012 9z' clip-rule='evenodd'/%3e%3c/svg%3e");
	background-repeat: no-repeat;
	background-position: left 0.85em center;
	background-size: 1.1em;
	/* Same fix the FAQ search needed: the theme's field styles collapse
	 * the left padding that keeps text clear of the magnifier icon. */
	padding: 0.8em 1em 0.8em 2.7em !important;
	margin: 0;
	height: auto;
	box-shadow: none;
}

.kdtc-as__input:focus {
	outline: none;
	border-color: var(--kdtc-accent);
	box-shadow: 0 0 0 3px var(--kdtc-accent-soft);
}

.kdtc-as__input::placeholder {
	color: var(--kdtc-muted);
	opacity: 1;
}

.kdtc-as__input::-webkit-search-cancel-button {
	cursor: pointer;
}

/*
 * Buttons: Hello Elementor's reset paints every plain <button> pink
 * (#cc3366) with white text on hover and focus. Every state is pinned
 * here so the accent blue holds, same lesson as kd-faq.css.
 */
.kdtc-as__submit,
.kdtc-as__more {
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	border: 1px solid var(--kdtc-accent);
	border-radius: var(--kdtc-radius-sm);
	background-color: var(--kdtc-accent);
	color: #fff;
	padding: 0.7em 1.3em;
	line-height: 1.2;
	text-transform: none;
	letter-spacing: normal;
}

.kdtc-as__submit:hover,
.kdtc-as__submit:focus,
.kdtc-as__submit:active,
.kdtc-as__more:hover,
.kdtc-as__more:focus,
.kdtc-as__more:active {
	background-color: var(--kdtc-accent-dark);
	border-color: var(--kdtc-accent-dark);
	color: #fff;
}

.kdtc-as__submit:focus-visible,
.kdtc-as__more:focus-visible {
	outline: 3px solid var(--kdtc-accent-soft);
	outline-offset: 2px;
}

/* With JavaScript running, results appear as you type, so the Search
 * button is tucked away visually. It stays in the page for screen reader
 * and keyboard users. */
.kdtc-as--js .kdtc-as__submit {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ---------- status line ---------- */

.kdtc-as__status {
	margin: 0.7em 0 0;
	min-height: 1.4em;
	font-size: 0.92em;
	color: var(--kdtc-muted);
}

.kdtc-archive-search.is-loading .kdtc-as__status {
	opacity: 0.7;
}

/* ---------- results ---------- */

.kdtc-as__results {
	list-style: none;
	margin: 0.9em 0 0;
	padding: 0;
	display: grid;
	gap: 0.8em;
}

.kdtc-as__results[hidden],
.kdtc-as__more[hidden] {
	display: none;
}

.kdtc-as__item {
	margin: 0;
	padding: 0;
	list-style: none;
}

.kdtc-calc .kdtc-as__link {
	display: flex;
	gap: 1em;
	align-items: flex-start;
	padding: 0.9em;
	background: #fff;
	border: 1px solid var(--kdtc-border);
	border-radius: var(--kdtc-radius);
	text-decoration: none;
	color: var(--kdtc-ink);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.kdtc-calc .kdtc-as__link:hover,
.kdtc-calc .kdtc-as__link:focus-visible {
	border-color: var(--kdtc-accent);
	box-shadow: 0 0 0 3px var(--kdtc-accent-soft);
	text-decoration: none;
	color: var(--kdtc-ink);
}

.kdtc-as__thumb {
	flex: 0 0 auto;
	width: 96px;
	height: 96px;
	object-fit: cover;
	border-radius: var(--kdtc-radius-sm);
	background: var(--kdtc-panel-bg);
	margin: 0;
}

.kdtc-as__body {
	display: flex;
	flex-direction: column;
	gap: 0.25em;
	min-width: 0;
}

/* Spans, not headings, on purpose. The site has a sitewide heading
 * color rule with !important that would override anything set here. */
.kdtc-calc .kdtc-as__title {
	font-size: 1.1em;
	font-weight: 700;
	line-height: 1.3;
	color: var(--kdtc-accent-dark);
}

.kdtc-calc .kdtc-as__link:hover .kdtc-as__title {
	text-decoration: underline;
}

.kdtc-as__meta {
	font-size: 0.82em;
	color: var(--kdtc-muted);
}

.kdtc-as__excerpt {
	font-size: 0.93em;
	line-height: 1.5;
	color: var(--kdtc-ink);
}

.kdtc-archive-search mark {
	background: #fff1b8;
	color: inherit;
	padding: 0 0.1em;
	border-radius: 2px;
}

.kdtc-as__more {
	display: block;
	margin: 1.1em auto 0;
}

@media (max-width: 520px) {
	.kdtc-as__thumb {
		width: 72px;
		height: 72px;
	}
	.kdtc-calc .kdtc-as__link {
		gap: 0.75em;
		padding: 0.75em;
	}
	/* Without JS the Search button wraps under the box on narrow screens. */
	.kdtc-archive-search:not(.kdtc-as--js) .kdtc-as__form {
		flex-wrap: wrap;
	}
}

/* ---------- posts versus pages ---------- */

/* Articles get a blue left edge and a blue "Article" tag. Pages get a
 * warm amber edge, a soft tinted background and an amber "Page" tag, so
 * the two read as different kinds of result at a glance. */
.kdtc-calc .kdtc-as__item--post .kdtc-as__link {
	border-left: 4px solid var(--kdtc-accent);
}

.kdtc-calc .kdtc-as__item--page .kdtc-as__link {
	border-left: 4px solid #c9811a;
	background: #fffaf0;
}

.kdtc-calc .kdtc-as__item--page .kdtc-as__link:hover,
.kdtc-calc .kdtc-as__item--page .kdtc-as__link:focus-visible {
	border-color: #c9811a;
	box-shadow: 0 0 0 3px #fbe9c8;
}

.kdtc-calc .kdtc-as__item--page .kdtc-as__title {
	color: #8a5200;
}

.kdtc-as__badge {
	align-self: flex-start;
	font-size: 0.68em;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	line-height: 1;
	padding: 0.35em 0.7em;
	border-radius: 999px;
}

.kdtc-as__badge--post {
	background: var(--kdtc-accent-soft);
	color: var(--kdtc-accent-dark);
}

.kdtc-as__badge--page {
	background: #fbe9c8;
	color: #8a5200;
}
