/* Project › Traceability (explorer) and the traceability card of the project overview. */

.trace-explorer {
  display: flex;
  flex-direction: column;
  gap: var(--scs-space-4);
  min-width: 0;
  padding: var(--scs-space-4) var(--scs-space-5);
}

/* Wide tables scroll inside their card; the page itself never scrolls sideways. */
.trace-explorer > *,
.explorer-cards > * {
  min-width: 0;
}

/* Views as a segmented control, page links on the right */
.explorer-views {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

html:root .explorer-views [data-explorer-view] {
  min-height: var(--scs-control-h-s);
  padding: 4px 14px;
  border: 1px solid var(--scs-line);
  border-radius: var(--scs-radius-m);
  background: var(--scs-surface);
  color: var(--scs-ink-2);
  font-size: var(--scs-text-s);
  font-weight: 600;
  box-shadow: none;
}

html:root .explorer-views [data-explorer-view][aria-pressed='true'] {
  border-color: var(--scs-accent);
  background: var(--scs-accent-soft);
  color: var(--scs-ink);
  box-shadow: inset 0 0 0 1px var(--scs-accent);
}

.explorer-views-spacer {
  flex: 1;
}

.explorer-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--scs-space-3);
}

.explorer-search {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--scs-space-2);
}

html:root .explorer-search input[type='search'] {
  width: 260px;
  min-height: var(--scs-control-h-s);
  height: var(--scs-control-h-s);
}

/* List left, the chosen object's cards right */
.explorer-body {
  display: grid;
  grid-template-columns: minmax(440px, 1fr) minmax(0, 1fr);
  gap: var(--scs-space-4);
  align-items: start;
}

.explorer-list {
  position: sticky;
  top: var(--scs-space-3);
}

.explorer-list .object-table-scroll {
  max-height: calc(100vh - 300px);
  min-height: 240px;
  overflow: auto;
}

.explorer-table {
  table-layout: fixed;
}

.explorer-table th:nth-child(2) {
  width: 130px;
}

.explorer-id {
  display: block;
  overflow: hidden;
  color: var(--scs-ink-2);
  font-family: var(--scs-font-mono);
  font-size: var(--scs-text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.explorer-table th:nth-child(3) {
  width: 110px;
}

.explorer-table th:nth-child(4) {
  width: 84px;
}

.explorer-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.explorer-table tbody tr {
  cursor: pointer;
}

.explorer-table tbody tr:hover td {
  background: var(--scs-surface-2);
}

.explorer-table tbody tr[aria-selected='true'] td {
  background: var(--scs-accent-soft);
}

.explorer-table tbody tr[aria-selected='true'] td:first-child {
  box-shadow: inset 3px 0 0 var(--scs-accent);
}

.explorer-table tbody tr:focus-visible {
  outline: 2px solid var(--scs-focus);
  outline-offset: -2px;
}

.explorer-name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.explorer-name > svg,
.explorer-name > .navigation-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.explorer-name > span {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.explorer-name strong {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.explorer-name small {
  color: var(--scs-ink-3);
  font-size: var(--scs-text-xs);
}

.explorer-number {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.explorer-empty {
  padding: var(--scs-space-4);
}

/* Object head over the cards, as on the object page */
.explorer-detail {
  display: flex;
  flex-direction: column;
  gap: var(--scs-space-4);
  min-width: 0;
  container-type: inline-size;
}

.explorer-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--scs-space-3);
  padding: var(--scs-space-3) var(--scs-space-4);
  border: 1px solid var(--scs-line);
  border-radius: var(--scs-radius-l);
  background: var(--scs-surface);
}

.explorer-head > svg,
.explorer-head > .navigation-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.explorer-head > div:first-of-type {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  min-width: 0;
}

.explorer-head small {
  flex-basis: 100%;
  color: var(--scs-ink-3);
  font-size: var(--scs-text-s);
}

.explorer-head h2 {
  margin: 0;
  font-size: var(--scs-text-l);
}

.explorer-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--scs-space-2);
}

.explorer-cards {
  display: flex;
  flex-direction: column;
  gap: var(--scs-space-4);
}

#explorer-realization > .model-mapping {
  padding: 0;
}

@media (max-width: 1100px) {
  .explorer-body {
    grid-template-columns: 1fr;
  }

  .explorer-list {
    position: static;
  }

  .explorer-list .object-table-scroll {
    max-height: 420px;
  }
}

/* Project overview: figures like the impact summary, a coverage bar and the most used roles */
.overview-trace-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--scs-space-2);
}

.overview-trace-figures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--scs-space-2);
}

html:root .overview-trace-figure {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--scs-line);
  border-radius: var(--scs-radius-m);
  background: var(--scs-surface);
  color: var(--scs-ink-2);
  font-size: var(--scs-text-s);
  text-align: left;
  white-space: normal;
  box-shadow: none;
}

html:root .overview-trace-figure:hover {
  border-color: var(--scs-accent-line);
  background: var(--scs-accent-soft);
}

.overview-trace-figure strong {
  color: var(--scs-ink);
  font-size: var(--scs-text-xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.overview-trace-figure.tone-gap strong {
  color: var(--scs-danger);
}

.overview-trace-figure.tone-warn strong {
  color: var(--scs-warn);
}

.overview-trace-bar {
  height: 8px;
  margin: var(--scs-space-3) 0;
  overflow: hidden;
  border-radius: 999px;
  background: var(--scs-surface-3);
}

.overview-trace-bar span {
  display: block;
  height: 100%;
  background: var(--scs-ok);
}

.overview-trace h3 {
  margin: var(--scs-space-3) 0 var(--scs-space-2);
  color: var(--scs-ink-3);
  font-size: var(--scs-text-s);
  font-weight: 600;
}

.overview-trace-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.overview-trace-roles li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.overview-trace-roles strong {
  color: var(--scs-ink-2);
  font-size: var(--scs-text-s);
  font-variant-numeric: tabular-nums;
}

/* Traceability pane next to the diagram: the row's model object with its cards */
.editor-trace-object {
  display: flex;
  flex-direction: column;
  gap: var(--scs-space-3);
  padding: var(--scs-space-3);
  container-type: inline-size;
}

.editor-trace-kind {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--scs-ink-3);
  font-size: var(--scs-text-s);
}

.editor-trace-kind > svg,
.editor-trace-kind > .navigation-icon {
  width: 18px;
  height: 18px;
}

.editor-trace-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--scs-space-2);
}

/* Hidden column captions are positioned; they must stay inside the scrolling table. */
.trace-explorer .object-table-scroll,
.editor-trace-object .object-table-scroll {
  position: relative;
}
