/* ==========================================================================
   CENTAURI 0.7.0 — the table layer (authored; copied through)
   GENERATED by scripts/generate.mjs from scripts/tokens.source.mjs. Do not edit.
   A local edit is not a disagreement to adjudicate; it is a build that no
   longer reproduces, and scripts/check.mjs will say so.
   ========================================================================== */
/* -----------------------------------------------------------------------------
   CENTAURI — the table layer. The responsive dense table of references/the-table.md,
   shipped (ADR-010 §6). The first-class object of Centauri Console.

   What twelve systems specify for the desktop and none publishes for a phone:

     - COLUMN PRIORITY IS DATA. Each <th>/<td> carries data-priority="identity"
       | "primary" | "secondary". Secondary columns leave first as the container
       narrows; the identity column is never dropped and never truncated.
     - A ROW BECOMES A RECORD under the reflow width — a labeled definition list
       with the identity cell as its heading and every surviving field as a
       label/value pair. Same data, same tokens, chosen by container width, not
       by a separate mobile route. All fields return in record view: a phone has
       vertical room, and a field hidden on a phone is a function lost.
     - NO HORIZONTAL SCROLL is the default. A spreadsheet-shaped product
       declares its exception with data-scroll-x="declared" and a stated reason.
     - THE HEADER OWNS ITS SCROLL. A sticky header only works when the vertical
       scroll lives in the container it sticks to, so a table that wants one
       sets data-scroll and a max block size, and the wrapper scrolls.
     - Density is inherited from the profile: a console table is 32px rows of
       13px values, a field table 48px rows of 15px values, and on a coarse
       pointer both get 44px hit areas without changing a visual dimension.
     - No zebra (Carbon: it "fights the layer model"), no card around the table
       (it "takes width from the only thing on the page that needs it").
     - Zero, null and "not yet" are three different states, and two of them
       are rendered here so a 0 is never a lie.

   Markup:

     <div class="centauri-table" data-scroll style="--centauri-table-max: 60dvh">
       <table>
         <caption class="centauri-vh">Departures</caption>
         <thead><tr>
           <th scope="col" data-priority="identity" aria-sort="ascending">Service</th>
           <th scope="col" data-priority="primary" data-type="number">Delay</th>
           <th scope="col" data-priority="secondary">Platform</th>
         </tr></thead>
         <tbody><tr>
           <th scope="row" data-priority="identity" data-label="Service">9:04 to Fairhaven</th>
           <td data-priority="primary" data-type="number" data-label="Delay">
             <span class="centauri-dimension" style="--value: 6; --domain: 20"></span> 6 min
           </td>
           <td data-priority="secondary" data-label="Platform">4</td>
         </tr></tbody>
       </table>
     </div>
   -------------------------------------------------------------------------- */

.centauri-table {
  container-type: inline-size;
  container-name: centauri-table;
  inline-size: 100%;
}
/* the wrapper owns the vertical scroll, so the header has something to stick to */
.centauri-table[data-scroll] {
  max-block-size: var(--centauri-table-max, 70dvh);
  overflow-y: auto;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
}
/* the declared exception, and only that */
.centauri-table[data-scroll-x="declared"] { overflow-x: auto; }
.centauri-table[data-scroll-x="declared"] table { min-inline-size: max-content; }

.centauri-table table {
  inline-size: 100%;
  border-collapse: separate; border-spacing: 0;
  font-size: var(--text-datum); line-height: var(--text-datum--line-height);
  color: var(--color-prose);
}
.centauri-table caption { text-align: start; }

/* INVARIANT 8 — the header is the micro label */
.centauri-table thead th {
  position: sticky; inset-block-start: 0; z-index: 1;
  background: var(--color-surface);
  font-family: var(--font-mono);
  font-size: var(--text-micro); line-height: var(--text-micro--line-height);
  letter-spacing: 0.14em; text-transform: uppercase; font-weight: 500;
  color: var(--color-muted);
  text-align: start;
  padding: var(--centauri-scaled-cell-y) var(--centauri-scaled-cell-x);
  border-block-end: var(--centauri-static-stroke-edge) solid var(--color-edge);
  white-space: nowrap;
}
.centauri-table tbody th, .centauri-table td {
  padding: var(--centauri-scaled-cell-y) var(--centauri-scaled-cell-x);
  block-size: var(--centauri-scaled-row-height);
  vertical-align: middle;
  text-align: start;
  font-weight: 400;
  /* INVARIANT 5 — a hairline separates rows; nothing boxes them */
  border-block-end: var(--centauri-static-stroke-hairline) solid var(--color-hairline);
}
.centauri-table tbody th[data-priority="identity"] { color: var(--color-strong); font-weight: 500; white-space: nowrap; }

/* INVARIANT 4 — tabular numerals per cell, values right-aligned, mono is the record */
.centauri-table [data-type="number"], .centauri-table [data-type="time"], .centauri-table [data-type="id"] {
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -0.01em;
}
.centauri-table [data-type="number"] { text-align: end; }
.centauri-table [data-type="id"], .centauri-table [data-type="time"] { font-family: var(--font-mono); }
.centauri-table thead [data-type="number"] { text-align: end; }

/* the dimension line inside a cell draws to the cell's stated domain */
.centauri-table td .centauri-dimension { --centauri-dimension-length: 6rem; margin-inline-end: var(--centauri-scaled-2); }

/* SORT — the tick of selection under the sorted column head */
.centauri-table th[aria-sort] { cursor: pointer; }
.centauri-table th[aria-sort] > button {
  border: 0; padding: 0; background: transparent; cursor: pointer;
  font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit;
  display: inline-flex; align-items: center; min-block-size: var(--centauri-static-target-min);
}
.centauri-table th[aria-sort]:not([aria-sort="none"]) { color: var(--color-strong); }
.centauri-table th[aria-sort]:not([aria-sort="none"])::after {
  content: "";
  display: block;
  inline-size: calc(var(--centauri-static-tick-length) * 2);
  block-size: 2px;
  margin-block-start: var(--centauri-scaled-0);
  background: var(--color-accent);
}
.centauri-table th[aria-sort="descending"]::after { margin-inline-start: auto; }

/* ROW STATES — the state layer as a background, because a <tr> is not a
   reliable positioning context for an overlay */
.centauri-table tbody tr:hover > * {
  background: color-mix(in oklab, currentColor calc(var(--centauri-static-state-hover) * 100%), transparent);
}
.centauri-table tbody tr[aria-selected="true"] > * {
  background: color-mix(in oklab, currentColor calc(var(--centauri-static-state-selected) * 100%), transparent);
}
.centauri-table tbody tr[aria-selected="true"] th[data-priority="identity"] {
  box-shadow: inset 2px 0 0 var(--color-accent);
}

/* SELECTION — the column that says which rows an action is about. It carries no
   data, so it takes no width from the data; the hit area comes from the touch
   mechanism rather than from a bigger box. */
.centauri-table th.gw-table__select,
.centauri-table td.gw-table__select {
  inline-size: var(--centauri-scaled-6);
  padding-inline: var(--centauri-scaled-2);
  text-align: center;
}
/* The control itself, because a browser's default checkbox is 13x13 and SC
   2.5.8 wants 24. Groundwork emits the input and cannot know this system's
   target token -- which is the point of the boundary: the presentation owns
   what a control looks like, and its hit area is part of that. On a coarse
   pointer the touch mechanism expands it again without moving this dimension. */
.centauri-table .gw-table__select input[type="checkbox"] {
  inline-size: var(--centauri-static-target-min);
  block-size: var(--centauri-static-target-min);
  margin: 0;
  /* A 24px box on the text baseline leaves the line's descent below it, and
     the cell's `vertical-align: middle` centers the LINE, not the box: measured
     2026-10-09, the box sat 3px above the row's middle beside text that did
     not. Middle puts the box's center on the line's. */
  vertical-align: middle;
}

/* ABSENCE — two of the three states, rendered so a 0 is never a lie.
   null: a dash. not yet: a hollow, dashed cell. Zero is written as 0. */
.centauri-table [data-absent="null"]::after { content: "—"; color: var(--color-subtle); }
.centauri-table [data-absent="pending"]::after {
  content: "";
  display: inline-block; vertical-align: middle;
  inline-size: 2.5ch; block-size: 1em;
  border: var(--centauri-static-stroke-hairline) dashed var(--color-edge);
  border-radius: var(--radius-chip);
}

/* ---- no column leaves without a way back ------------------------------------ */
/* There used to be a rule here dropping `[data-priority="secondary"]` at a
   720px container, while the record layout restored those fields at 560px.
   Between those two widths the data was gone and nothing on screen offered it
   back — reported 2026-09-10, reproduced at a 900px viewport where the demo's
   table sat at 620px and Service, Line and Last 12 hours were simply absent.
   A field may leave the columns only by entering the record, which restores
   every one of them, so the drop is gone rather than retuned.

   The table therefore keeps every column and scrolls inside its own box until
   the record takes over. That is allowed and it is the honest trade: SC 1.4.10
   excepts content requiring a two-dimensional layout and Understanding 1.4.10
   names data tables, and a scrollbar is discoverable in a way that a missing
   column is not.

   `data-priority` still means something — it orders the record and it is what a
   column chooser would read. The chooser is the missing piece, and it is a
   control rather than a stylesheet: `⟨sap-fiori:patterns.md⟩` is right that the
   column set is "a decision, and a saved one". See references/roadmap.md. */

/* ---- the record: the row becomes a labeled definition list ------------------ */
/* Records flow with the page: a scroll box inside the page's scroll is a trap
   for a thumb, and the header it existed to pin is out of the layout here. A
   container query cannot reach its own container, so this one is the phone's
   media query rather than the table's width. */
@media (max-width: 599.98px) {
  .centauri-table[data-scroll]:not([data-scroll-x="declared"]) { max-block-size: none; overflow: visible; }
}

/* A control at the edge of the scroll box had its focus ring clipped by the box
   — the same defect the nav bar had, and found the same way, by measuring the
   rendered ring rather than reading the rule. The ring goes inside. SC 1.4.11. */
.centauri-table :focus-visible {
  outline-offset: calc(-1 * var(--centauri-static-focus-offset));
}
/* 600px of CONTAINER, not 560. The media query above takes the scroll box away
   at 599.98px of VIEWPORT, and those are two different boxes: at a 599px
   viewport this container measures 575px, so a 560px threshold left a band with
   no scroll box and no record layout — seven columns and a document 76px wider
   than the phone. 600 is above any container a 599.98px viewport can produce,
   so the two hand over to each other with nothing in between. Any change to one
   number is a change to both. */
@container centauri-table (max-width: 600px) {
  /* THE SORT BAR. The first fix here hid the whole header and revealed it on
     `:focus-within`, like a skip link. That answered the keyboard — a control
     focusable inside a 1px box, SC 2.4.11 — and left a touch user with no
     visible way to sort at all, which was reported on 2026-09-10 and is now
     `control-lost-narrowing` in screen_probe.py: 9 controls in the tab order,
     8 on screen, which is exactly why `parity_check.py` counted parity.

     So the header stays in the layout and becomes a bar of the controls it
     holds. What hides is the column head that is ONLY a label, because the
     record repeats every label beside its own value two rules below — the
     labels were never the thing worth revealing. */
  .centauri-table:not([data-scroll-x="declared"]) thead { display: block; }
  .centauri-table:not([data-scroll-x="declared"]) thead tr {
    display: flex; flex-wrap: wrap; align-items: center;
    column-gap: var(--centauri-scaled-4); row-gap: var(--centauri-scaled-1);
    padding-block-end: var(--centauri-scaled-2);
    border-block-end: var(--centauri-static-stroke-hairline) solid var(--color-hairline);
  }
  .centauri-table:not([data-scroll-x="declared"]) thead th {
    display: block; position: static;
    padding: 0; border: 0; block-size: auto;
  }
  /* A column head with no control in it is a label and nothing else here. It
     stays in the accessibility tree — `scope="col"` is what associates it with
     every cell below — and leaves the layout. */
  .centauri-table:not([data-scroll-x="declared"]) thead th:not(:has(button)):not(:has(a)) {
    position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
  /* ...and if one ever does become focusable, it comes back rather than
     repeating the defect this block was written to fix. SC 2.4.11. */
  .centauri-table:not([data-scroll-x="declared"]) thead th:focus-within {
    position: static; inline-size: auto; block-size: auto;
    overflow: visible; clip-path: none; white-space: normal;
  }
  .centauri-table:not([data-scroll-x="declared"]) table,
  .centauri-table:not([data-scroll-x="declared"]) tbody { display: block; }
  .centauri-table:not([data-scroll-x="declared"]) tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    row-gap: var(--centauri-scaled-1);
    padding-block: var(--centauri-scaled-3);
    border-block-end: var(--centauri-static-stroke-hairline) solid var(--color-hairline);
  }
  .centauri-table:not([data-scroll-x="declared"]) tbody th,
  .centauri-table:not([data-scroll-x="declared"]) td {
    display: block; block-size: auto; padding: 0; border: 0;
  }
  /* every field returns in the record: secondary included */
  .centauri-table:not([data-scroll-x="declared"]) td[data-priority="secondary"] { display: flex; }
  /* the identity cell is the record's heading, across both columns */
  /* In the record, the checkbox belongs beside the heading it chooses. Left as
     its own stacked row it would be a control with no subject, above a label
     the identity cell already carries. */
  .centauri-table:not([data-scroll-x="declared"]) td.gw-table__select {
    display: inline-flex; inline-size: auto;
    padding: 0; margin-inline-end: var(--centauri-scaled-3);
    float: inline-start;
  }
  .centauri-table:not([data-scroll-x="declared"]) td.gw-table__select::before { content: none; }
  .centauri-table:not([data-scroll-x="declared"]) tbody th[data-priority="identity"] {
    font-size: var(--text-body); line-height: var(--text-body--line-height);
    margin-block-end: var(--centauri-scaled-1);
    /* `nowrap` is right for a COLUMN, where the identity has to stay on the
       row it names, and wrong for a HEADING in a one-column grid: a long
       destination then pushes the whole document wider than the phone.
       Measured 2026-09-10 — one 54-character destination took a 375px layout
       to 388px. `anywhere` rather than `break-word` because CSS Text 3 §5.4
       counts only what `anywhere` introduces when computing min-content, and
       min-content is what the grid track is sized from. */
    white-space: normal;
    overflow-wrap: anywhere;
  }
  /* every other cell is one line: the column head as a label, then the value
     and whatever was drawn beside it, in the order the cell had them.
     The label and the value share a BASELINE, not a center. Centering an 11px
     label against a 13px value put the two baselines 3.5px apart on every
     row, and a label wrapped to two lines left its value between them, the
     second line reading as a label for nothing: measured 2026-10-09 across two
     products' record tables, -19.4px to +17px, 0 on every row once aligned. */
  .centauri-table:not([data-scroll-x="declared"]) td {
    display: flex; flex-wrap: wrap; align-items: baseline;
    column-gap: var(--centauri-scaled-3);
  }
  .centauri-table:not([data-scroll-x="declared"]) td::before {
    content: attr(data-label);
    flex: 0 0 var(--centauri-record-label, 12ch);
    font-family: var(--font-mono);
    font-size: var(--text-micro); line-height: var(--text-micro--line-height);
    letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--color-muted);
    /* A label is one word and must stay one word. Measured 2026-09-10: an
       eleven-character label rendered as `DESTINATI` / `ON`, which reads as two
       words when neither is one -- worse than the overflow it was avoiding,
       because 0.14em of tracking on eleven caps needs more than 12ch and the
       box does not shrink. A label wider than the column now runs into the gap
       instead of fragmenting, and `--centauri-record-label` is the knob for a
       product whose labels are genuinely longer. */
    overflow-wrap: normal;
    word-break: keep-all;
    hyphens: none;
    /* The label wraps between its words even where the value may not. A pseudo
       element inherits `white-space` from its cell, so a product that keeps a
       figure on one line (`nowrap` on its numbers) kept the label on one line
       too, and the label's min-content grew past 12ch: a REORDER POINT value
       sat 26.6px right of every other value in its record. */
    white-space: normal;
  }
  /* A cell whose column has no head has nothing to be called, and reserving
     12ch for the name of an attribute that does not exist indents the value
     under every labeled row above it. Found 2026-09-15 in a console's invoice
     table, where the Subtotal row -- a figures column with a blank head -- sat
     12ch in from the record's own edge on a phone and read as a nested value.
     Both spellings, because a template that interpolates a missing head emits
     the empty attribute rather than omitting it. */
  .centauri-table:not([data-scroll-x="declared"]) td:not([data-label])::before,
  .centauri-table:not([data-scroll-x="declared"]) td[data-label=""]::before { content: none; }
  .centauri-table:not([data-scroll-x="declared"]) td[data-type="number"] { text-align: start; }
  .centauri-table:not([data-scroll-x="declared"]) td .centauri-dimension { --centauri-dimension-length: 6rem; }
  .centauri-table:not([data-scroll-x="declared"]) tbody tr[aria-selected="true"] th[data-priority="identity"] { box-shadow: none; }
  .centauri-table:not([data-scroll-x="declared"]) tbody tr[aria-selected="true"] { box-shadow: inset 2px 0 0 var(--color-accent); padding-inline-start: var(--centauri-scaled-3); }
}
