/* Keep horizontal pinning independent of vertical header pinning.
   Collapsed borders and nested sticky table cells are unreliable in WebKit. */
.table-shell > table {
  border-collapse: separate;
  border-spacing: 0;
}

/* Ordinary headers scroll with their row; body row labels must never stick
   to the top. Existing, more specific left-pinned cell rules stay in effect.
   Bounded game / connected tables pin their whole thead, not each child. */
.table-shell > table > thead > tr > th,
.table-shell > table > tbody > tr > th {
  position: static;
  top: auto;
}

.table-shell > table > thead .name-head {
  position: sticky;
  left: 0;
  top: auto;
}

/* Keep the material and its text in the same painting layer instead of
   relying on a separate row-group background in mobile scroll containers. */
.table-shell > table:not(.compare-table) thead th {
  background-color: #102d48;
  background-image: var(--table-material-atlas);
  background-size: 200% 200%;
  background-position: 0 0;
  background-repeat: no-repeat;
  color: #f5faff;
}

/* Keep fixed columns in their actual rows on iOS. Native sticky table-cell
   positioning is not used on narrow/touch screens; horizontal translation is
   bounded to the original table. Desktop sticky behavior is unchanged. */
.table-shell > table[data-mobile-table-pins] > :is(thead, tbody, tfoot) > tr > :is(th, td)[data-table-pin-left] {
  position: relative;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  transform: translateX(max(0px, min(var(--table-pin-limit, 0px), calc(var(--table-scroll-x, 0px) + var(--table-pin-left, 0px) - var(--table-pin-origin, 0px)))));
  z-index: 2;
}
.table-shell > table[data-mobile-table-pins][data-mobile-pin-measuring] > :is(thead, tbody, tfoot) > tr > :is(th, td)[data-table-pin-left] {
  transform: none;
}
.table-shell > table[data-mobile-table-pins]:not(.compare-table) > tbody > tr > :is(th, td)[data-table-pin-left] {
  background-color: var(--table-row-color, #fafcfe);
  background-image: var(--table-material-atlas);
  background-size: 200% 200%;
  background-position: var(--table-row-position, 100% 0%);
  background-repeat: no-repeat;
}
.table-shell > table[data-mobile-table-pins] > thead > tr > th[data-table-pin-left] {
  z-index: 7;
}
