/* What gets made, two views (src/pieces_view.rs; docs/decisions.md, 3 Nov 2026, "The shared pieces
   of choices…", (4)): an item's pieces and the order's pieces as the handoff's 12a to 12c draw them.
   A table where there is room; under 40rem of the width it is given, a block per item, one
   container query, so the view follows its column and not the window. */
.pieces-view {
  container-type: inline-size;
  display: grid;
  gap: var(--space-3);
  font-size: var(--text-quiet);
  color: var(--color-ink);
}

.pieces-title {
  display: flex;
  max-width: none;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  margin: 0;
  padding-bottom: var(--space-2);
  border-bottom: var(--rule-strong) solid var(--color-ink);
  font-size: var(--text-lead);
  font-weight: var(--weight-strong);
}

.pieces-title-head {
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  font-weight: var(--weight-regular);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.pieces-title-count {
  font-size: var(--text-quiet);
  font-weight: var(--weight-regular);
  color: var(--color-meta);
}

.pieces-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.pieces-table th,
.pieces-table td {
  padding: var(--space-1) var(--space-2) var(--space-1) 0;
  text-align: left;
  font-weight: var(--weight-regular);
  vertical-align: middle;
}

.pieces-table thead th,
.pieces-table thead td {
  padding-bottom: var(--space-1);
  border-bottom: var(--rule-strong) solid var(--color-ink);
  font-size: var(--text-meta);
  font-weight: var(--weight-strong);
  color: var(--color-meta);
  white-space: nowrap;
}

.pieces-choice-head {
  min-width: var(--pieces-choice-least);
}

.pieces-table .pieces-count {
  width: var(--pieces-size-column);
  padding-right: 0;
  text-align: center;
}

.pieces-table .pieces-total {
  width: var(--pieces-total-column);
  font-weight: var(--weight-strong);
  color: var(--color-ink);
}

.pieces-row td,
.pieces-row th {
  border-top: var(--hairline) solid var(--color-line-panel);
}

.pieces-row.pieces-group-start td,
.pieces-row.pieces-group-start th {
  border-top-color: var(--color-line-later);
}

.pieces-to-come,
.pieces-muted,
.pieces-off {
  color: var(--color-muted);
}

.pieces-row.pieces-to-come td,
.pieces-combination.pieces-to-come td,
.pieces-name-row.pieces-to-come td {
  border-top-style: dashed;
  border-top-color: var(--color-line-later);
}

.pieces-value .tile-named {
  max-width: 100%;
}

.pieces-row td:first-child .tile-name {
  font-weight: var(--weight-strong);
}

.pieces-all th,
.pieces-all td {
  padding-top: var(--space-2);
  border-top: var(--rule-strong) solid var(--color-ink);
  font-weight: var(--weight-strong);
}

/* The order's pieces: an item's row bold with its note, its combinations indented beneath. */
.pieces-number {
  width: var(--pieces-number-column);
  color: var(--color-meta);
}

.pieces-item th,
.pieces-item td {
  padding-top: var(--space-2);
  border-top: var(--hairline) solid var(--color-line-later);
  font-weight: var(--weight-strong);
}

.pieces-item .pieces-number {
  font-weight: var(--weight-regular);
}

.pieces-item-note {
  margin-left: var(--space-2);
  font-size: var(--text-meta);
  font-weight: var(--weight-regular);
  color: var(--color-meta);
}

/* **A warning under an item's name** (HQ's roster, where an item is short of its minimum): the needs
   list's warning mark, the flag's soft yellow in its rim, before the words; on a line of its own. */
.pieces-item-warn {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-meta);
  font-weight: var(--weight-regular);
  color: var(--color-ink);
}

.pieces-warn-mark {
  display: inline-grid;
  place-items: center;
  box-sizing: border-box;
  width: var(--need-mark);
  height: var(--need-mark);
  border: var(--hairline) solid var(--color-flag-rule);
  border-radius: 50%;
  background: var(--color-flag);
  color: var(--color-flag-ink);
  font-family: var(--font-mono);
  font-size: var(--text-mono-sm);
  font-weight: var(--weight-strong);
  line-height: 1;
}

.pieces-combination td {
  padding-top: var(--hairline);
  padding-bottom: var(--hairline);
  border-top: var(--hairline) solid var(--color-line-panel);
}

.pieces-combination-values {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  padding-left: var(--space-4);
}

/* The names, beneath an item's pieces. */
.pieces-names {
  display: grid;
  gap: var(--space-2);
  padding-top: var(--space-3);
}

.pieces-names-head {
  max-width: none;
  margin: 0;
  font-weight: var(--weight-strong);
}

.pieces-name-row td {
  border-top: var(--hairline) solid var(--color-line);
}

.pieces-name-row .pieces-count {
  text-align: left;
}

.pieces-typed {
  font-weight: var(--weight-strong);
}

/* ---- at a phone's width: a block per item, a line per combination ---- */
.pieces-narrow {
  display: none;
}

.pieces-block {
  display: grid;
  gap: var(--space-1);
  padding-bottom: var(--space-2);
  border-bottom: var(--hairline) solid var(--color-line);
}

.pieces-block-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: var(--text-control);
  font-weight: var(--weight-strong);
}

.pieces-block .pieces-item-note {
  margin-left: 0;
}

.pieces-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: var(--space-2);
  padding-left: var(--hairline);
}

.pieces-line-values {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
}

.pieces-line-total {
  font-weight: var(--weight-strong);
  font-variant-numeric: tabular-nums;
}

.pieces-line-sizes {
  grid-column: 1 / -1;
  padding-left: calc(var(--tile-table) + var(--space-1));
  font-family: var(--font-mono);
  font-size: var(--text-mono-number-sm);
  color: var(--color-meta);
}

/* A named row's values on its second line: tiles and names in the body's face, not the sizes' mono. */
.pieces-line-also {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--text-meta);
}

.pieces-name-count {
  font-variant-numeric: tabular-nums;
}

.pieces-name-typed {
  font-weight: var(--weight-strong);
}

@container (max-width: 40rem) {
  .pieces-wide {
    display: none;
  }

  .pieces-narrow {
    display: grid;
    gap: var(--space-2);
  }
}
