/* Header forum live search — Discourse-style multi-section suggest */

.search-header.forum-search {
	position: relative;
	width: 100%;
}

@media (min-width: 768px) {
	.breadcrumbs-panel .breadcrumbs-search-col {
		flex: 0 0 auto;
		width: 16rem;
	}

	.breadcrumbs-panel .breadcrumbs-search-col > div:last-child,
	.breadcrumbs-panel .breadcrumbs-search-col .forum-search:not(.is-sheet-open),
	.breadcrumbs-panel .breadcrumbs-search-col .forum-search:not(.is-sheet-open) .forum-search__form,
	.breadcrumbs-panel .breadcrumbs-search-col .forum-search:not(.is-sheet-open) .forum-search__field,
	.breadcrumbs-panel .breadcrumbs-search-col .forum-search:not(.is-sheet-open) .forum-search__input {
		width: 100%;
		max-width: none;
	}
}

.search-header.forum-search .forum-search__form {
	display: flex;
	align-items: center;
	position: relative;
	width: 100%;
}

.search-header.forum-search .forum-search__field {
	position: relative;
	display: flex;
	align-items: center;
	width: 100%;
	min-width: 0;
}

.search-header.forum-search .forum-search__prefix {
	position: absolute;
	z-index: 1;
	left: 0.65rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
	color: rgba(var(--color-secondary), 1);
	opacity: 0.7;
}

[dir="rtl"] .search-header.forum-search .forum-search__prefix {
	left: auto;
	right: 0.65rem;
}

.search-header.forum-search .forum-search__input {
	width: 100%;
	padding-left: 2.35rem !important;
	padding-right: 2.6rem !important;
}

[dir="rtl"] .search-header.forum-search .forum-search__input {
	padding-left: 2.6rem !important;
	padding-right: 2.35rem !important;
}

.search-header.forum-search .forum-search__filter {
	position: absolute;
	z-index: 1;
	right: 0.25rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	line-height: 0;
	padding: 0.5rem;
	border-radius: 9999px;
	color: rgba(var(--color-secondary), 1);
	text-decoration: none;
}

[dir="rtl"] .search-header.forum-search .forum-search__filter {
	right: auto;
	left: 0.25rem;
}

.search-header.forum-search .forum-search__filter:hover,
.search-header.forum-search .forum-search__filter:focus-visible {
	color: rgba(var(--color-text), 1);
	background: rgba(var(--color-primary), 0.08);
}

:is(.dark .search-header.forum-search .forum-search__filter:hover),
:is(.dark .search-header.forum-search .forum-search__filter:focus-visible) {
	color: rgba(var(--color-text-dark), 1);
	background: rgba(var(--color-primary-dark), 0.1);
}

.forum-search__suggest {
	position: absolute;
	z-index: 60;
	left: 0;
	right: 0;
	top: calc(100% + 0.4rem);
	border: 1px solid #e5e7eb;
	border-radius: 0.85rem;
	background: #fff;
	box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
	overflow: hidden;
}

:is(.dark .forum-search__suggest) {
	border-color: rgb(51 65 85 / 0.65);
	background: #0f172a;
	box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
}

.forum-search__panel {
	max-height: min(70vh, 28rem);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.forum-search__section-title {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	padding: 0.65rem 0.85rem 0.3rem;
	font-size: 0.7rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: rgba(var(--color-secondary), 1);
	opacity: 0.9;
}

.forum-search__section-action {
	border: 0;
	background: transparent;
	color: rgba(var(--color-primary), 1);
	font-size: 0.7rem;
	font-weight: 600;
	letter-spacing: 0;
	text-transform: none;
	cursor: pointer;
	padding: 0;
}

:is(.dark .forum-search__section-action) {
	color: rgba(var(--color-primary-dark), 1);
}

.forum-search__list {
	display: flex;
	flex-direction: column;
}

.forum-search__item {
	display: flex;
	align-items: center;
	gap: 0.65rem;
	width: 100%;
	padding: 0.65rem 0.85rem;
	text-decoration: none;
	color: inherit;
	border: 0;
	background: transparent;
	cursor: pointer;
	text-align: left;
}

.forum-search__item:hover,
.forum-search__item:focus-visible,
.forum-search__item.is-active {
	background: rgba(var(--color-primary), 0.08);
}

:is(.dark .forum-search__item:hover),
:is(.dark .forum-search__item:focus-visible),
:is(.dark .forum-search__item.is-active) {
	background: rgba(var(--color-primary-dark), 0.1);
}

.forum-search__item-body {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.15rem;
	min-width: 0;
	flex: 1;
}

.forum-search__item-title {
	font-size: 0.9375rem;
	line-height: 1.3;
	font-weight: 500;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	max-width: 100%;
}

.forum-search__item-title strong {
	font-weight: 700;
	color: rgba(var(--color-primary), 1);
}

:is(.dark .forum-search__item-title strong) {
	color: rgba(var(--color-primary-dark), 1);
}

.forum-search__item-meta {
	font-size: 0.75rem;
	line-height: 1.2;
	color: rgba(var(--color-secondary), 1);
	opacity: 0.9;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	max-width: 100%;
}

.forum-search__avatar {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.75rem;
	height: 1.75rem;
	border-radius: 9999px;
	overflow: hidden;
	flex-shrink: 0;
	background: rgba(var(--color-primary), 0.12);
	color: rgb(var(--color-primary));
	font-size: 0.75rem;
	font-weight: 600;
}

.forum-search__avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.forum-search__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.75rem;
	height: 1.75rem;
	border-radius: 0.45rem;
	flex-shrink: 0;
	background: rgba(var(--color-secondary), 0.1);
	color: rgba(var(--color-secondary), 1);
}

.forum-search__empty,
.forum-search__loading {
	padding: 0.9rem 0.85rem;
	font-size: 0.875rem;
	color: rgba(var(--color-secondary), 1);
}

.forum-search__footer {
	border-top: 1px solid #e5e7eb;
	position: sticky;
	bottom: 0;
	/* Not "inherit": the direct parent (.forum-search__panel) has no
	   background of its own, so this must match .forum-search__suggest's
	   background explicitly — otherwise the sticky footer is transparent
	   and the scrolling results list shows through behind its text. */
	background: #fff;
}

:is(.dark .forum-search__footer) {
	border-top-color: rgb(51 65 85 / 0.65);
	background: #0f172a;
}

.forum-search__more {
	display: block;
	padding: 0.7rem 0.85rem;
	font-size: 0.875rem;
	font-weight: 500;
	color: rgba(var(--color-primary), 1);
	text-decoration: none;
}

:is(.dark .forum-search__more) {
	color: rgba(var(--color-primary-dark), 1);
}

.forum-search__more:hover,
.forum-search__more:focus-visible {
	background: rgba(var(--color-primary), 0.06);
}

:is(.dark .forum-search__more:hover),
:is(.dark .forum-search__more:focus-visible) {
	background: rgba(var(--color-primary-dark), 0.08);
}

/* Command-palette style overlay search (VS Code docs-search style):
   on open, the whole search box detaches from the header and floats
   centered near the top of the screen, over a blurred backdrop.
   Same behaviour on every screen size. */
.forum-search__backdrop {
	display: block;
	position: fixed;
	inset: 0;
	z-index: 70;
	background: rgba(15, 23, 42, 0.45);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease;
}

.forum-search__backdrop.is-visible {
	opacity: 1;
	pointer-events: auto;
}

.search-header.forum-search.is-sheet-open {
	position: fixed;
	left: 0.75rem;
	right: 0.75rem;
	top: max(0.75rem, env(safe-area-inset-top));
	z-index: 80;
	display: flex;
	flex-direction: column;
	/* Must override the base ".search-header.forum-search { width: 100% }"
	   rule — otherwise the box keeps its full pre-open width on top of the
	   left/right insets and overflows past the right edge of the screen. */
	width: auto;
}

@media (min-width: 640px) {
	.search-header.forum-search.is-sheet-open {
		left: 50%;
		right: auto;
		transform: translateX(-50%);
		top: 12vh;
		width: min(90vw, 34rem);
	}
}

.search-header.forum-search.is-sheet-open .forum-search__form {
	border-radius: 0.85rem;
	box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3);
}

.search-header.forum-search.is-sheet-open .forum-search__input {
	border-radius: 0.85rem;
}

.search-header.forum-search.is-sheet-open .forum-search__suggest {
	position: relative;
	left: auto;
	right: auto;
	top: 0.4rem;
	max-height: min(65vh, 24rem);
	border-radius: 0.85rem;
	display: flex;
	flex-direction: column;
}

.search-header.forum-search.is-sheet-open .forum-search__panel {
	max-height: min(65vh, 24rem);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	flex: 1;
}
