/* Table (T19, spec new-blocks/table.md). Tokens only; mobile first.
   Prototype ("What to expect", "Side by side"): heading 34–52 px signature, column headings 14 px bold
   in blue over a Deep Blue rule, rows 16 px with hairlines, row labels 500 in the heading colour,
   empty cells "—" in grey; first column minmax(160px, 1.2fr), the others share the rest.
   Phones: Stack turns each row into a card ("Column: value" pairs); Scroll keeps the grid in its own
   frame with the first column fixed and a "Swipe to see more" cue, shown only while the table is wider
   than its frame (container query on the frame's width per column count: 150 px a column). */

.data-table__head { max-width: 820px; margin-bottom: var(--space-7); }
.data-table__heading { margin: 0; }
.data-table__intro {
  margin: var(--space-4) 0 0;
  font-size: var(--fs-body-lg);
  font-weight: var(--fw-light);
  line-height: 1.44;
  color: var(--color-text);
}

.data-table__table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-body-md);
  line-height: 1.45;
}

.data-table__table th,
.data-table__table td {
  padding: var(--space-4) var(--space-5) var(--space-4) 0;
  text-align: left;
  vertical-align: top;
  border-bottom: var(--border-width) solid var(--color-hairline);
  overflow-wrap: break-word;
}
.data-table__table th:last-child,
.data-table__table td:last-child { padding-right: 0; }

.data-table__table thead th {
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-bold);
  line-height: var(--lh-label);
  letter-spacing: var(--ls-label);
  color: var(--color-eyebrow);
  border-bottom-color: var(--color-heading);
  vertical-align: bottom;
}
.data-table__table thead th:first-child { width: 28%; min-width: 160px; }

.data-table__table tbody th {
  font-weight: var(--fw-medium);
  color: var(--color-heading);
}
.data-table__table td { color: var(--color-text); }
.data-table__empty { color: var(--color-muted); }

.data-table__note {
  margin: var(--space-5) 0 0;
  max-width: var(--container-text);
  font-size: var(--fs-body-sm);
  line-height: var(--lh-body-tight);
  color: var(--color-muted);
}

/* ── Scroll sideways ─────────────────────────────────────────────────── */
.data-table__scroller { container-type: inline-size; }

.data-table__frame { position: relative; }   /* keeps the visually hidden texts inside the frame's clip */
.data-table--scroll .data-table__frame {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
}
.data-table--scroll .data-table__table { min-width: 600px; }
.data-table--cols-2.data-table--scroll .data-table__table { min-width: 300px; }
.data-table--cols-3.data-table--scroll .data-table__table { min-width: 450px; }
.data-table--cols-4.data-table--scroll .data-table__table { min-width: 600px; }
.data-table--cols-5.data-table--scroll .data-table__table { min-width: 750px; }

/* The first column stays put while the rest scrolls under it. */
.data-table--scroll th:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--theme-bg, var(--color-page));
}
/* Phones: the fixed column takes at most 40% of the frame (cqi = the scroller's width), so one or two data
   columns stay in view beside it; long row labels wrap. */
@media (max-width: 599px) {
  .data-table--scroll .data-table__table thead th:first-child,
  .data-table--scroll .data-table__table tbody th:first-child {
    width: 40cqi;
    min-width: 0;
    max-width: 40cqi;
  }
}
/* A divider on the fixed column only where the table can scroll (prototype: no divider on wide screens). */
@media (max-width: 1023px) {
  .data-table--scroll th:first-child { box-shadow: inset calc(-1 * var(--border-width)) 0 0 var(--color-hairline); }
}
.data-table--scroll .data-table__table thead th:first-child { min-width: 140px; }

.data-table__cue {
  display: none;
  margin: var(--space-3) 0 0;
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-bold);
  line-height: var(--lh-label);
  color: var(--color-eyebrow);
}
.data-table__cue-arrow { display: inline-block; }

@container (max-width: 299px) { .data-table--cols-2 .data-table__cue { display: block; } }
@container (max-width: 449px) { .data-table--cols-3 .data-table__cue { display: block; } }
@container (max-width: 599px) { .data-table--cols-4 .data-table__cue { display: block; } }
@container (max-width: 749px) { .data-table--cols-5 .data-table__cue { display: block; } }

/* ── Stack each row (phones) ─────────────────────────────────────────── */
@media (max-width: 599px) {
  .data-table--stack .data-table__table,
  .data-table--stack .data-table__table tbody,
  .data-table--stack .data-table__table tr,
  .data-table--stack .data-table__table th,
  .data-table--stack .data-table__table td {
    display: block;
    width: auto;
    min-width: 0;
  }
  /* Column headings are repeated in every card; the header row stays for screen readers only. */
  .data-table--stack .data-table__table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .data-table--stack .data-table__table tr {
    margin: 0 0 var(--space-3);
    padding: var(--space-4) var(--space-5);
    border: var(--border-width) solid var(--color-hairline);
    border-radius: var(--radius-media);
  }
  .data-table--stack .data-table__table tbody th {
    padding: 0 0 var(--space-2);
    border: 0;
    font-size: var(--fs-h4);
  }
  .data-table--stack .data-table__table td {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    gap: var(--space-3);
    padding: var(--space-2) 0;
    border-bottom: 0;
    border-top: var(--border-width) solid var(--color-hairline);
  }
  .data-table--stack .data-table__table td::before {
    content: attr(data-label) ":";
    font-weight: var(--fw-bold);
    color: var(--color-heading);
  }
  .data-table--stack .data-table__table td[data-label=""] { display: block; }
  .data-table--stack .data-table__table td[data-label=""]::before { content: none; }
}
