/*
 * .o-rows — a table that becomes labelled rows below 768px (docs/plans/seq-redesign.md, the
 * review of 2026-09-24: a table clipped at 390px hid the column the reader comes for). On a
 * phone a table of five or more columns inside .o-scroll shows its first two and hides the
 * state mark, the finished time and the result behind a sideways scroll. With this object on
 * the <table>, below 768px each row is a block and each cell a line: the first cell, the
 * identifier, in the row's first line, then one fact per line with its column's header as a
 * label before the value. The header row is kept for assistive technology and taken out of
 * the layout. From 768px the table is the gem's .admin-table as shipped.
 *
 * Structure only: no colour of its own, the label in the body face at --font-size-14. Markup:
 *   <div class="o-scroll"><table class="admin-table o-rows">
 *     <thead><tr><th scope="col">Run</th><th scope="col">State</th>…</tr></thead>
 *     <tbody><tr><td>…</td><td data-label="State">…</td>…</tr></tbody>
 *   </table></div>
 * The view writes data-label on every cell after the identifier, with the column's header
 * word for word; a cell without it stands alone on its line. The state mark or the result is
 * the second column of every table that carries one, so it is the identifier's first fact.
 * A cell that is empty is not drawn as a line. Every .admin-table carries this object
 * (DesignSystemConformanceTest); .seq-params tables carry it too. A table whose first column
 * is a checkbox (the runs index's compare selection, the incoming files' attach selection)
 * puts the checkbox in the identifier's cell as .o-rows__checkbox, so the row's first line is
 * the checkbox and the identifier at every width, never the checkbox alone.
 *
 * The label is positioned beside the cell's content, which stays in normal flow: as a flex
 * container the cell made each child a flex item, so the comma between two links became an
 * item with the flex gap on both sides ("Download cram , Download crai") and the size after
 * an artifact link wrapped to a line of its own under the label (the review of 2026-09-24).
 */

@media (max-width: 767px) {
  .o-rows,
  .o-rows tbody,
  .o-rows tr,
  .o-rows th,
  .o-rows td {
    display: block;
  }
  /* The header row leaves the page: its words are on every cell as the label, and a link in
     a header (the timings table's run headings) would otherwise be a control a finger cannot
     reach (TouchTargetTest). */
  .o-rows thead {
    display: none;
  }
  .o-rows caption {
    display: block;
  }
  .o-rows tbody tr {
    padding-block: var(--spacing-12);
    border-block-end: var(--stroke-weight-1) solid var(--border-subtle);
  }
  .o-rows tbody th,
  .o-rows tbody td {
    padding: var(--spacing-2) 0;
    border: 0;
    text-align: start;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .o-rows tbody td:empty {
    display: none;
  }
  .o-rows td[data-label] {
    --_label-width: 7rem;
    --_inline-padding: 0px;
    position: relative;
    padding-inline-start: calc(var(--_inline-padding) + var(--_label-width) + var(--spacing-12));
  }
  .o-rows td[data-label]::before {
    content: attr(data-label);
    position: absolute;
    inset-inline-start: var(--_inline-padding);
    inline-size: var(--_label-width);
    font-family: var(--font-family-body);
    font-size: var(--font-size-14);
    font-weight: var(--font-weight-400);
    color: var(--text-secondary);
  }
}

/* The checkbox in the identifier's cell, on the identifier's line, --spacing-16 before the
   identifier: on a coarse pointer the identifier link's 44px hit area (03-generic/_base.css)
   reaches 15px left of a two-digit id and the checkbox label's area ends at its box, so at a
   smaller gap one area covered the other's corner (TouchTargetTest on the runs index). */
.o-rows__checkbox {
  display: inline-block;
  vertical-align: middle;
  margin-inline-end: var(--spacing-16);
}

/* Touch. A link in a cell has a 44px hit area (03-generic/_base.css); as lines 24px apart the
   areas of two neighbouring cells covered each other, and at the container's edge a link's
   area reached past the page, so on a coarse pointer each cell of a block row has --spacing-12
   of block padding, which keeps a 44px area inside its own line, and --spacing-24 of inline
   padding: the area of the identifier link, the first thing in the row, reaches (44px - its
   width) / 2 past its start, 18.5px for a one-digit id, and .o-scroll clips what reaches past
   the table's edge (the showcase's run 21 at 390px, regenerated 2026-09-24; the gate's real
   pages have three-digit ids). */
@media (pointer: coarse) and (max-width: 767px) {
  .o-rows tbody td,
  .o-rows tbody th {
    padding: var(--spacing-12) var(--spacing-24);
  }
  .o-rows td[data-label] {
    --_inline-padding: var(--spacing-24);
  }
  /* A link in a labelled cell is a block that wraps inside the value's width and is 44px tall
     by its own padding, so a long value ("Standard with the S-04 reference set") is not
     clipped at the cell's edge, two links in one cell ("Download cram, Download crai") may
     take two lines without their hit areas meeting, and the cell needs no padding of its own
     for them; the label moves down by the link's padding to share its first line. */
  .o-rows td[data-label]:has(a[href]) {
    padding-block: var(--spacing-4);
    white-space: normal;
  }
  .o-rows td[data-label]:has(a[href])::before {
    padding-block-start: var(--spacing-12);
  }
  .o-rows td[data-label] a[href] {
    display: inline-block;
    max-width: 100%;
    padding-block: var(--spacing-12);
    white-space: normal;
  }
}
