/* 53_names.css - KP Equipment editor release, design row F7: the "Also called" section in a machine's record.
 * Styles the DOM that 53_names_ui.js builds inside section.drawer-names (#d-names-sec). No logic lives here.
 * Colours come from 01_tokens.css only, so light and dark follow the theme. The section title keeps the record's own
 * ".drawer h3" look. The search rows (.result-also, .result-more) are not styled here: they belong to the search list.
 * Owner: Fable (wave 5, F7). */

.drawer-names { --names-act-w: 5.5rem; container-type: inline-size; }

/* ---- the list: one name per row, its department beside it ---- */
.names-list { list-style: none; margin: 0; padding: 0; }
.names-row { box-sizing: border-box; display: flex; flex-wrap: wrap; align-items: center; align-content: center; gap: 4px var(--sp-2); min-height: 52px; padding: 4px 0; }
.names-row + .names-row { border-top: 1px solid var(--line); }
.names-name { min-width: 0; color: var(--ink); font-size: 16px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.names-dept { flex: 0 1 auto; min-width: 0; padding: 1px var(--sp-2); border: 1px solid var(--line); border-radius: 11px; background: var(--surface-alt); color: var(--ink-soft); font-size: 13px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.names-empty { margin: 0; color: var(--ink-muted); font-size: 15px; line-height: 1.4; }

/* ---- draft marks: "Not saved yet" and "Removed when you save" (words carry the meaning, colour only supports it) ---- */
.names-tag { flex: 0 1 auto; min-width: 0; padding: 1px var(--sp-2); border: 1px solid transparent; border-radius: var(--r-sm); color: var(--ink); font-size: 13px; font-weight: 600; line-height: 1.4; }
.names-tag.is-pending { border-color: var(--info); background: var(--info-bg); }
.names-tag.is-removed { border-color: var(--warning-fg); background: var(--warning-bg); }
.names-row.is-removed .names-name { color: var(--ink-muted); font-weight: 500; text-decoration: line-through; }
.names-row.is-removed .names-dept { background: transparent; color: var(--ink-muted); }

/* ---- buttons (44 px touch targets everywhere) ---- */
.names-remove, .names-undo, .names-add-btn, .names-clash-add, .names-clash-cancel {
  box-sizing: border-box; min-width: 44px; min-height: 44px; margin: 0; padding: 0 var(--sp-3);
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 15px; font-weight: 600; line-height: 1.2; cursor: pointer; touch-action: manipulation;
}
.names-remove:active, .names-undo:active, .names-clash-add:active, .names-clash-cancel:active { background: var(--brand-soft); }
.names-undo:disabled { border-style: dashed; background: var(--surface-alt); color: var(--ink-muted); cursor: not-allowed; }

/* the row's button sits in its own column on the right; the words wrap beside it, never under it */
.names-row > button { flex: none; margin-left: auto; }
@supports selector(:has(*)) {
  .names-row:has(> button) { position: relative; padding-right: calc(var(--names-act-w) + var(--sp-2)); }
  .names-row:has(> button) > button { position: absolute; top: 0; bottom: 0; right: 0; width: var(--names-act-w); height: 44px; margin: auto 0; padding: 0 var(--sp-1); }
}

/* ---- add row: Name on its own line, Department and the button under it ---- */
.names-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: var(--sp-2); margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--line); }
.names-label { display: flex; flex-direction: column; gap: 4px; min-width: 0; color: var(--ink-soft); font-size: 13px; font-weight: 600; line-height: 1.3; }
.names-label:first-child { grid-column: 1 / -1; }
.names-field, .names-dept-field {
  box-sizing: border-box; width: 100%; min-width: 0; min-height: 44px; margin: 0; padding: 0 var(--sp-3);
  border: 1px solid var(--ink-muted); border-radius: var(--r-sm); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 16px; font-weight: 400; line-height: 1.3;
}
.names-add-btn { padding: 0 var(--sp-4); border-color: var(--brand-solid); background: var(--brand-solid); color: var(--acc-ink); white-space: nowrap; }
.names-add-btn:active { border-color: var(--brand-solid-hover); background: var(--brand-solid-hover); }

/* ---- messages ---- */
.names-refusal { margin: var(--sp-2) 0 0; color: var(--danger-fg); font-size: 14px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.names-clash { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); padding: var(--sp-3); border: 1px solid var(--warning-fg); border-radius: var(--r-sm); background: var(--warning-bg); }
.names-clash-text { flex: 0 0 100%; min-width: 0; margin: 0 0 var(--sp-1); color: var(--ink); font-size: 15px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.names-clash-add, .names-clash-cancel { flex: 1 1 0; min-width: 7rem; max-width: 14rem; border-color: var(--ink-muted); white-space: nowrap; }

/* ---- keyboard focus: a solid ring in both themes (the page default ring is too faint on these controls) ---- */
.drawer-names button:focus-visible, .drawer-names input:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; box-shadow: none; }
.drawer-names input:focus-visible { border-color: var(--brand); }

/* ---- pointer hover, never on touch ---- */
@media (hover: hover) {
  .names-remove:hover, .names-undo:not(:disabled):hover, .names-clash-add:hover, .names-clash-cancel:hover { background: var(--surface-alt); }
  .names-add-btn:hover { border-color: var(--brand-solid-hover); background: var(--brand-solid-hover); }
}

/* ==== F11 (wave 5): looks for the hooks 53_names_ui.js gained after F7 (S5-HOOKS 1-6). Tokens from 01_tokens.css only. ==== */

/* 1. a blocked Undo says why, in words, on its own line under the name (a title never shows on touch) */
.names-hint { flex: 0 0 100%; min-width: 0; color: var(--ink-soft); font-size: 13px; font-weight: 500; line-height: 1.4; overflow-wrap: anywhere; }

/* 2. while the same-name notice is open the choice sits in the notice, so Add name steps back to an outline.
 *    It is still a real, enabled button: same size, same place, same words. */
.names-add.is-clash .names-add-btn { border-color: var(--brand); background: var(--surface); color: var(--brand); }
.names-add.is-clash .names-add-btn:active { border-color: var(--brand-hover); background: var(--brand-soft); color: var(--brand-hover); }
@media (hover: hover) {
  .names-add.is-clash .names-add-btn:hover { border-color: var(--brand-hover); background: var(--brand-soft); color: var(--brand-hover); }
}

/* 3. a new machine that is not saved yet: a quiet note where the add row would be */
.names-lock { margin: var(--sp-3) 0 0; padding: var(--sp-2) var(--sp-3); border-left: 3px solid var(--info); border-radius: var(--r-sm); background: var(--surface-alt); color: var(--ink); font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }

/* 4. a refused name: the field takes a doubled red edge (thicker, not only redder) and keeps it while focused;
 *    the focus ring still draws outside it. The words under the row (.names-refusal) say what went wrong. */
.drawer-names .names-field[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }

/* 5. the same-name notice: the machine code in the code face, the reason on a quieter second line close under it */
.names-clash-id { font-family: var(--mono); font-weight: 700; white-space: nowrap; }
.names-clash-sub { flex: 0 0 100%; min-width: 0; margin: calc(2px - var(--sp-2) - var(--sp-1)) 0 var(--sp-1); color: var(--ink-soft); font-size: 14px; font-weight: 400; line-height: 1.4; overflow-wrap: anywhere; }

/* 6. the department label now starts with a read-aloud "used by " (.visually-hidden, which is position: absolute).
 *    The label is its box, so the hidden words can never stray outside the record and widen the page. */
.names-dept { position: relative; }

/* ---- a wide record (the bottom sheet on a small tablet or a phone on its side): the add row fits on one line ---- */
@container (min-width: 520px) {
  .names-add { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) auto; }
  .names-label:first-child { grid-column: auto; }
}
