/* collection: a list of records as a table from column definitions, with
   one primary action per row and the rest in an overflow menu. In a narrow
   container, or one narrower than the table needs, each row becomes a card
   (BLOCKS.md "Every width"). Below the table's width, blocks/collection.js
   sets the padding --block-collection-reserve, so the container is 599px
   wide and the card rules apply. The children go over the padding with a
   negative margin. */
.block_collection {
  --block-collection-label-width: calc(var(--ui-space-12) * 2.5);
  --block-collection-clip-min: calc(var(--ui-space-12) * 2.5);
  --block-collection-primary-min: calc(var(--ui-space-12) * 3.5);
  --block-collection-menu-slot: var(--ui-control-height-compact);

  min-width: 0;
  container: block-collection / inline-size;
}

.block_collection[data-stack-below] {
  padding-inline-end: var(--block-collection-reserve);
}

.block_collection[data-stack-below] > * {
  margin-inline-end: calc(var(--block-collection-reserve) * -1);
}

@media (any-pointer: coarse) {
  .block_collection {
    --block-collection-menu-slot: var(--ui-touch-target);
  }
}

.block_surface_body > p + .block_collection,
.block_collection + :is(p, .block_notice) {
  margin-block-start: var(--ui-space-4);
}

/* Density redefines the shared table tokens, which the legacy #main table
   rules read as well, so both agree. */
.block_collection[data-density='compact'] {
  --ui-table-cell-block: var(--ui-space-1);
  --ui-table-cell-inline: var(--ui-space-2);
}

/* The scroll box positions what is inside it. The absolutely positioned
   hidden labels and switch inputs of a wide table then scroll with it
   instead of widening the page. */
.block_collection_scroll {
  position: relative;
  overflow-x: auto;
  container: block-collection-box / inline-size;
}

.block_collection_scroll[hidden],
.block_collection_table[hidden] {
  display: none;
}

/* Tiles lay out in their own list (the image views' grid), which spaces its
   edges itself, so nothing clips them. */
.block_collection[data-layout='tiles'] > .block_collection_scroll {
  overflow: visible;
}

/* The list's layout (margins, gaps, columns) belongs to its tile grid. */
.block_collection_tiles {
  list-style: none;
}

.block_collection_table {
  width: 100%;
  font-size: var(--ui-font-size-body);
  border-collapse: collapse;
}

/* The table rule (RULES §8.14): text, dates, states and switches start each
   cell, and every cell sits on the row's centre line. */
.block_collection_table :is(th, td) {
  padding: var(--ui-table-cell-block) var(--ui-table-cell-inline);
  text-align: start;
  vertical-align: middle;
}

/* The panel column's legacy table rule (#panels th, td: 8px all round) would
   pad every cell again on top of the collection's own spacing. */
#panels .block_collection_table :is(th, td) {
  padding: var(--ui-table-cell-block) var(--ui-table-cell-inline);
}

.block_collection_table thead th {
  color: var(--color-text-secondary);
  font-family: var(--ui-font-family);
  font-size: var(--ui-font-size-label);
  font-weight: var(--ui-weight-medium);
  white-space: nowrap;
}

.block_collection_table tbody tr {
  border-block-start: 1px solid var(--color-border-subtle);
}

.block_collection_table tbody tr:hover > td,
.block_collection_table tbody tr[data-active] > td {
  background-color: var(--color-toolbar-hover);
}

/* A long value (an address, a URL) wraps inside its cell rather than
   running under the row's actions. The name never gets narrower than a few
   words (--block-collection-primary-min), so it breaks between words. It
   breaks inside a word only when that word is wider than the column. */
.block_collection_primary_cell {
  width: 100%;
  font-weight: var(--ui-weight-medium);
  overflow-wrap: anywhere;
}

.block_collection_table td.block_collection_primary_cell {
  min-width: var(--block-collection-primary-min);
}

/* A column that grows (c.column(grow: true)) takes the spare width; the
   primary cell then keeps to its content on one line. */
.block_collection_table[data-grow] .block_collection_primary_cell {
  width: 1%;
  white-space: nowrap;
}

.block_collection_table .block_collection_grow_cell {
  width: 100%;
}

/* Several growing columns share the space according to their content. Giving
   each 100% lets the first consume the later columns' width. */
.block_collection_table:has(th.block_collection_grow_cell ~ th.block_collection_grow_cell) .block_collection_grow_cell {
  width: auto;
}

/* A table keeps each value on one line, and the name takes the spare
   width. When the box is too narrow for that, the script sets
   data-fit="tight". Then each column wraps between words. No column takes
   all the spare width, because that squeezes the others to one word. */
@container block-collection (width >= 600px) {
  .block_collection:not([data-fit='tight']) .block_collection_table td:not(.block_collection_primary_cell, .block_collection_grow_cell, .block_collection_clip_cell, .block_collection_media_cell) {
    white-space: nowrap;
  }

  .block_collection[data-fit='tight'] .block_collection_table :is(.block_collection_primary_cell, .block_collection_grow_cell:not(.block_collection_clip_cell)) {
    width: auto;
    white-space: normal;
  }
}

/* A tight table puts its columns closer together, as compact density does
   for its rows. Then a laptop's workspace keeps the table for longer. */
.block_collection[data-fit='tight']:not([data-density='compact']) {
  --ui-table-cell-inline: var(--ui-space-3);
}

/* A numeric column (c.column(numeric: true)): counts and money line up on
   their last digit, in tabular figures. The header's name ends where the
   digits end. The #main and #panels copies outrank the legacy th rules. */
.block_collection_table .block_collection_numeric_cell,
:is(#main, #panels) .block_collection_table th.block_collection_numeric_cell {
  font-variant-numeric: tabular-nums;
  text-align: end;
  white-space: nowrap;
}

/* A numeric cell with no value (its block gave nil) shows a quiet dash. Its
   hidden word (Unknown) is for assistive technology. */
.block_collection_missing::before {
  color: var(--color-text-secondary);
  content: '\2014' var(--ui-icon-alt,);
}

/* A short value that reads wrongly broken (a date, a method):
   c.column(nowrap: true). A date or time (ui_time) never breaks in any
   cell ("6 days / ago"), whichever column it sits in. */
.block_collection_table .block_collection_nowrap_cell,
.block_collection_table :is(time, relative-time) {
  white-space: nowrap;
}

/* A cell's second line (.block_collection_detail), quieter than its value,
   so a row reads as one record: the email under a customer's name. */
.block_collection_detail {
  display: block;
  color: var(--color-text-secondary);
  font-size: var(--ui-font-size-small);
  font-weight: var(--ui-weight-regular);
}

/* Code in a cell (.block_collection_code), such as a selector or a CSS
   property. It uses the code face at the small size and keeps its line
   breaks. It wraps anywhere, so a long selector never widens the table. */
.block_collection_code {
  font-family: var(--ui-font-family-code);
  font-size: var(--ui-font-size-small);
  line-height: var(--ui-line-height-body);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* A disclosure in a cell (a row's selector or settings) sits close under
   the cell's first line. */
.block_collection_table td .block_disclosure {
  margin-block-start: var(--ui-space-1);
}

/* A cell's paragraphs (a comment's text) start and end level with the
   cell's other lines. */
.block_collection_table td > p:first-child {
  margin-block-start: 0;
}

.block_collection_table td > p:last-of-type {
  margin-block-end: 0;
}

/* A plain text row with a second line, and no glyph figure or picture, reads
   along its first lines. Every cell's first line, the action's label too,
   shares one baseline, and the quieter lines sit beneath. A row with a figure
   or a picture keeps the centre line, where the glyph and its lines meet. */
.block_collection_table tr:has(:is(.block_collection_detail, .block_collection_kind)):not(:has(.block_collection_figure, > td.block_collection_media_cell, > td img)) > td,
.block_collection_table tr:has(:is(.block_collection_detail, .block_collection_kind)):not(:has(.block_collection_figure, > td.block_collection_media_cell, > td img)) .block_row_actions {
  vertical-align: baseline;
}

/* The small line above a row's name (.block_collection_kind) stays out of
   that shared line. It is floated, so it makes no line box. The other cells
   then sit level with the name it labels rather than with the label. */
.block_collection:not([data-layout]) .block_collection_table td > .block_collection_kind {
  float: inline-start;
  inline-size: 100%;
}

/* A picture in a table row (c.column(media: true) without layout: :cards) is
   a small 3:2 thumbnail. It is cropped to fill and keeps the row its height.
   A row without one keeps the space with a muted well
   (.block_collection_thumb). */
.block_collection:not([data-layout]) .block_collection_table td.block_collection_media_cell {
  width: 1%;
  padding-inline-end: 0;
}

.block_collection:not([data-layout]) .block_collection_media_cell > :is(img, .block_collection_thumb) {
  display: block;
  flex: none;
  inline-size: var(--block-collection-thumb-width, 72px);
  max-inline-size: none;
  block-size: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  background-color: var(--color-surface-muted);
  border-radius: var(--ui-radius-control);
}

/* A small picture beside a cell's text (an avatar beside a name) sits on
   the text's centre. This applies in a table row and in a stacked card. */
.block_collection_table td:not(.block_collection_media_cell) img {
  align-self: center;
  vertical-align: middle;
}

/* A clipped column (c.column(clip: true)) keeps a sentence or a sample to
   one line, cut short. Max-width 0 stops it widening the table. The cell's
   title holds the whole text. The column never gets narrower than a few
   words. A table whose other columns leave less becomes cards. */
.block_collection_table .block_collection_clip_cell {
  min-width: var(--block-collection-clip-min);
  max-width: 0;
}

.block_collection_clip_cell,
.block_collection_clip_cell > * {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.block_collection_handle_cell,
.block_collection_actions_cell,
.block_collection_status_cell,
.block_collection_toggle_cell {
  width: 1%;
  white-space: nowrap;
}

.block_collection_table .block_collection_handle_cell {
  padding-inline-end: 0;
}

.block_collection_table .block_collection_actions_cell {
  text-align: end;
}

/* The handle shows where a row can be dragged (the reorder block installs the
   drag on td:first-child). Keyboard and touch reorder with its Move controls. */
.block_collection_handle {
  display: inline-grid;
  width: var(--ui-toolbar-control);
  height: var(--ui-control-height-compact);
  color: var(--color-text-secondary);
  cursor: grab;
  place-items: center;
  touch-action: none;
}

.block_collection_handle::before {
  font-family: var(--ui-icon-font-family);
  font-size: var(--ui-icon-size);
  font-weight: var(--ui-icon-weight);
  line-height: 1;
  content: var(--ui-icon-grip-vertical) var(--ui-icon-alt,);
}

.block_collection_table tr:hover .block_collection_handle {
  color: var(--color-text);
}

/* A glyph beside the primary text (a record's kind). Its box is one em tall,
   so it never makes the text's line taller than its neighbours' lines. */
.block_collection_glyph {
  display: inline-block;
  width: var(--ui-icon-size);
  margin-inline-end: var(--ui-space-2);
  color: var(--color-text-secondary);
  font-family: var(--ui-icon-font-family);
  font-size: var(--ui-icon-size);
  font-weight: var(--ui-icon-weight);
  line-height: 1;
  text-align: center;
}

.block_collection_glyph[data-glyph='link']::before {
  content: var(--ui-icon-link) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='folder']::before {
  content: var(--ui-icon-folder) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='page']::before {
  content: var(--ui-icon-file-lines) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='images']::before {
  content: var(--ui-icon-images) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='camera']::before {
  content: var(--ui-icon-camera) var(--ui-icon-alt,);
}

/* A download's file, by its format (DownloadsHelper#download_glyph_name). */
.block_collection_glyph[data-glyph='file']::before {
  content: var(--ui-icon-file) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-jpg']::before {
  content: var(--ui-icon-file-jpg) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-png']::before {
  content: var(--ui-icon-file-png) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-gif']::before {
  content: var(--ui-icon-file-gif) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-svg']::before {
  content: var(--ui-icon-file-svg) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-eps']::before {
  content: var(--ui-icon-file-eps) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-pdf']::before {
  content: var(--ui-icon-file-pdf) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-zip']::before {
  content: var(--ui-icon-file-zip) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-mov']::before {
  content: var(--ui-icon-file-mov) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-mp4']::before {
  content: var(--ui-icon-file-mp4) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-mp3']::before {
  content: var(--ui-icon-file-mp3) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-wav']::before {
  content: var(--ui-icon-file-wav) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-aiff']::before {
  content: var(--ui-icon-file-aiff) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-txt']::before {
  content: var(--ui-icon-file-txt) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-csv']::before {
  content: var(--ui-icon-file-csv) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-doc']::before {
  content: var(--ui-icon-file-doc) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-xls']::before {
  content: var(--ui-icon-file-xls) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-ppt']::before {
  content: var(--ui-icon-file-ppt) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-html']::before {
  content: var(--ui-icon-file-html) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-xml']::before {
  content: var(--ui-icon-file-xml) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-image']::before {
  content: var(--ui-icon-file-image) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-video']::before {
  content: var(--ui-icon-file-video) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-audio']::before {
  content: var(--ui-icon-file-audio) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-zipper']::before {
  content: var(--ui-icon-file-zipper) var(--ui-icon-alt,);
}

/* Each kind of record a list row shows has a light glyph (RULES §13.1). The
   Google glyph is a brand, so it comes from the brands face. */
.block_collection_glyph[data-glyph='badge-percent']::before {
  content: var(--ui-icon-badge-percent) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='bag-shopping']::before {
  content: var(--ui-icon-bag-shopping) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='bolt']::before {
  content: var(--ui-icon-bolt) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='books']::before {
  content: var(--ui-icon-books) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='clipboard-list']::before {
  content: var(--ui-icon-clipboard-list) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='clock-rotate-left']::before {
  content: var(--ui-icon-clock-rotate-left) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='code']::before {
  content: var(--ui-icon-code) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='comment']::before {
  content: var(--ui-icon-comment) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='comments-question']::before {
  content: var(--ui-icon-comments-question) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='copyright']::before {
  content: var(--ui-icon-copyright) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='cubes']::before {
  content: var(--ui-icon-cubes) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='database']::before {
  content: var(--ui-icon-database) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='desktop']::before {
  content: var(--ui-icon-desktop) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='diamond-turn-right']::before {
  content: var(--ui-icon-diamond-turn-right) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='envelope']::before {
  content: var(--ui-icon-envelope) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='envelope-open']::before {
  content: var(--ui-icon-envelope-open) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-code']::before {
  content: var(--ui-icon-file-code) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='file-invoice']::before {
  content: var(--ui-icon-file-invoice) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='files']::before {
  content: var(--ui-icon-files) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='filter']::before {
  content: var(--ui-icon-filter) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='folder-gear']::before {
  content: var(--ui-icon-folder-gear) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='folder-tree']::before {
  content: var(--ui-icon-folder-tree) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='font']::before {
  content: var(--ui-icon-font) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='globe']::before {
  content: var(--ui-icon-globe) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='google']::before {
  font-family: var(--ui-icon-font-family-brands);
  font-weight: var(--ui-weight-regular);
  content: var(--ui-icon-google) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='heart']::before {
  content: var(--ui-icon-heart) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='input-text']::before {
  content: var(--ui-icon-input-text) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='key']::before {
  content: var(--ui-icon-key) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='laptop-mobile']::before {
  content: var(--ui-icon-laptop-mobile) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='layer-group']::before {
  content: var(--ui-icon-layer-group) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='list']::before {
  content: var(--ui-icon-list) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='list-check']::before {
  content: var(--ui-icon-list-check) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='lock']::before {
  content: var(--ui-icon-lock) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='mobile']::before {
  content: var(--ui-icon-mobile) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='newspaper']::before {
  content: var(--ui-icon-newspaper) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='palette']::before {
  content: var(--ui-icon-palette) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='paper-plane']::before {
  content: var(--ui-icon-paper-plane) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='puzzle-piece']::before {
  content: var(--ui-icon-puzzle-piece) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='receipt']::before {
  content: var(--ui-icon-receipt) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='rss']::before {
  content: var(--ui-icon-rss) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='ruler-combined']::before {
  content: var(--ui-icon-ruler-combined) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='share-nodes']::before {
  content: var(--ui-icon-share-nodes) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='sliders']::before {
  content: var(--ui-icon-sliders) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='swatchbook']::before {
  content: var(--ui-icon-swatchbook) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='tablet']::before {
  content: var(--ui-icon-tablet) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='tag']::before {
  content: var(--ui-icon-tag) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='timeline']::before {
  content: var(--ui-icon-timeline) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='truck']::before {
  content: var(--ui-icon-truck) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='user']::before {
  content: var(--ui-icon-user) var(--ui-icon-alt,);
}

/* A row's series swatch (.block_collection_swatch[data-series="1"…"8"]) is a
   short line in the chart colour of the row's series, before its name. The
   table is then the key to the charts beside it. */
.block_collection_swatch {
  display: inline-block;
  width: var(--ui-space-4);
  height: var(--ui-space-1);
  margin-inline-end: var(--ui-space-2);
  vertical-align: middle;
  background-color: var(--block-collection-swatch, var(--color-chart-8));
  border-radius: var(--ui-radius-control);
}

.block_collection_swatch[data-series='1'] { --block-collection-swatch: var(--color-chart-1); }
.block_collection_swatch[data-series='2'] { --block-collection-swatch: var(--color-chart-2); }
.block_collection_swatch[data-series='3'] { --block-collection-swatch: var(--color-chart-3); }
.block_collection_swatch[data-series='4'] { --block-collection-swatch: var(--color-chart-4); }
.block_collection_swatch[data-series='5'] { --block-collection-swatch: var(--color-chart-5); }
.block_collection_swatch[data-series='6'] { --block-collection-swatch: var(--color-chart-6); }
.block_collection_swatch[data-series='7'] { --block-collection-swatch: var(--color-chart-7); }
.block_collection_swatch[data-series='8'] { --block-collection-swatch: var(--color-chart-8); }
.block_collection_swatch[data-series='rest'] { --block-collection-swatch: var(--color-chart-rest); }
.block_collection_swatch[data-series='other'] { --block-collection-swatch: var(--color-chart-other); }

/* A record known by its kind: a larger glyph on the left, level with its
   lines. For example, a camera beside its serial number and model. */
.block_collection_figure {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: var(--ui-space-3);
}

/* The glyph's box is as wide as the widest glyph (1.25em), so the lines never
   move when the icon font arrives. The names in a column also start together. */
.block_collection_figure > .block_collection_glyph {
  width: 1.25em;
  margin-inline-end: 0;
  font-size: calc(var(--ui-icon-size-large) * 1.4);
  font-weight: var(--ui-icon-weight-thin);
}

/* A picture can take the glyph's place (an archive's file made from an
   image, linked to it). It is a small square as wide as the glyph's box.
   So the names in the column still start together. */
.block_collection_figure > a:has(> img) {
  display: block;
  line-height: 0;
}

.block_collection_figure > :is(img, a > img) {
  inline-size: calc(var(--ui-icon-size-large) * 1.75);
  block-size: calc(var(--ui-icon-size-large) * 1.75);
  /* Its column is as wide as the picture, so a percentage limit would make
     both zero: the picture keeps its size. */
  max-inline-size: none;
  object-fit: cover;
  background-color: var(--color-surface-muted);
  border-radius: var(--ui-radius-control);
}

/* When a column grows (c.column(grow: true)), the other cells keep to their
   content, and the primary cell keeps to one line. A figure outside the
   growing column then keeps its lines' width, so they do not collapse under
   the next column. */
.block_collection_table[data-grow] td:not(.block_collection_grow_cell) .block_collection_figure {
  grid-template-columns: auto 1fr;
}

/* A figure outside the primary column keeps its lines' width too (the
   account log's Who column: a person's picture beside two lines). Only the
   primary cell takes the spare width, so only its lines can give way. */
.block_collection_table td:not(.block_collection_primary_cell, .block_collection_grow_cell) .block_collection_figure {
  grid-template-columns: auto 1fr;
}

.block_row_actions {
  display: inline-flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--ui-space-1);
  vertical-align: middle;
}

.block_row_actions > .button,
.block_row_actions > .button + .button {
  margin: 0;
}

/* A small action with words (Run, Open, Details) has a minimum width, so
   the buttons in a column line up. In a narrow box the width can be less,
   so the name keeps its room. */
.block_row_actions > .block_action.small:not([data-icon-only]) {
  min-inline-size: min(var(--ui-row-action-min-width), 30cqi);
}

/* When a row of the table has a menu, a row without one keeps an empty
   slot of the same width. Thus the primary actions line up in every row. */
.block_collection_table:has(.block_row_actions > .block_menu_anchor) .block_row_actions:not(:has(> .block_menu_anchor))::after {
  inline-size: var(--block-collection-menu-slot);
  flex: none;
  content: '';
}

/* A switch cell's label names the switch for assistive technology; the
   column header (or the card label) shows it. */
.block_collection_toggle_cell .ui_field {
  margin: 0;
}

.block_collection_toggle_cell .ui_field > label:not(.switch_label) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  white-space: nowrap;
  clip-path: inset(50%);
}

/* The legacy "#main table input[type=checkbox]" rule would give the switch's
   hidden checkbox a 16px box beside it. */
.block_collection .switch_input,
#main .block_collection .switch_input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  border: 0;
}

.block_collection > .block_empty_state {
  border-block-start: 1px solid var(--color-border-subtle);
}

/* The pager (a collection that pages on the server, RULES §8.11): the search
   and the live caption above the rows, Show more under them. The caption
   ends the line in tabular figures, so a new count moves nothing else. */
.block_collection_pager {
  --block-collection-search-width: calc(var(--ui-space-12) * 6);

  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ui-space-2) var(--ui-space-4);
  padding-block-end: var(--ui-space-3);
}

.block_collection_pager[hidden],
.block_collection_more[hidden] {
  display: none;
}

/* After something in its surface (a form) the search keeps a gap. After a
   paragraph the collection's own margin is that gap, so it is not doubled. */
:not(p) + .block_collection > .block_collection_pager {
  margin-block-start: var(--ui-space-4);
}

.block_collection_search {
  position: relative;
  flex: 0 1 var(--block-collection-search-width);
  min-width: 0;
  margin: 0;
}

.block_collection_search::before {
  position: absolute;
  inset-block: 0;
  inset-inline-start: var(--ui-space-3);
  display: grid;
  color: var(--color-text-secondary);
  font-family: var(--ui-icon-font-family);
  font-size: var(--ui-icon-size);
  font-weight: var(--ui-icon-weight);
  line-height: 1;
  pointer-events: none;
  content: var(--ui-icon-magnifying-glass) var(--ui-icon-alt,);
  place-items: center;
}

.block_collection_search input[type='search'] {
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding-inline-start: calc(var(--ui-space-3) + var(--ui-icon-size) + var(--ui-space-2));
}

.block_collection_count {
  margin: 0;
  margin-inline-start: auto;
  color: var(--color-text-secondary);
  font-size: var(--ui-font-size-label);
  font-variant-numeric: tabular-nums;
}

.block_collection_more {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--ui-space-3);
  padding-block: var(--ui-space-4);
  border-block-start: 1px solid var(--color-border-subtle);
}

/* A sort header: the column's name as a button, and a box for the
   direction's glyph. The box is always there; the glyph shows on the sorted
   column. The name sets the button's baseline, level with other headers. */
.block_collection_sort {
  display: inline-flex;
  align-items: baseline;
  gap: var(--ui-space-1);
  margin: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  white-space: nowrap;
  background: none;
  border: 0;
  cursor: pointer;
}

.block_collection_sort:hover,
th[aria-sort] > .block_collection_sort {
  color: var(--color-text);
}

/* Over a numeric column the glyph's box comes before the name, so the name
   ends where the digits end. */
th.block_collection_numeric_cell > .block_collection_sort {
  flex-direction: row-reverse;
}

.block_collection_sort_glyph {
  display: inline-block;
  align-self: center;
  width: var(--ui-icon-size);
  font-family: var(--ui-icon-font-family);
  font-weight: var(--ui-icon-weight);
  line-height: 1;
  text-align: center;
}

th[aria-sort='ascending'] .block_collection_sort_glyph::before {
  content: var(--ui-icon-arrow-up) var(--ui-icon-alt,);
}

th[aria-sort='descending'] .block_collection_sort_glyph::before {
  content: var(--ui-icon-arrow-down) var(--ui-icon-alt,);
}

/* While rows load, those shown dim a moment later, so a quick answer never
   flickers. The first row Show more adds takes focus. */
.block_collection [data-pager-rows][aria-busy='true'] {
  opacity: var(--ui-opacity-dimmed);
  transition: opacity var(--ui-duration-feedback) linear var(--ui-duration-feedback);
}

.block_collection [data-pager-rows] > :focus-visible {
  outline: 2px solid var(--color-input-focus-border);
  outline-offset: -2px;
}

.block_collection_sort_controls.block_fields {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--ui-space-3);
  margin-block-end: var(--ui-space-4);
}

.block_collection_sort_controls > .ui_field {
  flex: 0 1 auto;
  min-inline-size: 0;
  margin: 0;
}

/* Stacked cards: the handle, primary text and actions share the first line;
   every other column follows as "label value" beneath. */
@container block-collection (width < 600px) {
  .block_collection_table,
  .block_collection_table tbody {
    display: block;
  }

  .block_collection_table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  /* A paged collection's search takes the line; its sort buttons stay, a line
     of them above the cards, the other headers left out. */
  .block_collection_search {
    flex-basis: 100%;
  }

  .block_collection_table thead:has(.block_collection_sort) {
    position: static;
    display: block;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
  }

  .block_collection_table thead:has(.block_collection_sort) tr {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ui-space-2) var(--ui-space-4);
    padding: 0 var(--ui-space-2) var(--ui-space-3);
  }

  .block_collection_table thead:has(.block_collection_sort) th:not(:has(.block_collection_sort)) {
    display: none;
  }

  /* In that line every name starts its button, numbers' too. */
  .block_collection_table th.block_collection_numeric_cell > .block_collection_sort {
    flex-direction: row;
  }

  .block_collection_table tr {
    --ui-table-cell-block: 0;
    --ui-table-cell-inline: 0;

    display: grid;
    align-items: center;
    grid-template-columns: [handle] auto [main] minmax(0, 1fr) [actions] auto;
    gap: var(--ui-space-1) var(--ui-space-2);
    padding: var(--ui-space-3) var(--ui-space-2);
  }

  .block_collection:not([data-reorder]) .block_collection_table tr {
    grid-template-columns: [main] minmax(0, 1fr) [actions] auto;
  }

  /* A value of one long word (a selector, a host) breaks inside the word
     rather than going past its card. */
  .block_collection_table td {
    display: flex;
    align-items: center;
    gap: var(--ui-space-2);
    grid-column: main / -1;
    width: auto;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .block_collection_table td:empty {
    display: none;
  }

  /* The handle and the actions stay level with the top of the name, so a long
     second line (a product's description) never leaves them floating. */
  .block_collection_table td.block_collection_handle_cell {
    grid-column: handle;
    grid-row: 1;
    align-self: start;
  }

  .block_collection_table td.block_collection_primary_cell {
    grid-column: main;
    grid-row: 1;
    font-size: var(--ui-font-size-control);
  }

  .block_collection_table td.block_collection_primary_cell > * {
    min-width: 0;
  }

  /* A compact list (a panel's list of sets, versions or links) is something
     to scan in a small space. It has tighter rows and the label size for the
     text, like the other panel lists. */
  .block_collection[data-density='compact'] .block_collection_table tr {
    padding: var(--ui-space-1) var(--ui-space-2);
  }

  .block_collection[data-density='compact'] .block_collection_table td.block_collection_primary_cell {
    font-size: var(--ui-font-size-label);
    line-height: var(--ui-line-height-control);
  }

  /* A card's primary text wraps even when another column grows; a clipped
     value takes its own full-width line, still one line. */
  .block_collection_table[data-grow] td:is(.block_collection_primary_cell, .block_collection_grow_cell) {
    width: auto;
    white-space: normal;
  }

  .block_collection_table td.block_collection_numeric_cell {
    text-align: start;
  }

  .block_collection_table td.block_collection_clip_cell {
    display: block;
    min-width: 0;
    max-width: none;
    white-space: nowrap;
  }

  .block_collection_table td.block_collection_clip_cell[data-label]::before {
    display: block;
  }

  .block_collection_table td.block_collection_actions_cell {
    justify-content: flex-end;
    grid-column: actions;
    grid-row: 1;
    align-self: start;
  }

  /* Full-width identity lines leave the actions at the foot of the card. */
  .block_collection[data-card-actions='below'] .block_collection_primary_cell {
    grid-column: main / -1;
  }

  .block_collection[data-card-actions='below'] .block_collection_actions_cell {
    grid-column: main / -1;
    grid-row: auto;
    margin-block-start: var(--ui-space-2);
  }

  .block_collection:has(> .block_collection_sort_controls) .block_collection_table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .block_collection_table td[data-label]::before {
    flex: 0 0 var(--block-collection-label-width);
    color: var(--color-text-secondary);
    font-size: var(--ui-font-size-label);
    content: attr(data-label);
  }

  /* A cell with a line above or below its value (.block_collection_kind,
     .block_collection_detail) keeps its lines stacked. */
  .block_collection_table td:has(> :is(.block_collection_kind, .block_collection_detail)) {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }

  /* A label sits level with its value's first line, so a value that wraps
     starts beside its label. A switch stays centred on its label, and a
     clipped value keeps its own line under its label. */
  .block_collection_table td[data-label]:not(.block_collection_toggle_cell, .block_collection_clip_cell) {
    align-items: baseline;
  }

  /* A labelled figure (a person's picture beside their name and a second
     line) starts level with its label. The picture has no line of its own,
     so it must not set the line the label sits on. */
  .block_collection_table td[data-label]:not(.block_collection_toggle_cell, .block_collection_clip_cell):has(> .block_collection_figure) {
    align-items: flex-start;
  }

  /* A labelled value with a second line (a cost and its currency) keeps the
     label in its column and stacks the value's lines beside it. */
  .block_collection_table td[data-label]:not(.block_collection_clip_cell):has(> :is(.block_collection_kind, .block_collection_detail)) {
    display: grid;
    grid-template-columns: var(--block-collection-label-width) minmax(0, 1fr);
    column-gap: var(--ui-space-2);
  }

  .block_collection_table td[data-label]:not(.block_collection_clip_cell):has(> :is(.block_collection_kind, .block_collection_detail)) > * {
    grid-column: 2;
  }

  /* A row's thumbnail sits at the card's left beside its lines, smaller and
     without a label (its picture says what it is). */
  .block_collection:not([data-layout]) .block_collection_table tr:has(> td.block_collection_media_cell) {
    --block-collection-thumb-width: 56px;

    grid-template-columns: [media] auto [main] minmax(0, 1fr) [actions] auto;
  }

  /* A list that reorders keeps the drag handle first, before the picture. */
  .block_collection[data-reorder]:not([data-layout]) .block_collection_table tr:has(> td.block_collection_media_cell) {
    grid-template-columns: [handle] auto [media] auto [main] minmax(0, 1fr) [actions] auto;
  }

  .block_collection:not([data-layout]) .block_collection_table td.block_collection_media_cell {
    grid-column: media;
    grid-row: 1 / span 3;
    align-self: start;
    width: auto;
  }

  .block_collection:not([data-layout]) .block_collection_table td.block_collection_media_cell::before {
    content: none;
  }

  /* In a box of 600px or more, a card shows its labelled values in two
     columns under the name. Thus each card stays a few lines tall. */
  @container block-collection-box (width >= 600px) {
    .block_collection_table tr {
      align-items: baseline;
      grid-template-columns: [handle] auto [main] minmax(0, 1fr) [half] minmax(0, 1fr) [actions] auto;
      column-gap: var(--ui-space-4);
    }

    .block_collection:not([data-reorder]) .block_collection_table tr {
      grid-template-columns: [main] minmax(0, 1fr) [half] minmax(0, 1fr) [actions] auto;
    }

    .block_collection:not([data-layout]) .block_collection_table tr:has(> td.block_collection_media_cell) {
      grid-template-columns: [media] auto [main] minmax(0, 1fr) [half] minmax(0, 1fr) [actions] auto;
    }

    .block_collection[data-reorder]:not([data-layout]) .block_collection_table tr:has(> td.block_collection_media_cell) {
      grid-template-columns: [handle] auto [media] auto [main] minmax(0, 1fr) [half] minmax(0, 1fr) [actions] auto;
    }

    .block_collection_table td.block_collection_primary_cell {
      grid-column: main / actions;
    }

    .block_collection_table td:nth-child(odd of :not(.block_collection_handle_cell, .block_collection_primary_cell, .block_collection_media_cell, .block_collection_actions_cell, .block_collection_clip_cell, :empty)) {
      grid-column: main / half;
    }

    .block_collection_table td:nth-child(even of :not(.block_collection_handle_cell, .block_collection_primary_cell, .block_collection_media_cell, .block_collection_actions_cell, .block_collection_clip_cell, :empty)) {
      grid-column: half / -1;
    }

    /* A clipped value comes after the pairs, so no pair is left alone on
       its line. Its label stays beside it. */
    .block_collection_table td.block_collection_clip_cell {
      order: 1;
    }

    .block_collection_table td.block_collection_clip_cell[data-label] {
      display: grid;
      grid-template-columns: var(--block-collection-label-width) minmax(0, 1fr);
      column-gap: var(--ui-space-2);
    }

    .block_collection_table td.block_collection_clip_cell[data-label]::before {
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }

  /* One hover surface per card, over the legacy per-cell hover. */
  .block_collection_table tbody tr:hover,
  #main .block_collection_table tbody tr:hover {
    background-color: var(--color-toolbar-hover);
  }

  .block_collection_table tbody tr:hover > td,
  #main .block_collection_table tbody tr:hover > td {
    background-color: transparent;
  }
}

/* Cards (layout: :cards): the same table, each row a card. Its picture (a
   media: true column) sits on the left, with its name, facts and other text
   columns beside it. Its switch and actions sit on the right, level with the
   name. The switch is named by its column, as there is no header to name it.
   The headers stay for assistive technology. In a narrow container the
   picture sits over the rest. */
.block_collection[data-layout='cards'] .block_collection_table,
.block_collection[data-layout='cards'] .block_collection_table tbody {
  display: block;
}

.block_collection[data-layout='cards'] .block_collection_table tbody {
  display: grid;
  gap: var(--ui-space-3);
}

.block_collection[data-layout='cards'] .block_collection_table thead {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.block_collection[data-layout='cards'] .block_collection_table tbody tr {
  --ui-table-cell-block: 0;
  --ui-table-cell-inline: 0;

  display: grid;
  align-items: start;
  grid-template-columns: [media] auto [main] minmax(0, 1fr) [toggle] auto [actions] auto;
  grid-template-rows: auto auto 1fr;
  gap: var(--ui-space-1) var(--ui-space-6);
  padding: var(--ui-space-4);
  border: 1px solid var(--color-border-faint);
  border-radius: var(--ui-radius-surface);
}

.block_collection[data-layout='cards'] .block_collection_table tbody tr:hover {
  border-color: var(--color-border-subtle);
}

/* A card never shades on hover, over the legacy per-cell hover of
   "#main tbody tr:hover td" (user_interface/tables); its edge darkens. */
.block_collection[data-layout='cards'] .block_collection_table tbody tr:hover,
#main .block_collection[data-layout='cards'] .block_collection_table tbody tr:hover,
.block_collection[data-layout='cards'] .block_collection_table tbody tr:hover > td,
#main .block_collection[data-layout='cards'] .block_collection_table tbody tr:hover > td {
  background-color: transparent;
}

.block_collection[data-layout='cards'] .block_collection_table td {
  display: block;
  grid-column: main;
  width: auto;
  min-width: 0;
  padding: 0;
  white-space: normal;
  border: 0;
}

.block_collection[data-layout='cards'] .block_collection_table td:empty {
  display: none;
}

.block_collection[data-layout='cards'] .block_collection_table td.block_collection_media_cell {
  grid-column: media;
  grid-row: 1 / span 3;
}

.block_collection[data-layout='cards'] .block_collection_table td.block_collection_toggle_cell {
  display: flex;
  align-items: center;
  gap: var(--ui-space-2);
  grid-column: toggle;
  grid-row: 1;
}

.block_collection[data-layout='cards'] .block_collection_toggle_cell::before {
  color: var(--color-text-secondary);
  font-size: var(--ui-font-size-small);
  content: attr(data-label);
}

.block_collection[data-layout='cards'] .block_collection_table td.block_collection_actions_cell {
  grid-column: actions;
  grid-row: 1;
}

/* A card's name and what is known about it, in two tones so the eye goes to
   the name first. Its kind (.block_collection_kind) sits small above the
   name, which is large and strong, then a sentence. The name can carry a
   filled .block_collection_tag, such as the homepage's. Its facts follow on a
   tinted panel as labelled rows (.block_collection_facts, a dl). Their labels
   sit in a quiet column, so the rows line up from card to card. */
.block_collection_kind {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: var(--ui-font-size-small);
}

.block_collection_title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ui-space-1) var(--ui-space-3);
  margin: 0;
  color: var(--color-text);
  font-size: var(--ui-font-size-title);
  font-weight: var(--ui-weight-strong);
}

.block_collection_tag {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-1);
  padding: 0 var(--ui-space-2);
  color: var(--color-text);
  font-size: var(--ui-font-size-small);
  font-weight: var(--ui-weight-medium);
  background: var(--color-surface-muted);
  border-radius: var(--ui-radius-control);
}

/* A font's sample in a cell (a website's fonts), large and in its own face.
   The row sets --font-preview-family, as the font picker's samples do, and an
   uploaded face's style and weight. Each one it leaves unset is inherited.
   websites/font_previews.js marks the list data-font-previews-deferred. It
   marks each sample data-font-preview-visible once it scrolls into view. Until
   then the sample keeps the page's face, so a long list downloads only the
   fonts it shows. */
.block_font_sample {
  font-family: var(--font-preview-family, inherit);
  font-size: clamp(var(--ui-type-xl), 4vw, var(--ui-type-xxxl));
  font-style: var(--font-preview-style);
  font-weight: var(--font-preview-weight);
}

[data-font-previews-deferred] .block_font_sample:not([data-font-preview-visible]) {
  font-family: inherit;
}

/* Several tags in a cell (a row's development tags), wrapping as they
   need. */
.block_collection_tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ui-space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.block_collection_tag[data-glyph='house']::before {
  font-family: var(--ui-icon-font-family);
  font-weight: var(--ui-icon-weight);
  content: var(--ui-icon-house) var(--ui-icon-alt,);
}

/* A record that is set apart (a featured blog post) has a small line above
   its name. The line is unboxed, so it labels the name rather than competing
   with it. Its text starts on the name's left edge, and its star is in the
   warning glyph colour. */
.block_collection_kind[data-glyph] {
  display: flex;
  align-items: center;
  gap: var(--ui-space-1);
  margin-block-end: var(--ui-space-1);
  font-weight: var(--ui-weight-medium);
  line-height: 1;
}

.block_collection_kind[data-glyph='star']::before {
  color: var(--color-status-warning-fill);
  font-family: var(--ui-icon-font-family);
  font-weight: var(--ui-icon-weight);
  content: var(--ui-icon-star) var(--ui-icon-alt,);
}

/* A row's name that opens it (.block_collection_link): the text colour,
   underlined on hover, as a link tile's title, never the link blue. */
.block_collection_link,
.block_collection_link:visited {
  color: var(--color-text);
  text-decoration: none;
}

.block_collection_link:hover {
  color: var(--color-text);
  text-decoration: underline;
}

.block_collection_text {
  max-width: 60ch;
  margin: var(--ui-space-2) 0 0;
  color: var(--color-text-secondary);
}

/* The #main copies outrank the legacy "#main dl" rules (user_interface/screens_shared:
   padding, and a floated 152px dt). */
.block_collection_facts,
#main .block_collection_facts {
  display: grid;
  align-items: center;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--ui-space-2) var(--ui-space-6);
  margin: var(--ui-space-4) 0 0;
  padding: var(--ui-space-3) var(--ui-space-4);
  background: var(--color-surface-muted);
  border-radius: var(--ui-radius-surface);
}

.block_collection_facts > div {
  display: contents;
}

.block_collection_facts dt,
#main .block_collection_facts dt {
  float: none;
  width: auto;
  padding: 0;
  color: var(--color-text-secondary);
  font-size: var(--ui-font-size-small);
  font-weight: var(--ui-weight-regular);
}

.block_collection_facts dd,
#main .block_collection_facts dd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ui-space-1) var(--ui-space-3);
  min-width: 0;
  margin: 0;
  padding: 0;
  overflow-wrap: anywhere;
}

/* Another text column (a count) says what it is, as there's no header. */
.block_collection[data-layout='cards'] .block_collection_table td[data-label]:not(.block_collection_media_cell, .block_collection_toggle_cell) {
  display: flex;
  gap: var(--ui-space-2);
}

.block_collection[data-layout='cards'] .block_collection_table td[data-label]:not(.block_collection_media_cell, .block_collection_toggle_cell)::before {
  color: var(--color-text-secondary);
  content: attr(data-label);
}

.block_collection[data-layout='cards'] .block_collection_table td.block_collection_media_cell::before {
  content: none;
}

/* An inspector or side navigation can leave a desktop-sized viewport with a
   much narrower collection. Move controls below the details before they can
   squeeze the name and address between the preview and the actions. */
@container block-collection (width < 1000px) {
  .block_collection[data-layout='cards'] .block_collection_table tbody tr {
    grid-template-columns: [media] auto [main] minmax(0, 1fr) [actions] auto;
  }

  .block_collection[data-layout='cards'] .block_collection_table td {
    grid-column: main / -1;
  }

  .block_collection[data-layout='cards'] .block_collection_table td.block_collection_toggle_cell {
    grid-column: main;
  }

  .block_collection[data-layout='cards'] .block_collection_table td.block_collection_toggle_cell,
  .block_collection[data-layout='cards'] .block_collection_table td.block_collection_actions_cell {
    grid-row: auto;
  }
}

/* In a narrow container the picture goes over the name and facts, which take
   the whole width. The switch and actions share the line under them. */
@container block-collection (width < 760px) {
  .block_collection[data-layout='cards'] .block_collection_table tbody tr {
    grid-template-columns: [main] minmax(0, 1fr) [actions] auto;
    grid-template-rows: none;
    gap: var(--ui-space-3);
    padding: var(--ui-space-3);
  }

  .block_collection[data-layout='cards'] .block_collection_table td,
  .block_collection[data-layout='cards'] .block_collection_table td.block_collection_media_cell {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .block_collection[data-layout='cards'] .block_collection_table td.block_collection_toggle_cell {
    grid-column: main;
    grid-row: auto;
  }

  .block_collection[data-layout='cards'] .block_collection_table td.block_collection_actions_cell {
    grid-column: actions;
    grid-row: auto;
  }
}

/* A longer second line (data-lines="2": what a row's item is for) stops
   at two lines; the whole text is its title. */
.block_collection_detail[data-lines='2'] {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* A named menu in a cell (action_menu trigger: :label, the pages a
   component is on) reads as the cell's value. Its label lines up with the
   column's heading, and its quiet box shows on hover. */
.block_collection_table td:not(.block_collection_actions_cell) .block_menu_trigger[data-trigger='label'] {
  margin-inline-start: calc(var(--ui-space-3) * -1);
}

.block_keyword_choices {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ui-space-2);
  margin: var(--ui-space-3) 0 0;
  padding: 0;
  list-style: none;
}

.block_keyword_choices > li {
  max-inline-size: 100%;
}

.block_keyword_choice {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-2);
  max-inline-size: 100%;
  min-block-size: var(--ui-space-8);
  padding: var(--ui-space-1) var(--ui-space-3);
  color: var(--color-text);
  font: inherit;
  text-align: start;
  overflow-wrap: anywhere;
  background: var(--color-accent-soft-bg);
  border: 1px solid transparent;
  border-radius: var(--ui-space-4);
  cursor: pointer;
}

.block_keyword_choice::before {
  color: var(--color-text-secondary);
  font-family: var(--ui-icon-font-family);
  font-weight: var(--ui-icon-weight);
  content: var(--ui-icon-tags) var(--ui-icon-alt,);
}

.block_keyword_choice:hover {
  border-color: var(--color-control-border);
}

/* Direct removal remains a standard confirmed delete link, with its name
   available to assistive technology and a visible cross instead of a menu. */
.block_row_actions .block_collection_remove.delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-inline-size: var(--ui-touch-target);
  min-block-size: var(--ui-touch-target);
  font-size: 0;
  text-decoration: none;
  padding: 0;
  background: none;
}

.block_row_actions .block_collection_remove.delete::before {
  font-family: var(--ui-icon-font-family);
  font-size: var(--ui-font-size-body);
  font-weight: var(--ui-icon-weight);
  content: var(--ui-icon-xmark) var(--ui-icon-alt,);
}

.block_collection_glyph[data-glyph='tags']::before {
  content: var(--ui-icon-tags) var(--ui-icon-alt,);
}

@media (pointer: coarse) {
  .block_keyword_choice {
    min-block-size: var(--ui-touch-target);
  }
}

/* The progress indicator replaces the tag glyph without changing chip size. */
.block_keyword_choice.ui-submitting::before {
  visibility: hidden;
}

.block_keyword_choice > .dpg-spinner {
  position: absolute;
  inset-block: 0;
  inset-inline-start: var(--ui-space-3);
  margin-block: auto;
  margin-inline: 0;
}
