/*
  Search box, typeahead dropdown and results page for the manual.

  Loaded by both index.php (box + dropdown only) and search.php (which also uses
  the results-page rules further down). Colours follow docs/css/style.css: the
  brand green #5eba47 for links and focus, #60af39 for its hover.
*/

/* --- search box in the navbar --------------------------------------------- */

.docs-search {
  position: relative;   /* the dropdown is positioned against this */
  margin-left: auto;
  width: 100%;
  max-width: 420px;
}

.docs-search-field {
  display: flex;
  align-items: stretch;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.docs-search-field:focus-within {
  border-color: #5eba47;
  box-shadow: 0 0 0 3px rgba(94, 186, 71, 0.18);
}

#docs-search-input {
  flex: 1 1 auto;
  min-width: 0;   /* lets the input shrink inside the flex row instead of overflowing */
  border: 0;
  background: transparent;
  padding: 8px 10px;
  font-size: 15px;
  color: #333;
  border-radius: 4px 0 0 4px;
}

#docs-search-input:focus {
  outline: none;   /* the ring is drawn on the wrapper, so the whole control lights up */
}

#docs-search-input::placeholder {
  color: #999;
}

/* The browser's own clear button in a type=search field, which would sit on top
   of ours. */
#docs-search-input::-webkit-search-cancel-button {
  margin-right: 4px;
}

.docs-search-submit {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: #666666;
  padding: 0 10px;
  cursor: pointer;
  border-radius: 0 4px 4px 0;
}

.docs-search-submit:hover,
.docs-search-submit:focus {
  color: #60af39;
}

/* Announcements for screen readers only; the sighted reader has the dropdown. */
.docs-search-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- typeahead dropdown --------------------------------------------------- */

.docs-search-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 1050;   /* above the sticky document columns */
  max-height: min(70vh, 560px);
  overflow-y: auto;
  background: #fff;
  border: 1px solid #dddddd;
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  text-align: left;
}

.docs-search-panel[hidden] {
  display: none;   /* [hidden] alone loses to the display rules above */
}

.docs-search-group + .docs-search-group {
  border-top: 1px solid #E4E4E4;
}

.docs-search-group-label {
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #999;
}

.docs-search-option {
  display: block;
  padding: 8px 12px 10px;
  border-left: 3px solid transparent;
  text-decoration: none;
  color: #333;
}

.docs-search-option:hover,
.docs-search-option:focus,
.docs-search-option.is-active {
  background: #f3f9f0;
  border-left-color: #5eba47;
  text-decoration: none;
  color: #333;
}

.docs-search-option-title {
  display: block;
  color: #5eba47;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

.docs-search-option-path {
  display: block;
  margin-top: 1px;
  font-size: 11.5px;
  color: #999;
}

.docs-search-option-snippet {
  display: block;
  margin-top: 3px;
  font-size: 12.5px;
  line-height: 1.45;
  color: #666666;
}

.docs-search-none {
  padding: 14px 12px;
  font-size: 14px;
  color: #666666;
}

.docs-search-more {
  display: block;
  padding: 9px 12px;
  border-top: 1px solid #E4E4E4;
  background: #fafafa;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

/* The global "mark { background: yellow }" is too loud at this size; a tint plus
   weight reads as emphasis without turning a snippet into a highlighter test. */
.docs-search-option-snippet mark,
.search-result-snippet mark {
  background: #fff2a8;
  color: inherit;
  font-weight: 600;
  padding: 0 1px;
  border-radius: 2px;
}

/* --- results page --------------------------------------------------------- */

/* style.css pins the body to the viewport for the document view's independently
   scrolling columns; the results page is one ordinary scrolling document. */
body.search-page {
  height: auto;
  min-height: 100vh;
  background: #fff;
}

body.search-page .header {
  border-bottom: 1px solid #E4E4E4;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  padding: 0 20px;
}

.search-main {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.search-main #breadcrumbs {
  font-size: 12.5px;
  color: #999;
  margin-bottom: 18px;
}

.search-main h1 {
  font-size: 26px;
  margin: 0 0 6px;
}

.search-main h2 {
  font-size: 19px;
  margin: 0 0 4px;
}

.search-summary,
.search-hint,
.search-none,
.search-qa-note {
  color: #666666;
  font-size: 14px;
}

.search-summary {
  margin-bottom: 22px;
}

.search-hint code {
  background: #f3f3f3;
  padding: 1px 4px;
  border-radius: 3px;
}

.search-results {
  margin: 0;
  padding: 0;
  list-style: none;
}

.search-result {
  padding: 14px 0;
  border-top: 1px solid #E4E4E4;
}

.search-result-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
}

.search-result-path {
  margin-top: 2px;
  font-size: 12px;
  color: #999;
}

.search-result-snippet {
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.55;
  color: #444;
}

.search-result-meta {
  margin-top: 3px;
  font-size: 12px;
  color: #999;
}

.search-badge {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 6px;
  border-radius: 10px;
  background: #f3f3f3;
  color: #666666;
  font-size: 11px;
  font-weight: 600;
}

.search-accepted {
  margin-left: 6px;
  color: #5eba47;
  font-weight: 600;
}

.search-pager {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid #E4E4E4;
  font-size: 14px;
}

.search-pager-position {
  color: #999;
}

.search-qa {
  margin-top: 42px;
  padding-top: 18px;
  border-top: 2px solid #E4E4E4;
}

.search-qa-more {
  margin-top: 14px;
  font-size: 13px;
}

.search-qa-more a {
  margin-right: 10px;
}

/* --- narrow screens ------------------------------------------------------- */

@media (max-width: 767px) {
  .docs-search {
    max-width: none;
    margin: 8px 0 0;
  }

  /* The navbar collapses on mobile, so anchoring the panel to the box would
     leave it inside a container that is about to change height. Full width under
     the field is both simpler and easier to hit. */
  .docs-search-panel {
    max-height: 60vh;
  }

  body.search-page .header {
    height: auto;
    padding: 10px 16px;
  }
}
