/* HelpPalette organism - How do I: the search palette over the help index and the hotel's
   SOP stages (TLP-1136). Opens over a light dim from the tray button or the ? key; the
   screen behind stays visible. SPACING CONTRACT: the palette is fixed and carries no
   external margin; the results list owns its rhythm through gap. Every value from
   design-tokens.css; classes are prefixed help-palette-. The rows are the ItemRow
   molecule, scoped here for the icon tile, the selection and the action word. */

/* Stacking: with the Show me menu (9998), under modals and drawers (9999), toasts and a running guide (10000). */
.help-palette-dim {
  position: fixed;
  inset: 0;
  z-index: 9997;
  background: var(--help-dim-palette);
}

.help-palette {
  position: fixed;
  z-index: 9998;
  top: calc(var(--header-height) + var(--space-10));
  left: 50%;
  transform: translateX(-50%);
  width: 620px;
  max-width: calc(100vw - var(--space-8));
  max-height: calc(100vh - var(--header-height) - var(--space-16));
  background: var(--bg-surface);
  border: var(--border-width-1) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- the input row ---------- */
.help-palette-input {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-bottom: var(--border-width-1) solid var(--border-subtle);
}

.help-palette-input .search-input-wrapper {
  flex: 1;
  min-width: 0;
}

/* the atom's field, borderless inside the palette: the palette is the frame */
.help-palette-input .search-input,
.help-palette-input .search-input:focus {
  border-color: transparent;
  box-shadow: none;
  background-color: transparent;
  font-size: var(--text-md);
}

/* ---------- results ---------- */
.help-palette-results {
  overflow-y: auto;
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-px);
}

.help-palette-group {
  font-size: var(--text-2xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: var(--font-weight-semibold);
  color: var(--text-muted);
  padding: var(--space-2) var(--space-2) var(--space-1);
}

.help-palette-results .help-palette-row {
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.help-palette-results .help-palette-row:hover,
.help-palette-results .help-palette-row.is-selected {
  background: var(--color-primary-light);
}

.help-palette-results .help-palette-row:focus-visible {
  outline: var(--border-width-2) solid var(--color-primary);
  outline-offset: -2px;
}

/* two lines beside one tile: the molecule's row becomes a small grid */
.help-palette-row .item-row-content {
  display: grid;
  grid-template-columns: var(--space-8) minmax(0, 1fr);
  grid-template-areas: "icon label" "icon secondary";
  column-gap: var(--space-3);
  align-items: center;
}

.help-palette-row .item-row-content > .icon {
  grid-area: icon;
  width: var(--space-8);
  height: var(--space-8);
  border-radius: var(--radius-sm);
  background: var(--surface-sunk);
  display: grid;
  place-items: center;
  color: var(--text-body);
}

.help-palette-row .item-row-label {
  grid-area: label;
  font-weight: var(--font-weight-medium);
}

.help-palette-row .item-row-secondary {
  grid-area: secondary;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.help-palette-action {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  color: var(--color-primary-press);
  white-space: nowrap;
}

.help-palette-foot {
  padding: var(--space-2) var(--space-4) var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-muted);
  border-top: var(--border-width-1) solid var(--border-subtle);
  background: var(--bg-panel);
}

.help-palette .empty-state {
  padding: var(--space-6) var(--space-4);
}

/* Phone: the palette fills the width just under the top of the screen */
@media (max-width: 760px) {
  .help-palette {
    top: var(--space-4);
    left: var(--space-4);
    right: var(--space-4);
    width: auto;
    max-width: none;
    max-height: calc(100vh - var(--space-8));
    transform: none;
  }
}
