/* ============================================
   SEARCH — one page: the engine at rest, results once it runs
   ============================================ */
/* The page container centres its children, and .hub-layout centres itself with
   auto margins, so both need an explicit width or the results squeeze into a
   narrow column. */
.search-page { display: flex; flex-direction: column; width: 100%; }
.search-body { width: 100%; }

/* At rest the box floats in the middle of what is left of the screen and the
   terms typed before sit directly under it. */
.search-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  flex: 1 0 auto;
  min-height: calc(100vh - 240px);
  padding: var(--space-6) 0 var(--space-12);
}

/* Committing a search lifts the box to the top and shrinks it, so the whole
   page below is results. */
.search-page.is-active .search-stage {
  justify-content: flex-start;
  min-height: 0;
  padding: var(--space-1) 0 var(--space-6);
}

/* The box is the loudest thing on the page until it has been used. */
/* The field wraps box + suggestion list so the dropdown can hang off the box
   without the results page moving underneath it. */
.search-field { position: relative; width: min(660px, 100%); }
.search-box {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  height: 64px;
  padding: 0 var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  transition: height 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.search-page.is-active .search-box {
  height: 48px;
  padding: 0 var(--space-4);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.search-box:focus-within { border-color: var(--border-focus); }
.search-box-icon { display: flex; flex-shrink: 0; color: var(--text-muted); }
.search-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}
.search-page.is-active .search-input { font-size: 16px; font-weight: 500; }
.search-input::placeholder { color: var(--text-muted); font-weight: 500; }
.search-box-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--surface-hover);
  color: var(--text-secondary);
  cursor: pointer;
}
.search-box-clear:hover { background: var(--border); color: var(--text-primary); }
.search-box-clear[hidden] { display: none; }

/* -------------------------------- suggest -------------------------------- */
/* Titles and names only, so every row is something the results page can
   actually find. It floats over the results rather than pushing them down. */
.search-suggest {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: min(320px, 52vh);
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.search-suggest[hidden] { display: none; }
.search-suggest-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 15px;
  text-align: left;
  color: var(--text-primary);
  cursor: pointer;
}
.search-suggest-item:hover,
.search-suggest-item.is-active { background: var(--surface-hover); }
/* The icon is the only thing saying gliim or person, so it cannot be the
   faintest element in the row. */
.search-suggest-icon { display: flex; flex-shrink: 0; color: var(--text-secondary); }
.search-suggest-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-suggest-text b { font-weight: 700; }

/* --------------------------------- history -------------------------------- */
.search-history { width: min(660px, 100%); display: grid; gap: 2px; }
.search-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px var(--space-1);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.search-history-clear {
  border: none;
  background: none;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-secondary);
  cursor: pointer;
}
.search-history-clear:hover { color: var(--brand-primary); }
.search-history-item { display: flex; align-items: center; gap: var(--space-1); }
.search-history-term {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 15px;
  text-align: left;
  color: var(--text-primary);
  cursor: pointer;
}
.search-history-term svg { flex-shrink: 0; color: var(--text-muted); }
.search-history-term span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-history-term:hover { background: var(--surface-hover); }
.search-history-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.search-history-remove:hover { background: var(--surface-hover); color: var(--text-primary); }

/* --------------------------------- results -------------------------------- */
/* Gliims, people and collections render through the classes already owned by
   XpLoRe (xplore-slice, xplore-row, xplore-people, library-feed), so a result
   is the same object the feed shows. */
.search-body { display: grid; gap: var(--space-10); padding-top: var(--space-1); }
.search-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  font-size: 14px;
  color: var(--text-secondary);
}
.search-results-clear {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.search-results-clear:hover { border-color: var(--brand-primary); color: var(--brand-primary); }
.search-status {
  width: 100%;
  text-align: center;
  padding: 60px 0;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .search-stage { min-height: calc(100vh - 210px); padding: var(--space-4) 0 var(--space-8); }
  .search-page.is-active .search-stage { padding: 0 0 var(--space-4); }
  .search-box { height: 54px; padding: 0 var(--space-4); }
  .search-page.is-active .search-box { height: 44px; padding: 0 var(--space-3); }
  .search-input { font-size: 17px; }
  .search-page.is-active .search-input { font-size: 15px; }
  .search-history { margin-top: var(--space-2); }
  .search-suggest { max-height: 46vh; }
  .search-suggest-item { font-size: 14px; }
  .search-body { gap: var(--space-8); }
}
