/* The header search box and its results (core). Sizes are The System's. */

.search {
  position: relative;
  flex: 1 1 180px;
  min-width: 0;
  max-width: 320px;
}

.search-in {
  box-sizing: border-box;
  width: 100%;
  height: 28px;
  padding: 0 64px 0 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  outline: none;
  background: var(--sheet);
  color: var(--fg);
  font: 400 12px var(--font-ui);
}

.search-in:focus { border-color: var(--accent); }
.search-in::placeholder { color: var(--muted); }
.search-in:disabled { opacity: .5; }
/* once the hint hides, the space comes back so the clear (×) sits at the right edge */
.search-in:focus,
.search-in:not(:placeholder-shown) { padding-right: 8px; }

.search .kbd {
  position: absolute;
  top: 0;
  right: 10px;
  height: 28px;
  color: var(--muted);
  font-size: 11px;
  line-height: 28px;
  pointer-events: none;
}

.search-in:focus ~ .kbd,
.search-in:not(:placeholder-shown) ~ .kbd { display: none; }

.search-results {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  min-width: min(240px, 90vw);
  max-height: 50vh;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--tedge);
  border-radius: 2px;
  background: var(--sheet);
  box-shadow: 0 6px 18px rgb(0 0 0 / .18);
}

.search-results[hidden] { display: none; }

.search-results .res {
  display: block;
  width: 100%;
  padding: 6px 8px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--fg);
  font: 400 12px/1.5 var(--font-ui);
  text-align: left;
  cursor: pointer;
}

.search-results .res[aria-selected="true"] { background: var(--sel-bg); box-shadow: inset 2px 0 0 var(--accent); }
.search-results .where { display: block; color: var(--accent); font-size: 11px; }
.search-results .snip { display: block; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.search-results mark { background: var(--accent-soft); color: var(--fg); }
.search-results .none { padding: 6px 8px; color: var(--muted); font-size: 12px; line-height: normal; }

@media (hover: hover) {
  .search-results .res:hover { background: var(--sel-bg); box-shadow: inset 2px 0 0 var(--accent); }
}

@media (hover: none) and (pointer: coarse) {
  .search .kbd { display: none; }
}

/* the result count, read out by screen readers only */
.search-said { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* phones: no "⌘ + L" hint, so no room kept for it */
@media (max-width: 700px), (hover: none) and (pointer: coarse) {
  .app-header .search-in:not(:focus) { padding-right: 10px; }
}
