/* FinE Retirement Planning R2 — module-scoped presentation additions.
 *
 * Loaded only by r2.html. styles/app.css is shared with the accepted R1 baseline and is
 * NOT modified by R2. Every value here resolves to a semantic token from tokens.css; no
 * literal colour is introduced.
 *
 * Purpose: at narrow widths the shared stacked-table rule converts <td> cells to blocks
 * and prefixes each with its data-label, but leaves the first column — a
 * th[scope="row"] — as a table-row-group box, so that column's label is lost. R2 tables
 * carry a row header in every table, so R2 completes the rule for row headers as well.
 */

@media (max-width: 46rem) {
  /* Stack row headers alongside the data cells. */
  table.fine-table tbody th[scope="row"] {
    display: block;
    width: 100%;
    border-bottom: none;
    padding: var(--fine-space-1) 0;
    text-align: left;
    /* The row header carries the first column's value, so it is not re-bolded. */
    font-weight: 400;
  }

  /* Emit the column label for the row header, exactly as for a data cell. */
  table.fine-table tbody th[scope="row"]::before {
    content: attr(data-label) ": ";
    font-weight: 700;
    font-size: 0.8125rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  }

  table.fine-table th.fine-num { text-align: left; font-variant-numeric: tabular-nums; }

  /* No table may produce page-level horizontal scrolling at narrow widths. */
  .fine-table-wrap { overflow-x: visible; max-width: 100%; }
  table.fine-table { table-layout: auto; word-break: break-word; }
}

@media print {
  /* Row headers return to table layout in print, where width is not constrained. */
  #print-region table th[scope="row"]::before { content: none; }
}
