/* HelpTray organism - the help control in the top bar and the Show me menu (TLP-1132).
   SPACING CONTRACT: the tray sits in .nav-right, which owns the gap; the tray carries no
   external margin. The menu is fixed and positioned by the controller through two custom
   properties. Every value from design-tokens.css; classes are prefixed help-. */

.help-tray {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--surface-sunk);
  border-radius: var(--radius-md);
  padding: var(--space-1);
}

.help-tray-item {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.help-tray .help-tray-btn {
  border-color: transparent;
  background: transparent;
  color: var(--text-body);
  gap: var(--space-2);
}

.help-tray .help-tray-btn:hover {
  background: var(--bg-surface-hover);
}

.help-tray .help-tray-btn.is-open {
  background: var(--bg-surface);
  color: var(--color-primary-press);
  box-shadow: var(--shadow-sm);
}

/* The search button is always white; when open it takes an inset ring instead */
.help-tray .help-tray-search {
  background: var(--bg-surface);
  color: var(--text-muted);
  font-weight: var(--font-weight-normal);
  justify-content: flex-start;
  width: 204px;
}

.help-tray .help-tray-search.is-open {
  box-shadow: inset 0 0 0 var(--border-width-2) var(--color-primary);
}

/* the key hint sits inside the search button's right edge */
.help-tray-item--search .kbd-group {
  position: absolute;
  right: var(--space-2);
  pointer-events: none;
}

.help-tray .help-tray-search {
  padding-right: var(--space-9);
}

.help-tray-count {
  margin-left: calc(-1 * var(--space-1));
}

.help-tray-pill {
  margin-left: calc(-1 * var(--space-1));
  font-variant-numeric: tabular-nums;
}

.nav-divider {
  width: var(--border-width-1);
  height: var(--space-5);
  background: var(--border-subtle);
}

/* ---------- Show me menu ---------- */
.help-menu {
  position: fixed;
  top: var(--help-menu-top, var(--header-height));
  left: var(--help-menu-left, auto);
  z-index: 9998;
  width: 372px;
  max-width: calc(100vw - var(--space-8));
  background: var(--bg-surface);
  border: var(--border-width-1) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.help-menu-group {
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-px);
}

.help-menu-group + .help-menu-group {
  border-top: var(--border-width-1) solid var(--border-subtle);
}

.help-menu-label {
  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-menu-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  text-align: left;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  background: transparent;
  border: 0;
  color: var(--text-body);
  font: inherit;
  cursor: pointer;
}

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

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

.help-menu-icon {
  width: var(--space-8);
  height: var(--space-8);
  border-radius: var(--radius-sm);
  background: var(--surface-sunk);
  display: grid;
  place-items: center;
  flex: none;
  color: var(--text-body);
}

.help-menu-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-px);
  min-width: 0;
}

.help-menu-title {
  font-weight: var(--font-weight-medium);
}

.help-menu-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.help-menu-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-menu .empty-state {
  padding: var(--space-4);
}

/* Phone: icons only, labels stay as accessible names; the menu spans the width */
@media (max-width: 760px) {
  .help-tray .help-tray-btn .btn-text,
  .help-tray .help-tray-search .btn-text,
  .help-tray-search .kbd-group {
    display: none;
  }
  .help-tray .help-tray-search {
    width: auto;
    justify-content: center;
  }
  .help-menu {
    left: var(--space-4);
    right: var(--space-4);
    width: auto;
  }
}
