/* ==========================================================================
   instantsearch-common.css
   Shared, theme-agnostic styles for the Algolia search widget.
   Contains layout/structure only - no color values.

   Requires a theme file loaded BEFORE this one to define these variables:
     --forest, --forest-dark, --sage, --navy, --marigold,
     --ink, --ink-soft, --line, --surface, --bg, --on-backdrop,
     --accent, --accent-soft, --radius
   See instantsearch-site.css for a working example.
   ========================================================================== */

* { box-sizing: border-box; }

/* Deliberately does NOT set font-family: the widget renders inside the host
   site's own page, and must inherit its typography rather than impose its
   own. The live modal never set one either. */
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

/* The host modal supplies its own heading and outer chrome, so the container
   only needs enough breathing room to separate the search box from the modal
   edge. */
.search-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 1rem 20px;
}

.search-page h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--forest);
  margin: 0 0 6px;
}

.search-page p.sub {
  color: var(--ink-soft);
  margin: 0 0 28px;
  font-size: 0.95rem;
}

/* Search box */
#searchbox .ais-SearchBox-form {
  position: relative;
}

#searchbox .ais-SearchBox-input {
  width: 100%;
  padding: 14px 46px 14px 44px;
  font-size: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#searchbox .ais-SearchBox-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

#searchbox .ais-SearchBox-submit,
#searchbox .ais-SearchBox-reset {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: none;
  cursor: pointer;
  color: var(--ink-soft);
  padding: 4px;
}

#searchbox .ais-SearchBox-submit { left: 12px; }
#searchbox .ais-SearchBox-reset { right: 12px; }
#searchbox .ais-SearchBox-submit svg,
#searchbox .ais-SearchBox-reset svg { width: 18px; height: 18px; fill: var(--navy); }

/* Stats */
/* Unlike every other element here, #stats sits directly on the host modal's
   dark backdrop rather than on a white card, so it needs the backdrop's
   contrast colour instead of the usual muted ink. */
#stats {
  margin: 14px 2px 0;
  font-size: 0.85rem;
  color: var(--on-backdrop);
}

/* Hits */
#hits {
  margin-top: 18px;
}

#hits .ais-Hits-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hit {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.hit:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.hit-icon {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* PDF badge background is intentionally NOT themed - a light amber tint
   reads as "PDF" universally, independent of any client's brand palette. */
.hit-icon.pdf {
  background: #fdf1de;
}

.hit-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.hit-body h3 {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

/* Section breadcrumb, e.g. "Wire Instructions" above an FAQ answer. Rendered
   only for records that carry a `section` attribute (the crawler emits one
   per FAQ question); absent on whole-page and PDF records. */
.hit-section {
  display: inline-block;
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sage);
}

.hit-body p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.4;
}

.hit-relevance {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.hit-relevance-track {
  flex: none;
  width: 90px;
  height: 5px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.hit-relevance-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--sage);
}

.hit-relevance-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--forest);
  white-space: nowrap;
}

.hit-relevance-reason {
  font-size: 0.72rem;
  color: var(--ink-soft);
  white-space: nowrap;
  padding-left: 8px;
  border-left: 1px solid var(--line);
}

.hit-body mark,
.hit-body em {
  background: none;
  color: var(--accent);
  font-style: normal;
  font-weight: 700;
  padding: 0;
}

/* Pagination */
#pagination {
  margin-top: 28px;
  display: flex;
  justify-content: center;
}

/* Host sites often style every <li> globally (custom bullets/markers).
   Reset aggressively so nothing bleeds into the pagination controls. */
#pagination ul,
#pagination li {
  all: unset;
  box-sizing: border-box;
}

#pagination li::before,
#pagination li::marker {
  content: none !important;
}

#pagination .ais-Pagination-list {
  list-style: none;
  display: flex;
  gap: 4px;
  padding: 0;
  margin: 0;
}

#pagination .ais-Pagination-item {
  display: block;
}

#pagination .ais-Pagination-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}

#pagination .ais-Pagination-link svg {
  width: 14px;
  height: 14px;
  display: block;
}

#pagination .ais-Pagination-item--selected .ais-Pagination-link {
  background: var(--forest);
  border-color: var(--forest);
  color: var(--surface);
}

#pagination .ais-Pagination-link:hover {
  border-color: var(--forest);
  color: var(--forest);
}

#pagination .ais-Pagination-item--disabled .ais-Pagination-link {
  opacity: 0.35;
  pointer-events: none;
}

/* Empty state */
.ais-Hits--empty .ais-Hits-list::after {
  content: "";
}

/* Like #stats, this sits directly on the host modal's dark backdrop rather
   than on a card, so it needs its own surface - dark ink on the dark ground
   was effectively invisible. Matching the hit cards keeps the empty state
   looking like part of the same list. */
#no-results {
  display: none;
  text-align: center;
  padding: 40px 20px;
  background: var(--surface);
  color: var(--ink-soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  margin-top: 18px;
}

#no-results strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
  font-size: 1rem;
}
