/*
 * Search results (modules/search/quick.js: /search-results, the awards timeline, the wishlist,
 * furniture search and CMS pages with an embedded search), moving to the design system, and the
 * search controls they share with the advanced, boolean and embedded searches (sort items, filter tags).
 *
 * Not search.css, which is legacy CSS for modals and the ordering grid, added with setCss().
 *
 * Loaded on every main-site page, as those controls appear on several. Unlayered, like shell.css,
 * so these rules win over everything in the legacy layer, including legacy rules on IDs: keep
 * selectors scoped to the search markup and set only the properties that need to change.
 */

/* Keyboard focus. Legacy CSS removes the outline from fields. The filter sidebar is also on the
   advanced search page, outside #searchForm. */
#searchForm :focus-visible,
#searchFilters :focus-visible,
.sortItemList :focus-visible,
.filterTag :focus-visible {
	outline: var(--focus-ring);
	outline-offset: var(--focus-ring-offset);
}

/* The book page's image lightbox (structure/simple/footer.php) is outside #searchForm, over a dark
   backdrop: white outside and steel inside, so the focus shows on the backdrop and on the images */
#lightbox :focus-visible {
	outline: 2px solid var(--color-on-primary);
	outline-offset: 2px;
	box-shadow: 0 0 0 2px var(--color-primary);
}

/* The rating filters' radio buttons are invisible over their icons, so the icon shows the focus */
.rating.clickable span:has(input:focus-visible) label {
	outline: var(--focus-ring);
	outline-offset: var(--focus-ring-offset);
}

/*
 * Controls that were <span>s, <div>s, <i>s or headings and are now buttons. Undo what legacy and
 * browser button styles add (a blue fill, capitals, a block with margins), then restate the legacy
 * rules each had, which the reset would otherwise override.
 */
.search-plain-button {
	display: inline-block;
	background: none;
	border: 0;
	margin: 0;
	padding: 0;
	width: auto;
	font: inherit;
	color: inherit;
	text-transform: none;
	text-align: inherit;
	cursor: pointer;
}

.search-plain-button:hover {
	background: none;
	color: inherit;
}

/* search.css (legacy) colours it on hover */
.saveSearch.search-plain-button:hover {
	color: var(--color-primary);
}

.toggleFilterSidebar {
	padding-right: 10px;
	font-weight: bold;
}

.addSortItem {
	padding: 2px 4px;
	border-radius: var(--radius-full);
}

.addSortItem:hover {
	background-color: var(--grey-100);
}

.searchHeadBar .updateList {
	margin: 0 1rem 0 0;
	font-size: 0.8em;
	color: var(--grey-800);
}

.updateList i {
	transition: transform 0.5s;
}

.updateList:hover i {
	transform: rotate(360deg);
}

/* Sort items (SearchHelper::buildSortItemsHtml), also on the advanced, boolean and embedded searches */
.sortItemList .sortOrder,
.sortItemList .removeSortItem {
	background: none;
	border: 0;
	width: auto;
	color: inherit;
	font-family: inherit;
	line-height: inherit;
	text-transform: none;
}

.sortItemList .sortOrder {
	margin: 0 10px 0 0;
	padding: 0;
}

.sortItemList .removeSortItem {
	margin: 0 2px 0 0;
	padding: 2px 7px;
	font-size: inherit;
	border-radius: var(--radius-full);
}

.sortItemList .sortOrder:hover {
	background: none;
	color: inherit;
}

.sortItemList .removeSortItem:hover {
	background-color: var(--grey-100);
	color: inherit;
}

/* Filter tags (Filter::getTagHtml). Their colours are in default.css, so the variants there still apply. */
.filterTag .removeFilterTag {
	display: inline-block;
	margin: 0;
	padding: 0;
	width: auto;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	cursor: pointer;
}

/* The applied filters, now a list */
#appliedFilters {
	margin: 2px 0;
	padding: 0;
	list-style: none;
}

.missingIsbns {
	padding: 0;
	list-style: none;
}

/* Results count, view buttons and the sidebar toggle above the results */
.viewButtons .viewOptions {
	color: var(--color-primary);
}

/* The view icons are graphics, which need 3:1: Peters blue, and the text colour for the one in use */
.viewOptions .viewTypeSelector {
	color: var(--color-title);
}

.viewOptions .viewTypeSelector.selectedSeachView {
	color: var(--color-text);
}

/* Sort and pagination bar */
.searchHeadBar .pagination .ds-pagination {
	padding: 4px 0;
}

/* Buttons above the results: steel and in sentence case, as the style guide asks */
.searchButtonsBar .button {
	background-color: var(--color-primary);
	color: var(--color-on-primary);
	text-transform: none;
	font-family: inherit;
}

.searchButtonsBar .button:hover {
	background-color: var(--color-primary-hover);
}

/* "Add current page to <bookshelf>", now a button; was a <div> holding a <p class="wishlistText"> */
#addPageToBookshelf {
	margin: 0;
	text-transform: none;
	font-family: inherit;
	font-size: inherit;
	text-align: left;
}

#addPageToBookshelf .wishlistText {
	display: inline-block;
	margin: 0 0 0 auto;
	white-space: nowrap;
}

/* Add to basket and bookshelf dropdowns: the select is an invisible target over the chevron, 21px
   wide, next to the button it belongs to. 24px is the smallest target WCAG 2.2 allows that close. */
.addToBasketSelectWrapper .addToBasketSelect {
	box-sizing: border-box;
	min-width: 24px;
	/* all padding, so no room is left for the selected option's text */
	padding-right: 24px;
}

/* The Filter buttons that open and close the sidebar on phones: sentence case, as the style guide asks */
.searchButtonsBar .hamburgerText,
.mobileSidebar .hamburgerText {
	text-transform: none;
}

/* Furniture results heading, a button that shows and hides them */
.furnitureResultsHeading .search-plain-button {
	color: var(--color-primary);
}

/* Awards timeline (src/Views/Award/timeline.phtml): each award is a button filling its row, laid out as
   the <div>s inside it were. The row (.award) keeps its padding, colours and the chosen award's grey. */
#awardsTimeline .awardButton {
	display: block;
	width: 100%;
	height: auto;
	border-radius: 0;
	box-shadow: none;
	letter-spacing: inherit;
	line-height: inherit;
}

#awardsTimeline .awardButton > span {
	display: block;
}

#awardsTimeline .awardButton:focus-visible {
	outline: var(--focus-ring);
	outline-offset: 10px;
}
