/* palette: a command palette. Colours, size and the corner radius are custom properties on .pl; the dialog's
   backdrop and stacking are on .pl-overlay. */

.pl {
  --pl-surface: #ffffff;
  --pl-text: #121212;
  --pl-muted: #66676b;
  --pl-edge: rgb(18 18 18 / 0.08);
  --pl-active: rgb(18 18 18 / 0.06);
  --pl-kbd: rgb(18 18 18 / 0.06);
  --pl-done: #0a7d4f;
  --pl-radius: 10px;
  --pl-width: 640px;
  --pl-height: 460px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  color: var(--pl-text);
  font-size: 15px;
}

.pl-search {
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 10px 0 16px;
  box-shadow: inset 0 -1px 0 var(--pl-edge);
}
.pl-search-icon { flex: none; width: 19px; height: 19px; fill: none; stroke: var(--pl-muted); stroke-width: 1.7; stroke-linecap: round; }
.pl-input {
  flex: 1;
  min-width: 0;
  height: 54px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--pl-text);
  font: inherit;
  /* 16px or more, so a phone does not zoom in when the field takes focus. */
  font-size: 16px;
  caret-color: var(--pl-text);
  outline: none;
}
.pl-input::placeholder { color: var(--pl-muted); }
/* The field is the only thing that ever has focus here; a ring around it would only add noise. Stated twice as
   strongly as a page's own focus rule, so that rule does not draw one anyway. */
.pl .pl-input:focus,
.pl .pl-input:focus-visible { outline: none; }
/* Close: a cross only. */
.pl-esc {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: var(--pl-kbd);
  color: var(--pl-muted);
  cursor: pointer;
  transition: color 160ms ease, background-color 160ms ease;
}
.pl-esc::after { content: ""; position: absolute; inset: -7px; }
.pl-esc:hover { color: var(--pl-text); }
.pl-esc:focus-visible { outline: 2px solid var(--pl-text); outline-offset: 2px; }
.pl-esc svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.pl-list {
  flex: 1;
  min-height: 0;
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding: 6px;
}
.pl-list[hidden] { display: none; }
.pl-group + .pl-group { margin-top: 6px; }
.pl-heading { padding: 8px 10px 4px; color: var(--pl-muted); font-size: 12.5px; font-weight: 600; }

.pl-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
/* The highlight moves at once: a palette is used often and fast, and a sliding highlight would trail the keys. */
.pl-item[data-active] { background: var(--pl-active); }
.pl-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 28px;
  height: 28px;
  overflow: hidden;
  border-radius: 6px;
  color: var(--pl-muted);
  object-fit: cover;
}
img.pl-icon { outline: 1px solid rgb(0 0 0 / 0.08); outline-offset: -1px; }
.pl-icon svg { width: 18px; height: 18px; }
.pl-text { display: flex; flex: 1; align-items: baseline; gap: 10px; min-width: 0; }
.pl-label { flex: none; max-width: 100%; overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.pl-label mark { background: none; color: inherit; font-weight: 700; }
.pl-hint { min-width: 0; overflow: hidden; color: var(--pl-muted); font-size: 13.5px; text-overflow: ellipsis; white-space: nowrap; }
.pl-keys { display: flex; flex: none; gap: 4px; }
.pl kbd {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  padding: 0 6px;
  border-radius: 5px;
  background: var(--pl-kbd);
  color: var(--pl-muted);
  font: 500 11.5px/1 ui-monospace, "SF Mono", Menlo, monospace;
}
.pl-out,
.pl-done { flex: none; width: 16px; height: 16px; fill: none; stroke: var(--pl-muted); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.pl-item[data-done] .pl-hint { color: var(--pl-done); }
.pl-done { stroke: var(--pl-done); }

.pl-empty { margin: 0; padding: 28px 16px 32px; color: var(--pl-muted); text-align: center; text-wrap: balance; }
.pl-empty[hidden] { display: none; }

.pl-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* The dialog, when the page does not place the palette itself. It opens and closes at once: it is reached for by
   keyboard, many times a day, and anything that delays the field would be felt. */
.pl-overlay {
  --pl-backdrop: rgb(10 10 12 / 0.32);
  --pl-z: 1000;
  position: fixed;
  inset: 0;
  z-index: var(--pl-z);
  display: flex;
  justify-content: center;
  padding: max(12vh, 16px) 16px 16px;
}
.pl-overlay[hidden] { display: none; }
.pl-backdrop { position: absolute; inset: 0; background: var(--pl-backdrop); }
.pl-overlay .pl {
  position: relative;
  width: min(var(--pl-width), 100%);
  height: fit-content;
  max-height: min(var(--pl-height), 100%);
  overflow: hidden;
  border-radius: var(--pl-radius);
  background: var(--pl-surface);
  box-shadow: 0 0 0 1px rgb(18 18 18 / 0.06), 0 2px 6px rgb(0 0 0 / 0.06), 0 30px 70px -20px rgb(0 0 0 / 0.45);
}
@media (max-width: 640px) {
  .pl-overlay { padding: max(10px, env(safe-area-inset-top)) 10px 10px; }
}
