/**
 * Machine search (Algolia InstantSearch): filter, range sliders, result list, pagination.
 *
 * Plain CSS, maintained directly in this file – no SCSS, no build step.
 * Loaded on the pages of the machine search through page.includeCSS.algolia (EXT:hph).
 * The markup comes from Resources/Public/Javascript/algolia/search.js and the
 * InstantSearch widgets (class prefix "ais-"); the range slider is rheostat.
 *
 * Contents
 *   1. Variables
 *   2. Range slider
 *   3. Filter area
 *   4. Filter: refinement lists (dropdowns with checkboxes)
 *   5. Filter: category select
 *   6. Pagination
 *   7. Reset button and statistics
 *   8. Results
 */

/* ==========================================================================
   1. Variables
   ========================================================================== */

:root {
	--algolia-color-main: #0067b1;
	--algolia-color-main-light: #c6deef;
	--algolia-color-dark: #333;
	--algolia-color-grey: #777;
	--algolia-color-border: #ccc;
	--algolia-color-background: #f0f0f0;
	--algolia-color-arrow: #9f9f9f;

	/* --algolia-color-dark with transparency, for shadows and soft borders */
	--algolia-color-dark-30: rgba(51, 51, 51, .3);
	--algolia-color-dark-20: rgba(51, 51, 51, .2);

	--algolia-border: 2px solid var(--algolia-color-border);
	--algolia-box-padding: 15px;
	--algolia-shadow: 1px 1px 4px 0 var(--algolia-color-dark-30);
	--algolia-font-size-small: .8rem;
}

/* Breakpoint: 768px (tablet). Custom properties do not work in media queries,
   so the value is written out there. */

/* ==========================================================================
   2. Range slider
   ========================================================================== */

.ais-range-slider {
	border: var(--algolia-border);
	margin: 5px;
	padding: 0 20px;
}

.ais-range-slider:focus-within,
.ais-range-slider:hover {
	border-color: var(--algolia-color-main);
}

/* Current value above the handle */
.ais-range-slider--tooltip {
	position: absolute;
	transform: translateX(-50%);
	margin-left: 50%;
	top: -22px;
	text-align: center;
	font-size: var(--algolia-font-size-small);
	font-weight: bold;
}

/* Scale values below the track */
.ais-range-slider--value {
	margin-left: 50%;
	padding-top: 5px;
	position: absolute;
	text-align: center;
	transform: translateX(-50%);
	font-size: var(--algolia-font-size-small);
	font-weight: bold;
}

.ais-range-slider--body {
	padding: 0 12px;
}

.ais-range-slider--header {
	padding: 15px 0;
	font-weight: bold;
	font-size: var(--algolia-font-size-small);
	line-height: 1;
	pointer-events: none;
}

.ais-range-slider .rheostat {
	overflow: visible;
	margin-top: 30px;
	margin-bottom: 40px;
}

/* Track */
.ais-range-slider .rheostat-background {
	height: 4px;
	top: 0;
	width: 100%;
	position: relative;
	background-color: var(--algolia-color-grey);
}

.ais-range-slider .rheostat-handle {
	margin-left: -12px;
	top: -7px;
	border-color: var(--algolia-color-dark-20);
	transition: color .3s ease;
	box-shadow: var(--algolia-shadow);
}

.ais-range-slider .rheostat-handle:hover,
.ais-range-slider .rheostat-handle:focus {
	border-color: var(--algolia-color-main-light);
}

/* Selected part of the track */
.ais-range-slider .rheostat-progress {
	position: absolute;
	top: 0;
	height: 4px;
	background-color: var(--algolia-color-main);
}

/* Base styles of rheostat */
.rheostat-handle {
	position: relative;
	z-index: 1;
	width: 20px;
	height: 20px;
	background-color: #fff;
	border: 1px solid var(--algolia-color-dark);
	border-radius: 50%;
	cursor: grab;
}

.rheostat-marker {
	margin-left: -1px;
	position: absolute;
	width: 1px;
	height: 5px;
	background-color: #aaa;
}

.rheostat-marker--large {
	height: 9px;
}

.rheostat-value {
	padding-top: 15px;
	margin-left: 50%;
	position: absolute;
	text-align: center;
	transform: translateX(-50%);
}

.rheostat-tooltip {
	margin-left: 50%;
	position: absolute;
	text-align: center;
	transform: translateX(-50%);
	top: -22px;
}

/* ==========================================================================
   3. Filter area
   ========================================================================== */

.ms__filter {
	background-color: var(--algolia-color-background);
	margin-bottom: 20px;
}

/* Hidden until search.js opens the filter; then a grid with three areas */
.ms__filter .ms__selectors {
	display: none;
	grid-template-areas: 'types selects sliders';
	grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
	padding: 15px;
	margin: 20px 0;
}

.ms__filter .inner > div.ms__selector_cat {
	width: 100%;
}

.ms__filter .inner > div.ms__selector_cat > div {
	width: calc(100% / 3);
}

.ms__filter #ms__clear {
	width: 100%;
}

.ms__filter #ms__clear > div {
	padding: 15px;
}

.ms__filter select {
	background-color: transparent;
}

@media all and (max-width: 768px) {
	/* Areas below each other */
	.ms__filter .ms__selectors {
		grid-template-areas:
			'types'
			'selects'
			'sliders';
		padding: 5px;
		border: 0;
	}

	.ms__filter #ms__clear > div {
		padding: 10px;
	}
}

@media screen and (max-width: 768px) {
	.ms__filter .inner > div.ms__selector_cat > div {
		width: 100%;
	}
}

/* ==========================================================================
   4. Filter: refinement lists (dropdowns with checkboxes)
   ========================================================================== */

.ms__selector .ais-refinement-list {
	padding: 5px;
	position: relative;
}

/* Header = button that opens the list */
.ms__selector .ais-header:not(.ais-range-slider--header) {
	display: block;
	color: var(--algolia-color-dark);
	line-height: 1;
	position: relative;
	font-size: var(--algolia-font-size-small);
	font-weight: 600;
	cursor: pointer;
	padding: var(--algolia-box-padding);
	border: var(--algolia-border);
	padding-right: 25px;
}

/* Arrow */
.ms__selector .ais-header:not(.ais-range-slider--header):after {
	content: '';
	width: 0;
	height: 0;
	border-left: 6px solid transparent;
	border-right: 6px solid transparent;
	border-top: 6px solid var(--algolia-color-arrow);
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	right: 15px;
	transition: transform .2s ease-in-out;
}

.ms__selector .ais-header:not(.ais-range-slider--header):hover,
.ms__selector .ais-header:not(.ais-range-slider--header):focus-within {
	border-color: var(--algolia-color-main);
}

/* Open state (class set by search.js) */
.ms__selector .ais-refinement-list.open .ais-header:after {
	transform: rotate(-180deg) translateY(50%);
}

/* Flyout with the options */
.ms__selector .ais-refinement-list--body {
	display: none;
	position: absolute;
	top: 100%;
	left: 0;
	width: 100%;
	padding: 0 5px;
	z-index: 10;
}

.ms__selector .ais-refinement-list--body .ais-refinement-list--list {
	background-color: #fff;
	border-top: 0;
	max-height: 250px;
	overflow: hidden;
	overflow-y: auto;
	padding: 15px;
	box-shadow: var(--algolia-shadow);
	border-color: var(--algolia-color-dark-20);
	display: flex;
	flex-wrap: wrap;
	gap: 5px;
}

/* One option, shown as a tag */
.ms__selector .ais-refinement-list--item {
	border: var(--algolia-border);
	padding: 5px;
	padding-right: 8px;
	line-height: 1.5;
	transition: all .2s ease-in-out;
	cursor: pointer;
}

.ms__selector .ais-refinement-list--item label {
	display: block;
	font-weight: bold;
	font-size: 13px;
	cursor: pointer;
}

/* The checkbox itself is not shown, the whole tag is the control */
.ms__selector .ais-refinement-list--item input[type="checkbox"] {
	appearance: none;
	border: 0;
	margin: 0;
	font-weight: bold;
}

.ms__selector .ais-refinement-list--item:hover,
.ms__selector .ais-refinement-list--item__active {
	background: var(--algolia-color-main);
	color: #fff;
	border-color: var(--algolia-color-main);
}

/* Grid areas of .ms__selectors */
.ms__selector__types {
	grid-area: types;
	align-content: start;
}

.ms__selector__selects {
	grid-area: selects;
	display: grid;
	align-content: start;
}

.ms__selector__sliders {
	grid-area: sliders;
	display: grid;
	align-content: start;
}

.ms__selector__group.hide {
	display: none;
}

/* Number of hits behind an option */
.ais-refinement-list--count {
	display: none;
}

/* ==========================================================================
   5. Filter: category select
   ========================================================================== */

.ms__selector_cat .ais-menu-select {
	padding: 20px 0 20px 20px;
	position: relative;
}

.ms__selector_cat .ais-menu-select select {
	position: relative;
	color: var(--algolia-color-dark);
	font-size: var(--algolia-font-size-small);
	font-weight: bold;
	height: auto;
	appearance: none;
	padding: var(--algolia-box-padding);
	border: var(--algolia-border);
	padding-right: 25px;
	background-color: #fff;
}

.ms__selector_cat .ais-menu-select select:focus-within,
.ms__selector_cat .ais-menu-select select:hover {
	border-color: var(--algolia-color-main);
}

@media all and (max-width: 768px) {
	.ms__selector_cat .ais-menu-select {
		padding: 10px;
	}
}

/* ==========================================================================
   6. Pagination
   ========================================================================== */

#ms__pagination {
	margin: 20px 0 40px;
}

#ms__pagination ul {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

#ms__pagination li {
	padding: 0;
	width: 35px;
	line-height: 35px;
	text-align: center;
}

/* Remove the list bullet of the site styles */
#ms__pagination li:before {
	display: none;
}

#ms__pagination li a {
	text-decoration: none;
	text-align: center;
	display: block;
	transition: background-color .2s ease-in-out, color .2s ease-in-out;
}

#ms__pagination li a:hover {
	background-color: var(--algolia-color-dark);
	color: #fff;
}

/* Only page numbers, no previous/next links */
#ms__pagination li.ais-pagination--item__previous,
#ms__pagination li.ais-pagination--item__next {
	display: none;
}

#ms__pagination li.ais-pagination--item__active a {
	background-color: var(--algolia-color-main);
	color: #fff;
}

/* ==========================================================================
   7. Reset button and statistics
   ========================================================================== */

#ms__clear .ais-clear-all a {
	font-weight: 600;
	text-decoration: none;
	display: inline-block;
	text-transform: uppercase;
	line-height: 1;
	padding: var(--algolia-box-padding);
	border: var(--algolia-border);
}

#ms__clear .ais-clear-all a:hover,
#ms__clear .ais-clear-all a:focus-within {
	border-color: var(--algolia-color-main);
}

/* Reset symbol ⟲ */
#ms__clear .ais-clear-all a div:before {
	content: '\27F2';
	font-size: 1.4rem;
	line-height: 0;
	padding-right: .5ch;
}

#ms__clear .ais-clear-all div {
	line-height: 1;
}

#ms__stats {
	padding: 20px 0;
}

/* ==========================================================================
   8. Results
   ========================================================================== */

/* The negative margins let the 1px borders of neighbouring tiles overlap */
#ms__hits .ais-hits {
	display: flex;
	flex-wrap: wrap;
	margin-left: 1px;
	margin-top: 1px;
}

#ms__hits .ais-hits--item {
	width: calc(100% / 3);
	margin-left: -1px;
	margin-top: -1px;
}

#ms__hits .ais-hits--item a.ms__result {
	position: relative;
	z-index: 1;
	display: block;
	border: 1px solid #f5f5f5;
	padding: 10px 20px;
	height: 100%;
	text-decoration: none;
}

#ms__hits .ais-hits--item a.ms__result:hover img {
	transform: scale(1.02);
}

#ms__hits .ais-hits--item .image {
	height: 200px;
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

#ms__hits .ais-hits--item .image img {
	max-width: 100%;
	height: auto;
	display: block;
	transition: transform .2s ease-in-out;
}

#ms__hits .ais-hits--item .text {
	margin-top: 20px;
	padding-top: 20px;
}

/* Model name */
#ms__hits .ais-hits--item .text strong {
	color: var(--algolia-color-main);
	display: block;
	font-weight: 900;
	line-height: 1;
	font-size: 25px;
	text-transform: uppercase;
}

/* Arrow behind the model name, moves to the right on hover */
#ms__hits .ais-hits--item .text strong:after {
	content: '';
	background: url(../../Images/arrow-right-blue.svg) no-repeat right center;
	background-size: 9px auto;
	padding-right: 20px;
	height: 18px;
	width: 20px;
	display: inline-block;
	transition: padding-right .3s ease-in-out;
}

#ms__hits .ais-hits--item:hover .text strong:after {
	padding-right: 30px;
}

/* Series */
#ms__hits .ais-hits--item .text span {
	font-size: 15px;
	color: #909090;
}

@media screen and (max-width: 768px) {
	#ms__hits .ais-hits--item {
		width: 50%;
	}
}
