/**
 * Core Table
 *
 * The figure is the horizontal scrolling container.
 */

.wp-block-table {
    overflow-x: auto;
    margin-inline: 0;
    background: var(--wp--preset--color--rice-white);
    color: var(--wp--preset--color--rich-black);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
}

/**
 * Keep the table at least as wide as its container, but allow its columns to
 * make it wider. This creates horizontal scrolling instead of compressed
 * mobile columns.
 */

.wp-block-table table {
    width: max-content !important;
    min-width: 100%;
    margin: 0;
    border-spacing: 0;
    border-collapse: collapse;
    table-layout: auto;
    background: var(--wp--preset--color--rice-white);
    color: var(--wp--preset--color--rich-black);
}

.wp-block-table thead {
    border-bottom: none;
}

/**
 * Cells.
 */

.wp-block-table th,
.wp-block-table td {
    box-sizing: border-box;
    min-width: 10rem;
    max-width: 25vw;
    padding: 0.75rem 1rem;
    border: 1px solid var(--wp--preset--color--mid-gray);
    text-align: left;
    vertical-align: top;
    background: var(--wp--preset--color--rice-white);
    color: var(--wp--preset--color--rich-black);
}

/**
 * Header cells.
 */

.wp-block-table th {
    font-weight: 700;
    background: var(--wp--preset--color--light-gray);
}

/**
 * Explicitly prevent alignment settings inherited from core or theme styles.
 */

.wp-block-table thead,
.wp-block-table tbody,
.wp-block-table tfoot,
.wp-block-table tr,
.wp-block-table th,
.wp-block-table td {
    text-align: left;
}

/**
 * Core may output the footer using td rather than th.
 */

.wp-block-table tfoot td {
    background: var(--wp--preset--color--rice-white);
    color: var(--wp--preset--color--rich-black);
}

/**
 * First column labels block style.
 */

.wp-block-table.is-style-first-column-labels tbody td:first-child,
.wp-block-table.is-style-first-column-labels tfoot td:first-child {
  background: var(--wp--preset--color--light-gray);
}

/**
 * Sticky first column.
 *
 * Apply position to both th and td so the corner/header cell also stays fixed.
 */

.wp-block-table.is-style-first-column-labels tr > :first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background-clip: padding-box;
  max-width: 25vw;
}

/**
 * The header must sit over sticky body cells while scrolling vertically.
 */

.wp-block-table.is-style-first-column-labels thead th:first-child {
    z-index: 4;
    background: var(--wp--preset--color--light-gray);
}

/**
 * Highlighted columns.
 *
 * Increase the generated range if your tables can contain more than
 * 20 columns.
 */

.wp-block-table.is-column-highlighted-1 th:nth-child(1),
.wp-block-table.is-column-highlighted-2 th:nth-child(2),
.wp-block-table.is-column-highlighted-3 th:nth-child(3),
.wp-block-table.is-column-highlighted-4 th:nth-child(4),
.wp-block-table.is-column-highlighted-5 th:nth-child(5),
.wp-block-table.is-column-highlighted-6 th:nth-child(6),
.wp-block-table.is-column-highlighted-7 th:nth-child(7),
.wp-block-table.is-column-highlighted-8 th:nth-child(8),
.wp-block-table.is-column-highlighted-9 th:nth-child(9),
.wp-block-table.is-column-highlighted-10 th:nth-child(10),
.wp-block-table.is-column-highlighted-11 th:nth-child(11),
.wp-block-table.is-column-highlighted-12 th:nth-child(12) {
    background: var(--wp--preset--color--rich-black);
    color: var(--wp--preset--color--rice-white);
}

/**
 * Highlighting column one should also override the sticky corner cell.
 */

.wp-block-table.is-style-first-column-labels.is-column-highlighted-1
    thead
    th:first-child {
    background: var(--wp--preset--color--dark-gray);
    color: var(--wp--preset--color--rice-white);
}

/**
 * Mobile/tablet behavior.
 */
@media (max-width: 781px) {

    .wp-block-table {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        touch-action: pan-x pan-y;
    }

    .wp-block-table.has-more-than-two-columns {
        width: calc(100% + var(--wp--style--root--padding-right));
        max-width: calc(100% + var(--wp--style--root--padding-right));
    }

    .wp-block-table table {
        width: max-content;
        min-width: 100%;
    }
}
