/* =============================================================================
   BD Media — search: autocomplete panel + search-results page furniture.

   Everything here reads a `--bd-*` token from bd-native.css, so dark mode is a token switch
   rather than a second stylesheet. The only literals in this file are the three `--bdm-sr-*`
   tints declared below, because the design system has no "selection highlight" token and
   inventing one inside a component rule is exactly what the house rule forbids.

   Two namespaces, both new, because nothing existing could be reused:
     .bd-suggest*   the autocomplete panel (no dropdown for a text input exists on this estate)
     .bd-sr*        search-page furniture (hero refine bar, facets, pager, no-results block)

   The result cards are NOT styled here. They are `.bdm-h-card` from bdm-home.css, produced by
   bdm_home_card() — the same function the native front page uses. If a card ever looks wrong on
   search, the fix belongs in the shared card, not in a search-only copy of it.
   ============================================================================= */

:root {
	--bdm-sr-mark: rgba(190, 30, 81, .14);
	--bdm-sr-mark-ink: #101828;
	--bdm-sr-row-hover: rgba(16, 24, 40, .05);
}
html[data-bd-theme='dark'] {
	--bdm-sr-mark: rgba(255, 92, 141, .26);
	--bdm-sr-mark-ink: #f2f4f8;
	--bdm-sr-row-hover: rgba(255, 255, 255, .07);
}

/* ================================================================= autocomplete
   The panel is injected by JS into the form that owns the input, which is why the host form gets
   `position: relative` from this class rather than from a change to bd-native.css — the header,
   the mobile drawer and the search page all reuse the same control, and none of them is edited. */
form.bd-suggest-host { position: relative; }

.bd-suggest {
	position: absolute;
	top: calc(100% + 6px);
	left: 0;
	z-index: 9500;
	width: min(430px, calc(100vw - 24px));
	max-height: min(70vh, 460px);
	overflow-y: auto;
	overscroll-behavior: contain;
	background: var(--bd-card);
	border: 1px solid var(--bd-line);
	border-radius: var(--bd-radius);
	box-shadow: var(--bd-shadow-lift);
	text-align: left;
}
.bd-suggest[hidden] { display: none !important; }

/* 🔴 RIGHT-anchored, not left. The header form is the last item in a right-aligned flex row, so a
   left-anchored 430px panel ran to x=1536 on a 1440px viewport — measured by the QC pass
   (`1106..1536 of 1440`). Anchoring to the form's right edge keeps the panel inside the viewport
   for the header, the drawer and the page refine bar alike. */
.bd-search .bd-suggest,
.bd-drawer__search .bd-suggest {
	left: auto;
	right: 0;
	width: min(430px, calc(100vw - 24px));
}

.bd-suggest__hd {
	padding: 9px 12px 5px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--bd-muted);
}

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

.bd-suggest__row {
	display: flex;
	align-items: center;
	gap: 11px;
	min-height: 52px;
	padding: 7px 12px;
	border: 0;
	background: transparent;
	color: inherit;
	text-decoration: none;
	cursor: pointer;
}
.bd-suggest__row:hover,
.bd-suggest__row[aria-selected='true'] { background: var(--bdm-sr-row-hover); }
.bd-suggest__row:focus-visible { outline: 2px solid var(--bd-accent); outline-offset: -2px; }

.bd-suggest__thumb {
	flex: 0 0 auto;
	width: 58px;
	height: 44px;
	object-fit: cover;
	border-radius: 5px;
	background: var(--bd-bg-alt);
}

.bd-suggest__body { min-width: 0; }

.bd-suggest__t {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	font-family: var(--bd-ff-display);
	font-size: 14.5px;
	font-weight: 600;
	line-height: 1.3;
	color: var(--bd-ink);
	overflow-wrap: break-word;
}
.bd-suggest__m {
	display: block;
	margin-top: 2px;
	font-size: 12px;
	line-height: 1.35;
	color: var(--bd-muted);
}

.bd-suggest__ft {
	border-top: 1px solid var(--bd-line-soft);
}
.bd-suggest__all {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	min-height: 46px;
	padding: 8px 12px;
	font-size: 14px;
	font-weight: 600;
	color: var(--bd-accent);
	text-decoration: none;
}
.bd-suggest__all:hover { text-decoration: underline; }

.bd-suggest__empty {
	margin: 0;
	padding: 14px 12px 16px;
	font-size: 14px;
	line-height: 1.5;
	color: var(--bd-muted);
}

/* the visually-hidden live region — the panel's own announcement channel */
.bd-suggest__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* ================================================================= highlight
   Applied client-side to card titles/excerpts and to nothing else. `<mark>`'s UA default is a
   hard yellow that fights the brand, so it is retinted rather than replaced — the element keeps
   its semantics for assistive tech. */
mark.bdm-mark {
	background: var(--bdm-sr-mark);
	color: var(--bdm-sr-mark-ink);
	padding: 0 .1em;
	border-radius: 3px;
}

/* ================================================================= the results page */
body.search-results .bd-sr-head { padding-bottom: 30px; }

.bd-sr-refine {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
	margin-top: 22px;
}
/* The page's refine bar is the primary control on the page, so it is the flex grower and its
   input is bigger than the header's 190px one — the header is a shortcut, this is the tool. */
.bd-sr-refine .bd-search { flex: 1 1 320px; max-width: 620px; }
.bd-sr-refine .bd-search__input {
	flex: 1 1 auto;
	width: auto;
	height: 46px;
	font-size: 16px;
	border-radius: 9px 0 0 9px;
}
.bd-sr-refine .bd-search__btn { height: 46px; width: 52px; border-radius: 0 9px 9px 0; }

.bd-sr-sort { display: flex; align-items: center; gap: 6px; }
.bd-sr-sort__opt {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 0 13px;
	border: 1px solid var(--bd-line);
	border-radius: 999px;
	font-size: 14px;
	color: var(--bd-body-ink);
	text-decoration: none;
	background: var(--bd-card);
}
.bd-sr-sort__opt:hover { border-color: var(--bd-accent); color: var(--bd-accent); }
.bd-sr-sort__opt[aria-current='true'] {
	background: var(--bd-accent);
	border-color: var(--bd-accent);
	color: #fff;
}

.bd-sr-facets {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin-top: 16px;
}
.bd-sr-facets__label {
	margin-right: 4px;
	font-size: 13px;
	font-weight: 600;
	color: var(--bd-muted);
}
.bd-sr-facet {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	min-height: 44px;
	padding: 0 14px;
	border: 1px solid var(--bd-line);
	border-radius: 999px;
	background: var(--bd-card);
	font-size: 14px;
	color: var(--bd-body-ink);
	text-decoration: none;
}
.bd-sr-facet:hover { border-color: var(--bd-accent); color: var(--bd-accent); }
.bd-sr-facet__n {
	font-size: 12px;
	font-weight: 700;
	color: var(--bd-accent);
}

/* ---- pager ---- */
.bd-sr-pager { margin-top: 34px; }
.bd-sr-pager__label {
	margin: 0 0 12px;
	font-size: 13px;
	color: var(--bd-muted);
}
.bd-sr-pager .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	min-height: 44px;
	padding: 0 12px;
	margin: 0 4px 8px 0;
	border: 1px solid var(--bd-line);
	border-radius: 9px;
	background: var(--bd-card);
	color: var(--bd-body-ink);
	font-size: 15px;
	text-decoration: none;
}
.bd-sr-pager .page-numbers:hover { border-color: var(--bd-accent); color: var(--bd-accent); }
.bd-sr-pager .page-numbers.current {
	background: var(--bd-accent);
	border-color: var(--bd-accent);
	color: #fff;
	font-weight: 700;
}
.bd-sr-pager .page-numbers.dots { border-color: transparent; background: transparent; }
.bd-sr-pager ul.page-numbers {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* ---- no-results / empty-query state ---- */
.bd-sr-none { max-width: var(--bd-measure); }
.bd-sr-tips {
	margin: 0;
	padding-left: 20px;
	font-size: 16px;
	line-height: 1.7;
	color: var(--bd-body-ink);
}
.bd-sr-tips li { margin-bottom: 8px; }
.bd-sr-block-title { margin-top: 38px; }

/* ================================================================= dark mode, scoped
   bdm-home.css paints the cards with literal hex, so the card system does not re-token on its own.
   These rules are scoped to the search page (and the 404, which shares the form) rather than
   rewriting the shared card — that file belongs to the homepage workstream and changing it here
   would be a silent, cross-surface edit. */
html[data-bd-theme='dark'] body.search-results .bdm-h-card__title,
html[data-bd-theme='dark'] body.search-results .bdm-h-card__excerpt,
html[data-bd-theme='dark'] body.search-results .bdm-h-card__media { color: var(--bd-ink); }
html[data-bd-theme='dark'] body.search-results .bdm-h-card__excerpt { color: var(--bd-body-ink); }
html[data-bd-theme='dark'] body.search-results .bdm-h-card__meta,
html[data-bd-theme='dark'] body.search-results .bdm-h-card__meta time { color: var(--bd-muted); }
html[data-bd-theme='dark'] body.search-results .bdm-h-card__media { background: var(--bd-bg-alt); }

/* ================================================================= mobile */
@media (max-width: 767px) {
	.bd-sr-refine { gap: 10px; }
	.bd-sr-refine .bd-search { flex: 1 1 100%; max-width: none; }
	.bd-sr-refine .bd-search__input { height: 48px; }
	.bd-sr-refine .bd-search__btn { height: 48px; }
	.bd-sr-sort { width: 100%; }
	.bd-sr-sort__opt { flex: 1 1 0; justify-content: center; }
	.bd-sr-facets__label { flex: 1 1 100%; margin-bottom: 2px; }
	.bd-suggest { width: calc(100vw - 24px); max-height: 64vh; }
	.bd-suggest__row { min-height: 56px; }
	.bd-sr-pager { margin-top: 26px; }
	.bd-sr-block-title { margin-top: 30px; }
}

@media (prefers-reduced-motion: reduce) {
	.bd-suggest,
	.bd-suggest__row,
	.bd-suggest__thumb,
	.bd-sr-facet,
	.bd-sr-sort__opt { transition: none !important; animation: none !important; }
}
