/* Help search box. Shared by the /help hub (hero) and every guide page (sidebar on desktop,
   a bar above the breadcrumb on phones).

   Hand-written. The markup is generated by scripts/build-help-site.mjs (searchBox()) and the
   behavior lives in scripts/website/help-search-client.mjs (built to js/help-search.js).
   It is NOT part of the generated help-articles.css, which a rebuild overwrites.

   Every color is a literal hex, on purpose: the site's custom properties hold rgb triplets,
   not colors (see the note in build-help-site.mjs buildHub). The values match the
   input style in trial-gate.css and the help hub's palette. */

/* Hidden until JavaScript is confirmed: every page sets .js-ready in <head> before first paint,
   so there is no layout jump, and a reader with scripts off never sees a dead control. */
.help-search { position: relative; display: none; font-family: 'Source Serif 4', Georgia, serif; }
.js-ready .help-search--hero,
.js-ready .help-search--side { display: block; }
.help-search--side { margin: 0 0 18px; padding-right: 8px; }
@media (max-width: 960px) {
  .js-ready .help-search--inline { display: block; margin: 0 0 24px; }
}

/* The hub's box is the centerpiece of the hero, and it sits ON the seam between the hero band and
   the "Start here" band instead of floating in the white above it. The negative bottom margin
   pulls the band's edge up to the box's vertical middle (band padding + half the 62px box), and
   the z-index lifts it over the next band, which paints later. */
.help-search--hero {
  max-width: 640px; margin: clamp(26px, 3.4vw, 38px) auto calc(-1 * (clamp(42px, 6vw, 80px) + 31px));
  text-align: left; z-index: 3;
}
/* The band under the box needs the half that overlaps it as extra headroom. */
.help-band:has(.help-search--hero) + .help-band { padding-top: calc(clamp(42px, 6vw, 80px) + 31px); }

/* Visually hidden, still read by screen readers. */
.help-search__label,
.help-search__status {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.help-search__field { position: relative; }
.help-search__icon {
  position: absolute; left: 13px; top: 50%; width: 16px; height: 16px;
  transform: translateY(-50%); color: #CD6E2C; pointer-events: none;
}
/* Warm card paper (the same #FCF8F0 as the hub's section cards), white once you start typing. */
.help-search__input {
  display: block; width: 100%; box-sizing: border-box; margin: 0;
  font-family: 'Source Serif 4', Georgia, serif; font-size: 16px; line-height: 1.3;
  padding: 11px 38px 11px 38px; color: #29241E; background: #FCF8F0;
  border: 1px solid #D9C6A5; border-radius: 0;
  transition: border-color .2s ease, box-shadow .2s ease;
  -webkit-appearance: none; appearance: none;
}
.help-search__input::placeholder { color: #8A7656; opacity: 1; }
.help-search__input::-webkit-search-cancel-button,
.help-search__input::-webkit-search-decoration { -webkit-appearance: none; display: none; }
.help-search__input:hover { border-color: #C9B79A; }
.help-search__input:focus {
  outline: none; background: #fff; border-color: #CD6E2C; box-shadow: 0 0 0 3px rgba(205, 110, 44, .22);
}
/* The hub's box is dressed like the headline above it: its display face (italic, to echo "and
   worldbuilders."), a larger size, and a soft lift off the seam. */
.help-search--hero .help-search__input {
  height: 62px; padding: 0 54px 0 58px;
  font-family: 'Newsreader', Georgia, serif; font-size: 21px;
  box-shadow: 0 10px 28px rgba(41, 36, 30, .10);
}
.help-search--hero .help-search__input::placeholder { font-style: italic; color: #8F7B5B; }
.help-search--hero .help-search__input:focus {
  box-shadow: 0 0 0 3px rgba(205, 110, 44, .22), 0 10px 28px rgba(41, 36, 30, .10);
}
.help-search--hero .help-search__icon { left: 21px; width: 20px; height: 20px; }
.help-search--hero .help-search__panel { top: calc(100% + 8px); }

.help-search__clear {
  position: absolute; right: 5px; top: 50%; width: 30px; height: 30px; margin: 0; padding: 0;
  transform: translateY(-50%); display: flex; align-items: center; justify-content: center;
  color: #7C5236; background: transparent; border: 0; border-radius: 0; cursor: pointer;
  transition: color .15s ease;
}
.help-search__clear[hidden] { display: none; }
.help-search__clear:hover { color: #CD6E2C; }
.help-search__clear:focus-visible { outline: 2px solid #CD6E2C; outline-offset: -2px; }
.help-search__clear svg { width: 12px; height: 12px; }
.help-search--hero .help-search__clear { right: 8px; }

/* Results. In the sidebar the panel is wider than the 240px column and opens over the article,
   the way the in-app Help does, so titles and snippets are not cut off. */
.help-search__panel {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; width: 100%;
  max-height: min(70vh, 460px); overflow-y: auto;
  background: #FCF8F0; border: 1px solid #E0D2BC; box-shadow: 0 12px 32px rgba(41, 36, 30, .14);
  animation: helpSearchIn .16s cubic-bezier(.2, .7, .2, 1) backwards;
}
.help-search__panel[hidden] { display: none; }
.help-search--side .help-search__panel { width: 460px; max-width: calc(100vw - 32px); }
.help-search--inline .help-search__panel { max-height: min(60vh, 420px); }
@keyframes helpSearchIn { from { opacity: 0; transform: translateY(-4px); } }

.help-search__result {
  display: block; padding: 11px 16px; color: inherit; text-decoration: none;
  border-bottom: 1px solid #EBDFCB;
}
.help-search__result:last-child { border-bottom: 0; }
.help-search__result[aria-selected="true"] { background: #F4EBD8; }
.help-search__title {
  display: block; font-size: 15px; font-weight: 600; line-height: 1.35; color: #29241E;
}
.help-search__result[aria-selected="true"] .help-search__title { color: #CD6E2C; }
.help-search__heading { display: block; margin-top: 1px; font-size: 13px; line-height: 1.4; color: #7C6A52; }
.help-search__snippet {
  display: -webkit-box; margin-top: 4px; font-size: 13.5px; line-height: 1.5; color: #5C4332;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.help-search__snippet mark { color: inherit; background: rgba(205, 110, 44, .2); padding: 0 1px; }
.help-search__empty { margin: 0; padding: 16px; font-size: 14.5px; line-height: 1.5; color: #5C4332; text-wrap: pretty; }

@media (prefers-reduced-motion: reduce) {
  .help-search__panel { animation: none; }
  .help-search__input, .help-search__clear { transition: none; }
}
/* !important is scoped to print: it has to beat the .js-ready display rules above, which are
   more specific than a plain .help-search selector. */
@media print { .help-search { display: none !important; } }
