/* ===== Header search block ===== */
.fs-header-search {
  position: relative;
  max-width: 420px;
  width: 100%;
}

/* Widen the header search reveal by 20% (theme sets 300px / -320px shift;
 * !important needed because theme CSS aggregates after module CSS). */
#block-finelite-fineliteheadersearch {
  width: 360px !important;
}

.region-topbar.search-open .menu--meta-contat-us {
  transform: translateX(-380px) !important;
}

.fs-header-search__form {
  position: relative;
  display: flex;
  align-items: center;
}

/* Positioning context for the in-input icon, scope pill, and close X, so
 * they anchor to the input itself (not the reset link on /search). */
.fs-header-search__inputwrap {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
}

.fs-header-search__input {
  width: 100%;
  padding: 0.55rem 7rem 0.55rem 2.3rem;
  border: 1px solid #d0d3d8;
  border-radius: 4px;
  font-size: 0.9rem;
  line-height: 1.4;
}

/* Header variant has the X close button too — leave room for it. */
.fs-header-search--closable .fs-header-search__input {
  padding-right: 8.6rem;
}

.fs-header-search__input:focus {
  outline: none;
  border-color: #1a3e6f;
  box-shadow: 0 0 0 2px rgba(26, 62, 111, 0.15);
}

/* Magnifying glass sits inside the input, left of the placeholder. */
.fs-header-search__submit {
  position: absolute;
  left: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: #4a4f57;
  display: flex;
  padding: 0.15rem;
  z-index: 2;
}

/* ===== Search inside the mobile menu =====
 *
 * The theme styles this block plugin for the dark top bar — absolutely
 * positioned, fixed width, right-aligned flex, borderless input — and hides
 * it outright on small screens, because mobile used to link out to a separate
 * search page. The mobile menu placement is the same plugin, so it inherits
 * all of that.
 *
 * Every rule below therefore leads with .mobile-nav-search plus BOTH block
 * classes: the theme's equivalents use two classes and load after this file,
 * so anything less specific loses on source order. */
.mobile-nav-search {
  padding: 0.75rem 1rem 0.5rem;
}

.mobile-nav-search,
.mobile-nav-search *,
.mobile-nav-search *::before,
.mobile-nav-search *::after {
  box-sizing: border-box;
}

.mobile-nav-search .block-finelite-search.block-finelite-header-search {
  display: block;
  position: static;
  top: auto;
  right: auto;
  width: auto;
  max-width: 100%;
  z-index: auto;
}

.mobile-nav-search .block-finelite-search.block-finelite-header-search .fs-header-search {
  display: block;
  width: 100%;
  max-width: 100%;
  gap: 0;
}

.mobile-nav-search .block-finelite-search.block-finelite-header-search .fs-header-search__form {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
}

.mobile-nav-search .block-finelite-search.block-finelite-header-search .fs-header-search__inputwrap {
  flex: 0 0 100%;
  width: 100%;
  max-width: 100%;
}

/* Restore the visible outline the top-bar styling removes (it sits on a dark
 * bar, so it has no border of its own), and use 16px so iOS doesn't zoom the
 * page on focus.
 *
 * Matches the theme's own selector shape — three classes plus an attribute
 * and element — with .mobile-nav-search on the front, because a plain class
 * selector loses to it however many classes it stacks. */
.mobile-nav-search .block-finelite-search.block-finelite-header-search .fs-header-search input[name="keys"] {
  /* Must be set here, not on a wrapper: without it the 100% width and the
   * padding add up and the box runs past the panel's right edge. */
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  height: auto;
  font-size: 16px;
  padding: 0.6rem 7rem 0.6rem 2.3rem;
  border: 1px solid #b9bec6;
  border-radius: 4px;
  background: #fff;
  color: #1a1c1f;
}

.mobile-nav-search .block-finelite-search.block-finelite-header-search .fs-header-search input[name="keys"]:focus {
  outline: none;
  border-color: #1a3e6f;
  box-shadow: 0 0 0 2px rgba(26, 62, 111, 0.15);
}

/* Results sit below the box, full width, scrolling with the menu rather than
 * floating over the page. Without the explicit row it stays a flex sibling of
 * the input and the two split the width. */
.mobile-nav-search .block-finelite-search.block-finelite-header-search .fs-suggestions {
  position: static;
  flex: 0 0 100%;
  width: 100%;
  max-width: 100%;
  max-height: 60vh;
  box-shadow: none;
  margin-top: 0.5rem;
}

/* Loading throbber: while suggestions are being fetched, the magnifier
 * swaps for a spinner so typing visibly "does something". Cleared as soon
 * as results (or no results) come back. */
.fs-header-search.is-loading .fs-header-search__submit svg {
  opacity: 0;
}

.fs-header-search.is-loading .fs-header-search__submit::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid #c7cad0;
  border-top-color: #1a3e6f;
  border-radius: 50%;
  animation: fs-spin 0.7s linear infinite;
}

@keyframes fs-spin {
  to { transform: rotate(360deg); }
}

/* "Products only" scope pill inside the right edge of the input. */
.fs-header-search__scope {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  background: #f0f1f3;
  border: 1px solid #d0d3d8;
  border-radius: 999px;
  font-size: 0.72rem;
  line-height: 1.2;
  color: #4a4f57;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  z-index: 2;
}

.fs-header-search--closable .fs-header-search__scope {
  right: 2.1rem;
}

.fs-header-search__scope-input {
  margin: 0;
  width: 12px;
  height: 12px;
  accent-color: #1a3e6f;
  cursor: pointer;
}

/* X close button (header only): far right inside the input. */
.fs-header-search__close {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: #4a4f57;
  display: flex;
  padding: 0.2rem;
  border-radius: 50%;
  z-index: 2;
}

.fs-header-search__close:hover {
  color: #1a1c1f;
  background: #e6e8eb;
}

/* While the top-bar search is open, hide the "Search" menu item (icon +
 * label); the X in the input closes the search and reveals it again. */
.region-topbar.search-open li.menu-item:has(> span[title="Search"]) {
  display: none;
}

/* Fallback for browsers without :has() support. */
.region-topbar.search-open .menu span[title="Search"] {
  display: none;
}

.fs-header-search__reset {
  margin-left: 0.75rem;
  font-size: 0.85rem;
  color: #6a6f76;
  text-decoration: underline;
  white-space: nowrap;
}

.fs-header-search__reset:hover {
  color: #1a3e6f;
}

/* ===== Page-level filter (top of /search) ===== */
.fs-page__filter {
  margin-bottom: 1.5rem;
  max-width: 100%;
}

.fs-page__filter .fs-header-search {
  max-width: 100%;
}

.fs-page__filter .fs-header-search__form {
  gap: 0.5rem;
}

/* ===== Autocomplete suggestion dropdown ===== */
.fs-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e1e3e6;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  max-height: 70vh;
  overflow-y: auto;
  z-index: 200;
}

.fs-suggestion-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid #f0f1f3;
}

.fs-suggestion-card:last-child {
  border-bottom: none;
}

.fs-suggestion-card:hover,
.fs-suggestion-card.is-active {
  background: #f4f6f9;
}

.fs-suggestion-card__image {
  flex: 0 0 100px;
  width: 100px;
  height: 70px;
  border-radius: 4px;
  overflow: hidden;
  background: #f0f1f3;
}

.fs-suggestion-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.fs-suggestion-card__image-placeholder {
  width: 100%;
  height: 100%;
  background: #e6e8eb url('/themes/custom/finelite/logo.svg') center / 55% auto no-repeat;
}

.fs-suggestion-card__body {
  flex: 1;
  min-width: 0;
}

.fs-suggestion-card__title {
  font-weight: 600;
  font-size: 0.9rem;
  color: #1a1c1f;
  margin-bottom: 0.15rem;
}

.fs-suggestion-card__desc {
  font-size: 0.8rem;
  color: #6a6f76;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Search results page ===== */
.fs-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

.fs-page__title {
  font-size: 1.75rem;
  margin-bottom: 0.25rem;
}

.fs-page__count {
  color: #6a6f76;
  margin-bottom: 1.5rem;
}

.fs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1.5rem;
}

.fs-card {
  display: flex;
  flex-direction: column;
  border: 1px solid #e6e8eb;
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
  background: #fff;
}

.fs-card:hover {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.fs-card__image {
  aspect-ratio: 4 / 3;
  background: #f0f1f3;
}

.fs-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.fs-card__image-placeholder {
  width: 100%;
  height: 100%;
  background: #e6e8eb url('/themes/custom/finelite/logo.svg') center / 50% auto no-repeat;
}

.fs-card__body {
  padding: 0.9rem 1rem 1.1rem;
}

.fs-card__title {
  font-size: 1rem;
  margin: 0 0 0.35rem;
}

.fs-card__desc {
  font-size: 0.85rem;
  color: #6a6f76;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fs-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: #6a6f76;
  padding: 3rem 0;
}

/* ===== No results ===== */
.fs-noresults {
  grid-column: 1 / -1;
}

.fs-noresults__title {
  font-size: 1.15rem;
  font-weight: 600;
  color: #1a1c1f;
  margin: 0 0 0.35rem;
}

.fs-noresults__lead {
  color: #6a6f76;
  margin: 0 0 1.5rem;
}

.fs-grid--suggestions {
  margin-top: 0.5rem;
}

/* Compact variant inside the header autocomplete dropdown. */
.fs-noresults--compact {
  padding: 0.85rem 0.85rem 0.6rem;
  border-bottom: 1px solid #f0f1f3;
}

.fs-noresults--compact .fs-noresults__title {
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
}

.fs-noresults--compact .fs-noresults__lead {
  font-size: 0.8rem;
  margin: 0;
}

/* Cards are title-only now, so centre the text against the thumbnail. */
.fs-card__body {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
}

.fs-card__title {
  margin: 0;
}

.fs-load-more-wrap {
  text-align: center;
  margin-top: 2.5rem;
}

.fs-load-more {
  padding: 0.65rem 2rem;
  border: 1px solid #1a3e6f;
  background: #fff;
  color: #1a3e6f;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
}

.fs-load-more:hover {
  background: #1a3e6f;
  color: #fff;
}

.fs-load-more:disabled {
  opacity: 0.6;
  cursor: default;
}
