/* EntityChip v0 (nexus-entity-chip.js): face, name, ":" and a mono
   sub-label, with one action menu. Tokens only, so a theme that redefines the
   tokens restyles the chip with no edit here. Every control is at least 32 px
   tall. */

.nx-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-width: 0;
  vertical-align: middle;
  color: var(--text-1);
  font-family: var(--font-body);
  font-size: 13px;
}

.nx-chip-main,
.nx-chip-static {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.nx-chip-static {
  cursor: default;
}
.nx-chip-main:hover .nx-chip-name {
  text-decoration: underline;
}
.nx-chip-main:hover,
.nx-chip[data-open] .nx-chip-main {
  border-color: var(--border-strong);
  background: var(--bg-2);
}

.nx-chip-face {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  background: var(--bg-3);
  color: var(--text-2);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
}
.nx-chip-face[data-shape="round"] {
  border-radius: var(--radius-full);
}
.nx-chip-face[data-shape="hex"] {
  border-radius: 0;
  clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0 50%);
}

.nx-chip-name {
  min-width: 0;
  overflow: hidden;
  color: var(--text-1);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nx-chip-sep {
  flex: none;
  color: var(--text-3);
}
/* On a narrow row the sub-label gives way first, then the name. */
.nx-chip-sub {
  flex: 0 1000 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--text-3);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* v0 (classic) keeps its mono sub-label; v1 speaks in the chip's body face. */
.nx-chip:not([data-v="1"]) .nx-chip-sub {
  font-family: var(--font-mono);
}

.nx-chip-status {
  flex: none;
  padding: 0 8px;
  border: 1px solid var(--chip-border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 11px;
}
.nx-chip-status[data-tone="ok"] {
  border-color: var(--status-ok);
  color: var(--status-ok);
}
.nx-chip-status[data-tone="warn"] {
  border-color: var(--status-warn);
  color: var(--status-warn);
}
.nx-chip-status[data-tone="bad"] {
  border-color: var(--status-bad);
  color: var(--status-bad);
}
.nx-chip-status[data-tone="neutral"] {
  color: var(--text-1);
}

.nx-chip-more {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-3);
  font: inherit;
  cursor: pointer;
}
.nx-chip-more:hover,
.nx-chip-more[aria-expanded="true"] {
  border-color: var(--border-strong);
  background: var(--bg-2);
  color: var(--text-1);
}

.nx-chip-live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The menu sits on the page, not in the chip, so a scrolling list cannot clip
   it. Hover mode is the slim pill; right-click, long-press and the keyboard
   get the same actions as a list. */
.nx-chip-menu {
  position: fixed;
  /* Above drawers (101) and top-bar menus (100), below toasts (200). */
  z-index: 150;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 160px;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-3);
  box-shadow: var(--shadow-menu);
}
.nx-chip-menu[data-mode="hover"] {
  flex-direction: row;
  min-width: 0;
}

.nx-chip-menu-item {
  display: flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-1);
  font: inherit;
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.nx-chip-menu-item:hover,
.nx-chip-menu-item:focus-visible {
  border-color: var(--border-strong);
  background: var(--bg-2);
}

/* ── EntityChip v1 (the Arkham shell): the name opens the record's Profile,
   the actions button shows on hover, on focus inside the chip, and always
   on touch and narrow screens. ── */
.nx-chip[data-v="1"] .nx-chip-more {
  opacity: 0;
}
.nx-chip[data-v="1"]:hover .nx-chip-more,
.nx-chip[data-v="1"]:focus-within .nx-chip-more,
.nx-chip[data-v="1"][data-open] .nx-chip-more {
  opacity: 1;
}
@media (pointer: coarse), (max-width: 760px) {
  .nx-chip[data-v="1"] .nx-chip-more {
    opacity: 1;
  }
}
.nx-chip[data-v="1"] .nx-chip-main:focus-visible,
.nx-chip[data-v="1"] .nx-chip-more:focus-visible,
[data-theme="arkham"] .nx-chip-menu-item:focus-visible,
.nx-cat-add-option:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}
.nx-chip-face[data-shape="pill"] {
  width: 28px;
  border-radius: var(--radius-full);
}
.nx-chip[data-loading] .nx-chip-name {
  color: var(--text-3);
}
.nx-chip[data-stamp="missing"] .nx-chip-name {
  color: var(--text-2);
}
/* A v1 badge speaks in the body face, since a mono label reads as code
   (Hallmark 64), and its spacing stays on the 4 px scale. */
.nx-chip-badge {
  flex: none;
  padding: 0 8px;
  border: 1px solid var(--chip-border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-family: var(--font-body);
  font-size: 11px;
  white-space: nowrap;
}
.nx-chip-menu-item[aria-disabled="true"] {
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  color: var(--text-3);
  cursor: default;
}
.nx-chip-menu-note {
  color: var(--text-3);
  font-size: 11px;
}

/* Add to category from a chip (nexus-category-add.js): the same menu look,
   under the chip's name. */
.nx-cat-add {
  position: fixed;
  z-index: 150;
  min-width: 200px;
  max-width: min(320px, calc(100vw - 16px));
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-3);
  box-shadow: var(--shadow-menu);
}
.nx-cat-add-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.nx-cat-add-note {
  margin: 0;
  padding: 6px 10px;
  color: var(--text-3);
  font-size: 12px;
}
.nx-cat-add-note[hidden] {
  display: none;
}
.nx-cat-add-option {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-1);
  font: inherit;
  font-size: 13px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.nx-cat-add-option:hover {
  border-color: var(--border-strong);
  background: var(--bg-2);
}

/* Rooms that name a record with a chip under Arkham (S5 section 3.4). */
.crm-name-chip {
  display: inline-flex;
  max-width: 100%;
  min-width: 0;
}
[data-theme="arkham"] .cmdk-open-profile {
  flex: none;
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
}
