/*
 * Header search box and its drop-down (inc/alx-site-search.php, assets/js/alx-search.js; AlexanianOS memory
 * "Website search (Algolia replacement)", step 4).
 *
 * Part 1 keeps the box looking exactly as it did under the Algolia plugin: the search-box rules from the plugin's
 * satellite-min.css (InstantSearch's theme) and its search.css, copied here so the look stays when the plugin is
 * switched off. The box keeps InstantSearch's class names (ais-SearchBox-…) for the same reason.
 * Part 2 is the new drop-down: photo, name, colour or size, and price, then pages in their own group.
 */

/* ---------- Part 1: the box (from the Algolia plugin's CSS) ---------- */

html[overlay="true"] { overflow-y: hidden; }
#mobileSearchMenu { max-height: 100vh; overflow: auto; }
#searchbox-wrapper { display: none; }
#searchbox { width: 100%; }
#searchbox-mobile-wrapper form { margin-bottom: 1rem; }
@media only screen and (min-width: 576px) {
  #searchbox-wrapper { display: block; }
}

.ais-SearchBox-submit, .ais-SearchBox-reset {
  padding: 0; overflow: visible; font: inherit; line-height: normal; color: inherit; background: none; border: 0;
  cursor: pointer; -webkit-user-select: none; -moz-user-select: none; user-select: none;
}
.ais-SearchBox-submit::-moz-focus-inner, .ais-SearchBox-reset::-moz-focus-inner { padding: 0; border: 0; }
.ais-SearchBox-input::-ms-clear, .ais-SearchBox-input::-ms-reveal { display: none; width: 0; height: 0; }
.ais-SearchBox-input::-webkit-search-decoration, .ais-SearchBox-input::-webkit-search-cancel-button,
.ais-SearchBox-input::-webkit-search-results-button, .ais-SearchBox-input::-webkit-search-results-decoration {
  display: none; -webkit-appearance: none; appearance: none;
}
.ais-SearchBox-form {
  background-color: #fff; display: flex; font-size: .875rem; height: 2.5rem; line-height: 1.25rem; position: relative; width: 100%;
}
.ais-SearchBox-form::before {
  background: rgba(0,0,0,0) url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2216%22%20height%3D%2216%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%235a5e9a%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Ccircle%20cx%3D%2211%22%20cy%3D%2211%22%20r%3D%228%22%3E%3C%2Fcircle%3E%3Cline%20x1%3D%2221%22%20y1%3D%2221%22%20x2%3D%2216.65%22%20y2%3D%2216.65%22%3E%3C%2Fline%3E%3C%2Fsvg%3E") repeat scroll 0% 0%;
  content: ""; height: 1rem; left: 1rem; margin-top: -0.5rem; position: absolute; top: 50%; width: 1rem;
}
.ais-SearchBox-input {
  -webkit-appearance: none; -moz-appearance: none; appearance: none; background-color: #fff; border: 1px solid #d6d6e7;
  border-radius: 3px; box-shadow: rgba(119,122,175,.3) 0 1px 4px 0 inset; caret-color: #5a5e9a; color: #23263b;
  flex: 1 1 0%; font: inherit; max-width: 100%; padding-left: 2.5rem !important;
}
.ais-SearchBox-input::placeholder { color: #5a5e9a; }
.ais-SearchBox-input:focus { border-color: #3c4fe0; box-shadow: rgba(35,38,59,.05) 0 1px 0 0; outline: currentcolor none medium; }
.ais-SearchBox-reset {
  align-items: center; border-radius: 50%; display: flex; fill: #484c7a; height: 20px; justify-content: center;
  position: absolute; right: 1rem; top: 50%; transform: translateY(-50%); width: 20px;
}
.ais-SearchBox-reset:focus { background: #b6b7d5; fill: #fff; outline: 0; }
.ais-SearchBox-reset[hidden] { display: none; }
.ais-SearchBox-submit { display: none; }
@media (max-width: 767px) {
  .ais-SearchBox-input { font-size: 1rem; }
}

#searchbox-wrapper .hits {
  position: absolute; right: 0; top: calc(100% + 0.5rem); background: white; padding: 1rem; width: min(22rem, 95vw);
  border-radius: 5px; box-shadow: 0 0 10px darkgray; display: none; overflow: auto; max-height: 70vh; z-index: 1000;
}
#searchbox-wrapper .hits.on { display: block; }
#searchbox-wrapper .hits::-webkit-scrollbar { width: auto; }
#searchbox-wrapper .hits::-webkit-scrollbar-track { background-color: transparent; }
#searchbox-wrapper .hits::-webkit-scrollbar-thumb {
  background-color: #d6dee1; border-radius: 20px; border: 6px solid transparent; background-clip: content-box;
}
#searchbox-wrapper .hits::-webkit-scrollbar-thumb:hover { background-color: #a8bbbf; }
/* The drop-down is empty until something is typed: no box then. */
.hits.on:empty { display: none !important; }

/* ---------- Part 2: the drop-down ---------- */

.alx-sr { color: #303030; font-size: 14px; line-height: 1.3; }
.alx-sr-list { list-style: none; margin: 0; padding: 0; }
.alx-sr-item a {
  display: flex; align-items: center; gap: 10px; padding: 6px; margin: 0 -6px; border-radius: 4px;
  color: inherit; text-decoration: none;
}
.alx-sr-item a:hover, .alx-sr-item.is-active a { background: #f0f0f0; }
.alx-sr-photo {
  flex: 0 0 48px; width: 48px; height: 48px; border-radius: 3px; background: #f0f0f0; object-fit: cover; display: block;
}
.alx-sr-text { flex: 1 1 auto; min-width: 0; }
.alx-sr-name { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alx-sr-detail { display: block; color: #6b6b6b; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alx-sr-price { flex: 0 0 auto; text-align: right; font-size: 13px; white-space: nowrap; }
.alx-sr-price del { color: #757575; display: block; font-size: 12px; }
.alx-sr-price ins { color: #c11633; text-decoration: none; font-weight: 500; background: none; }
.alx-sr-soldout { display: block; color: #757575; font-size: 12px; }
.alx-sr-heading {
  margin: 12px 0 4px; padding-top: 10px; border-top: 1px solid #e6e6e6; font-size: 12px; font-weight: 500;
  letter-spacing: .04em; text-transform: uppercase; color: #6b6b6b;
}
.alx-sr-page a { display: block; padding: 6px; margin: 0 -6px; border-radius: 4px; color: inherit; text-decoration: none; }
.alx-sr-page a:hover, .alx-sr-page.is-active a { background: #f0f0f0; }
.alx-sr-page .alx-sr-detail { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.alx-sr-all {
  display: block; margin-top: 10px; padding: 8px; text-align: center; border-radius: 4px; background: #303030; color: #fff !important;
  text-decoration: none; font-weight: 500;
}
.alx-sr-all:hover { background: #c11633; }
.alx-sr-none { margin: 0; color: #6b6b6b; }
.alx-sr-note { margin: 0 0 8px; color: #6b6b6b; font-size: 13px; }

/* Results page: the matching pages under the products, and the "left out" note above them. */
.alx-search-pages { margin: 2rem 0; padding-top: 1.5rem; border-top: 1px solid #e6e6e6; }
.alx-search-pages h2 { font-size: 20px; color: #303030; margin: 0 0 1rem; }
.alx-search-pages ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.alx-search-pages li a { display: block; padding: 12px; border: 1px solid #e6e6e6; border-radius: 4px; color: #303030; text-decoration: none; height: 100%; }
.alx-search-pages li a:hover { border-color: #303030; }
.alx-search-pages strong { display: block; margin-bottom: 4px; }
.alx-search-pages span { color: #6b6b6b; font-size: 14px; }
.alx-search-dropped { margin: 0 0 1rem; color: #6b6b6b; }
