/*
  Site-wide search overlay.
  Consumes design tokens; field chrome stays in components.css (.hc-search).
*/

.hc-site-search {
  position: relative;
  z-index: calc(var(--z-header) + 20);
}

.hc-site-search__scrim {
  position: fixed;
  inset: 0;
  background-color: rgb(33 33 33 / 28%);
  z-index: calc(var(--z-header) + 10);
}

.hc-site-search__panel {
  position: absolute;
  top: calc(100% + var(--spacing-sm));
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  max-height: min(420px, 70vh);
  overflow: hidden;
  background-color: var(--color-background-base-default);
  border: var(--border-width-default) solid var(--color-border-default);
  border-radius: var(--radius-xl);
  box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
  z-index: calc(var(--z-header) + 30);
}

/* display:flex above overrides the UA [hidden] rule — restore it explicitly. */
.hc-site-search__panel[hidden] {
  display: none;
}

.hc-site-search__panel--expanded {
  max-height: min(560px, 80vh);
}

.hc-site-search__status {
  margin: 0;
  padding: var(--spacing-md) var(--spacing-lg);
  font-size: var(--font-size-md);
  line-height: var(--line-height-md);
  color: var(--color-text-muted);
}

.hc-site-search__status:empty {
  display: none;
  padding: 0;
}

.hc-site-search__results {
  margin: 0;
  padding: var(--spacing-xs) 0;
  list-style: none;
  overflow-y: auto;
  flex: 1 1 auto;
  scrollbar-gutter: stable;
}

.hc-site-search__result {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-md);
  width: 100%;
  margin: 0;
  padding: var(--spacing-md) var(--spacing-lg);
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-decoration: none;
}

.hc-site-search__result:hover {
  background-color: var(--color-background-base-hovered);
}

.hc-site-search__result[aria-selected="true"] {
  background-color: var(--color-background-primary-invert-default);
}

.hc-site-search__result[aria-selected="true"]:hover {
  background-color: var(--color-background-primary-invert-default);
}

.hc-site-search__result-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-rounded);
  background-color: var(--color-background-base-hovered);
  color: var(--color-icon-default);
}

.hc-site-search__result-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xxs);
}

.hc-site-search__result-title {
  margin: 0;
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-md);
  color: var(--color-text-default);
}

.hc-site-search__result-description {
  margin: 0;
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-md);
  color: var(--color-text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hc-site-search__result-mark {
  background-color: var(--color-background-base-hovered);
  color: inherit;
  border-radius: var(--radius-none);
  padding: 0 1px;
  font-weight: var(--font-weight-semibold);
}

.hc-site-search__result-chevron {
  flex-shrink: 0;
  align-self: center;
  color: var(--color-icon-placeholder);
  opacity: 0;
}

.hc-site-search__result[aria-selected="true"] .hc-site-search__result-chevron,
.hc-site-search__result:hover .hc-site-search__result-chevron {
  opacity: 1;
}

.hc-site-search__actions {
  padding: var(--spacing-sm) var(--spacing-lg) var(--spacing-md);
}

.hc-site-search__view-more {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-text-link);
  font: inherit;
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-md);
  cursor: pointer;
  text-decoration: none;
}

.hc-site-search__view-more:hover {
  text-decoration: underline;
}

.hc-site-search__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  border-top: var(--border-width-default) solid var(--color-border-default);
  background-color: var(--color-background-base-hovered);
}

.hc-site-search__footer-copy {
  margin: 0;
  font-size: var(--font-size-md);
  line-height: var(--line-height-md);
  color: var(--color-text-muted);
}

.hc-site-search__footer-hint {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  margin: 0;
  font-size: var(--font-size-md);
  color: var(--color-text-placeholder);
}

.hc-site-search__footer-hint-label {
  margin-right: var(--spacing-xs);
}

.hc-site-search__kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 22px;
  height: 22px;
  margin: 0;
  padding: 0 var(--spacing-xs);
  border: var(--border-width-default) solid var(--color-border-default);
  border-radius: var(--radius-rounded);
  background-color: var(--color-background-base-default);
  font: inherit;
  font-size: 12px;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
}

.hc-site-search__kbd:hover {
  color: var(--color-text-default);
  border-color: var(--color-text-muted);
}

.hc-site-search__kbd:focus-visible {
  outline: 2px solid var(--color-text-link);
  outline-offset: 2px;
}

.hc-search__count {
  flex-shrink: 0;
  margin-left: var(--spacing-sm);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-md);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.hc-search__count:empty {
  display: none;
}

/* Anchor overlay to the active search field's label wrapper */
.hc-search {
  position: relative;
}

.hc-search.is-hc-search-open {
  z-index: calc(var(--z-header) + 40);
}

/*
  The fixed scrim lives in a page-level stacking context above normal content.
  Open search hosts must rise above it, or the panel (moved into .hc-search) stays
  click-blocked even though it is visible under the dimmed layer.
*/
.hc-home-hero:has(.hc-search.is-hc-search-open),
.hc-breadcrumb-bar:has(.hc-search.is-hc-search-open) {
  position: relative;
  z-index: calc(var(--z-header) + 40);
}

.hc-header:has(.hc-search.is-hc-search-open) {
  z-index: calc(var(--z-header) + 40);
}

/* Hero clips the ellipse curve; allow the suggestion panel to paint outside while open. */
.hc-home-hero:has(.hc-search.is-hc-search-open) {
  overflow: visible;
}

/*
  Breadcrumb compact field is 280px and right-aligned. Grow the panel leftward
  so min width cannot spill past the viewport edge.
*/
.hc-breadcrumb-bar__search .hc-site-search__panel {
  left: auto;
  right: 0;
  width: min(360px, calc(100vw - (2 * var(--spacing-md))));
  min-width: 0;
  max-width: min(360px, calc(100vw - (2 * var(--spacing-md))));
}

.hc-home-hero__search .hc-site-search__panel {
  left: 0;
  right: 0;
}

@media (max-width: 768px) {
  .hc-site-search__panel {
    position: fixed;
    top: auto;
    left: var(--spacing-md);
    right: var(--spacing-md);
    bottom: var(--spacing-md);
    max-height: min(70vh, 520px);
    width: auto;
  }

  .hc-site-search__panel--expanded {
    max-height: min(80vh, 640px);
  }

  .hc-site-search__footer-hint {
    display: none;
  }

  .hc-breadcrumb-bar__search .hc-site-search__panel {
    min-width: 0;
  }
}
