/**
 * Course Search Block — frontend styles.
 *
 * Loaded by both the card block and the standalone bar block.
 */

/* ---------- Wrapper ---------- */

.csb-wrapper {
	display: block;
	box-sizing: border-box;
	font-family: "Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

/* ---------- Card (full block) ---------- */

.csb-card-wrapper {
	width: 100%;
	max-width: 650px;
	margin-left: auto;
	margin-right: auto;
}

.csb-card {
	width: 100%;
	padding: 28px 50px;
	border-radius: 24px;
	border: 1px solid var(--csb-card-border, #4383DA);
	background: var(--csb-card-bg, #2F5FA1);
	box-shadow: 0 4px 60px 0 rgba(0, 0, 0, 0.25);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
}

/* ---------- Title ---------- */

.csb-title {
	color: var(--csb-title-color, #ECF1FC);
	font-family: "Nunito Sans", sans-serif;
	font-size: var(--csb-title-size, 24px);
	font-weight: 700;
	line-height: 130%;
	text-align: center;
	margin: 0 0 20px;
}

/* ---------- Search row (shared) ---------- */

.csb-form {
	margin: 0;
}

.csb-wrapper .csb-input-row {
	display: flex;
	align-items: stretch;
	background: transparent;
	border: 0;
	box-shadow: none;
	border-radius: 40px;
	overflow: hidden;
}

.csb-input {
	flex: 1 1 auto;
	min-width: 0;
	border: var(--csb-input-border, 1px solid #D9DDE3);
	border-right: 0;
	box-shadow: none;
	border-radius: 40px 0 0 40px;
	background: var(--csb-input-bg, #FFFFFF);
	padding: 16px 24px;
	color: var(--csb-input-text, #989FAD);
	font-family: "Nunito Sans", sans-serif;
	font-size: var(--csb-ph-size, 16px);
	font-style: normal;
	font-weight: 500;
	line-height: 150%;
	outline: none;
	-webkit-appearance: none;
	appearance: none;
}
/* Keep our border on focus; kill theme/modal focus rings. */
.csb-input:focus,
.csb-input:focus-visible {
	box-shadow: none;
	outline: none;
}

.csb-input::placeholder {
	color: var(--csb-input-text, #989FAD);
	opacity: 1;
}

.csb-input::-webkit-search-decoration,
.csb-input::-webkit-search-cancel-button {
	-webkit-appearance: none;
}

.csb-button {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 14px 24px 13px 24px;
	border-radius: 0 40px 40px 0;
	background: var(--csb-btn, #4383DA);
	color: var(--csb-btn-text, #ECF1FC);
	border: 0;
	cursor: pointer;
	font-family: "Nunito Sans", sans-serif;
	font-size: var(--csb-btn-size, 18px);
	font-style: normal;
	font-weight: 600;
	line-height: 130%;
	transition: filter .15s ease;
	white-space: nowrap;
}

.csb-button:hover { background: var(--csb-btn-hover, #2F6FC9); }
.csb-button:active { filter: brightness(0.95); }

/*
 * Theme search modals / popups often style button + input elements with
 * high-specificity selectors that strip our pill. Re-assert the essentials,
 * scoped to the block wrapper, so the search bar looks right anywhere.
 */
.csb-wrapper .csb-form .csb-button,
.csb-wrapper .csb-form .csb-button:focus,
.csb-wrapper .csb-form .csb-button:active {
	background: var(--csb-btn, #4383DA) !important;
	color: var(--csb-btn-text, #ECF1FC) !important;
	border: 0 !important;
	box-shadow: none !important;
	border-radius: 0 40px 40px 0 !important;
	text-decoration: none !important;
}
.csb-wrapper .csb-form .csb-button:hover {
	background: var(--csb-btn-hover, #2F6FC9) !important;
}
.csb-wrapper .csb-form .csb-button:active { filter: brightness(0.95); }

.csb-wrapper .csb-form .csb-button .csb-icon { color: var(--csb-btn-text, #ECF1FC) !important; }

.csb-wrapper .csb-form .csb-input,
.csb-wrapper .csb-form .csb-input:focus {
	background: var(--csb-input-bg, #FFFFFF) !important;
	border: var(--csb-input-border, 1px solid #D9DDE3) !important;
	border-right: 0 !important;
	box-shadow: none !important;
	border-radius: 40px 0 0 40px !important;
	outline: none !important;
}

.csb-icon {
	display: block;
	flex-shrink: 0;
}

/* ---------- Categories ---------- */

.csb-categories {
	margin-top: 18px;
	text-align: center;
	position: relative;
}

.csb-cat-toggle {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	background: transparent;
	color: var(--csb-title-color, #ECF1FC);
	border: 0;
	cursor: pointer;
	font-family: "Nunito Sans", sans-serif;
	font-size: var(--csb-browse-size, 16px);
	font-weight: 600;
	line-height: 130%;
	padding: 4px 8px;
}

.csb-cat-toggle .csb-caret {
	transition: transform .2s ease;
}

.csb-cat-toggle[aria-expanded="true"] .csb-caret {
	transform: rotate(180deg);
}

.csb-cat-empty {
	color: var(--csb-title-color, #ECF1FC);
	font-family: "Nunito Sans", sans-serif;
	font-size: var(--csb-browse-size, 16px);
	font-weight: 600;
	opacity: .85;
}

.csb-cat-list {
	list-style: none;
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	z-index: 30;
	margin: 10px 0 0;
	padding: 8px;
	background: #fff;
	color: #222;
	border-radius: 12px;
	box-shadow: 0 8px 24px rgba(0,0,0,0.18);
	width: min(320px, calc(100vw - 32px));
	max-height: 260px;
	overflow-y: auto;
	text-align: left;
	font-family: "Nunito Sans", sans-serif;
}

/*
 * Popover mode (set by view.js when the Popover API is supported).
 * The list renders in the browser top layer — above every theme stacking
 * context — and view.js positions it under the toggle with fixed coords.
 * Override the UA popover defaults (inset: 0, auto margins, border).
 */
.csb-cat-list[popover] {
	position: fixed;
	inset: auto;
	transform: none;
	margin: 0;
	border: 0;
}

.csb-cat-list li { margin: 0; }

.csb-cat-list a {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	padding: 8px 12px;
	color: inherit;
	text-decoration: none;
	border-radius: 8px;
	font-weight: 600;
}

.csb-cat-list a:hover,
.csb-cat-list a:focus {
	background: #f3f5f9;
}

.csb-cat-count {
	color: #888;
	font-size: 0.85em;
	font-weight: 500;
}

/* ---------- Mobile ---------- */

@media (max-width: 768px) {

	.csb-card-wrapper {
		max-width: 100%;
	}

	.csb-card {
		padding: 12px;
		border-radius: 12px;
	}

	.csb-title {
		font-size: var(--csb-title-size-m, 18px);
		margin-bottom: 10px;
	}

	.csb-input {
		padding: 10px 20px;
		font-size: var(--csb-ph-size-m, 10px);
	}

	.csb-button {
		padding: 10px 8px;
		font-size: var(--csb-btn-size-m, 14px);
		gap: 6px;
	}

	.csb-icon {
		width: 16px;
		height: 16px;
	}

	.csb-categories {
		margin-top: 10px;
	}

	.csb-cat-toggle,
	.csb-cat-empty {
		font-size: var(--csb-browse-size-m, 13px);
	}
}

/* Editor-only hint container — never shown on frontend */
.csb-editor-hint { display: none; }

/* ---------------------------------------------------------------- *
 * AJAX autocomplete suggestions
 * ---------------------------------------------------------------- */
.csb-input-row { position: relative; }

.csb-suggest-list {
	list-style: none;
	margin: 0;
	padding: 6px;
	background: #fff;
	color: #222;
	border-radius: 12px;
	box-shadow: 0 8px 24px rgba(0,0,0,0.18);
	max-height: 320px;
	overflow-y: auto;
	text-align: left;
	font-family: "Nunito Sans", sans-serif;
}

/* When not promoted to a popover (older browsers), fall back to an absolute
 * dropdown. The parent row clips it, so also lift the row's overflow then. */
.csb-suggest-list:not([popover]) {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	right: 0;
	z-index: 40;
}

/* Top-layer popover: fixed coords are set by view.js. */
.csb-suggest-list[popover] {
	position: fixed;
	inset: auto;
	border: 0;
}

.csb-suggest-list li { margin: 0; }

.csb-suggest-list a {
	display: block;
	padding: 9px 12px;
	border-radius: 8px;
	color: #222;
	text-decoration: none;
	font-size: 15px;
	line-height: 1.3;
}

.csb-suggest-list a:hover,
.csb-suggest-list a:focus {
	background: #eef3fb;
}

.csb-filter-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-top: 8px;
	padding: 4px 6px 4px 12px;
	background: rgba(255,255,255,0.92);
	color: #222;
	border-radius: 999px;
	font-size: 13px;
	font-family: "Nunito Sans", sans-serif;
}

.csb-filter-chip strong { font-weight: 700; }

.csb-filter-chip button {
	border: 0;
	background: #d9e3f5;
	color: #2F5FA1;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	cursor: pointer;
	line-height: 1;
	font-size: 12px;
}
