/* detail_list: a record's facts as label and value pairs, labels in one
   column and values beside them. In a narrow container each label sits above
   its value. */
.block_detail_list {
  --block-detail-label-width: max-content;

  display: grid;
  grid-template-columns: var(--block-detail-label-width) minmax(0, 1fr);
  gap: var(--ui-space-2) var(--ui-space-6);
  margin: 0 0 var(--ui-section-gap);
  font-size: var(--ui-font-size-body);
  line-height: var(--ui-line-height-body);
}

/* The #main copies outrank the legacy "#main dl" padding and its floated
   152px dt (user_interface/screens_shared). Those rules would indent the
   list inside its surface and widen its label column. */
#main .block_detail_list {
  padding: 0;
}

#main .block_detail_list > dt {
  float: none;
  width: auto;
}

.block_detail_list > :is(dt, dd),
#main .block_detail_list > :is(dt, dd) {
  padding: 0;
}

.block_detail_list > dt {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: var(--ui-font-size-label);
}

.block_detail_list > dd {
  margin: 0;
  color: var(--color-text);
  overflow-wrap: anywhere;
}

@container (width < 480px) {
  .block_detail_list {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 0;
  }

  .block_detail_list > dd + dt {
    margin-block-start: var(--ui-space-2);
  }
}

/* layout: :totals, a receipt's sums, at the end of the container. The
   amounts line up on their last digit. The grand total (the last pair) is
   strong, over a rule that runs under both columns. The rule is inset like a
   table cell, so the amounts line up under the table's. The two columns stay
   side by side at every width. The #main copies outrank the legacy
   "#main dl dt/dd" padding, as above. */
.block_detail_list[data-layout='totals'] {
  grid-template-columns: max-content max-content;
  justify-content: end;
  column-gap: 0;
  row-gap: var(--ui-space-2);
  margin: var(--ui-space-4) 0 0;
  padding-inline-end: var(--ui-table-cell-inline);
  font-variant-numeric: tabular-nums;
}

.block_detail_list[data-layout='totals'] > dd,
#main .block_detail_list[data-layout='totals'] > dd {
  padding-inline-start: var(--ui-space-8);
  text-align: end;
  white-space: nowrap;
}

.block_detail_list[data-layout='totals'] > dd + dt {
  margin-block-start: 0;
}

.block_detail_list[data-layout='totals'] > :is(dt, dd):nth-last-child(-n + 2),
#main .block_detail_list[data-layout='totals'] > :is(dt, dd):nth-last-child(-n + 2) {
  padding-block-start: var(--ui-space-2);
  border-block-start: 1px solid var(--color-border-subtle);
  color: var(--color-text);
  font-size: var(--ui-font-size-body);
  font-weight: var(--ui-weight-strong);
}

/* Short facts in an inspector stay aligned instead of becoming a tall
   label/value stack. Long values wrap within their column. */
.block_detail_list[data-layout='compact'] {
  grid-template-columns: minmax(min-content, 28%) minmax(0, 1fr);
  gap: 0;
  margin-block-end: 0;
}

.block_detail_list[data-layout='compact'] > :is(dt, dd),
#main .block_detail_list[data-layout='compact'] > :is(dt, dd) {
  min-width: 0;
  margin: 0;
  padding-block: var(--ui-space-2);
  border-block-end: 1px solid var(--color-border-subtle);
  overflow-wrap: anywhere;
}

.block_detail_list[data-layout='compact'] > dd {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--ui-space-2);
}

.block_detail_list[data-layout='compact'] > :is(dt, dd):nth-last-child(-n + 2) {
  border-block-end: none;
}

/* A label beside a copy box is centred on the box. The cell keeps the
   row's height and rule. */
.block_detail_list[data-layout='compact'] > dt:has(+ dd > .block_copy_field) {
  display: flex;
  align-items: center;
}

/* A trailing action (a value's Copy button) sits at the row end, centred on
   the value. Its touch target adds little height to the row. */
.block_detail_list[data-layout='compact'] > dd:has(> .block_action:last-child) {
  align-items: center;
}

.block_detail_list[data-layout='compact'] > dd > .block_action:last-child {
  margin-block: calc(var(--ui-space-2) * -1);
  margin-inline: 0;
}

/* A label breaks only between words: its column is at least as wide as its
   longest word ("Photographers"), so a narrow box never splits one. */
.block_detail_list[data-layout='compact'] > dt,
#main .block_detail_list[data-layout='compact'] > dt {
  padding-inline-end: var(--ui-space-3);
  overflow-wrap: break-word;
}

/* layout: :inline puts a record's few short facts on one quiet line under
   its heading (an archive's files, size and dates). Each label is before
   its value, and the pairs wrap as whole pairs. */
.block_detail_list[data-layout='inline'] {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ui-space-1) var(--ui-space-6);
  margin: 0 0 var(--ui-section-gap);
}

.block_detail_list[data-layout='inline'] > dt {
  margin-inline-end: calc(var(--ui-space-2) - var(--ui-space-6));
}

.block_detail_list[data-layout='inline'] > dd,
#main .block_detail_list[data-layout='inline'] > dd {
  overflow-wrap: normal;
  white-space: nowrap;
}

.block_detail_list[data-layout='inline'] > dd + dt {
  margin-block-start: 0;
}
