.yfm table th,
.yfm table td {
    &.cell-align-top-left,
    &.cell-align-bottom-left {
        text-align: start;
    }

    &.cell-align-top-center,
    &.cell-align-center {
        text-align: center;
    }

    &.cell-align-top-right,
    &.cell-align-bottom-right {
        text-align: end;
    }

    &.cell-align-top-left,
    &.cell-align-top-center,
    &.cell-align-top-right {
        vertical-align: top;
    }

    &.cell-align-center {
        vertical-align: middle;
    }

    &.cell-align-bottom-left,
    &.cell-align-bottom-right {
        vertical-align: bottom;
    }
}

@mixin yfm-sticky-header-row {
    position: sticky;
    top: 0;
    z-index: 2;

    td,
    th {
        position: relative;
        z-index: 0;
    }

    td::before,
    th::before {
        content: '';
        background: var(--yfm-color-table-background, var(--yfm-color-table-background-private));
        position: absolute;
        inset: 0;
        z-index: -2;
    }

    td::after,
    th::after {
        content: '';
        background: var(
            --yfm-color-table-head-background,
            var(--yfm-color-table-head-background-private)
        );
        position: absolute;
        inset: 0;
        z-index: -1;
    }
}

.yfm table tr[data-header] {
    & > th,
    & > td {
        &:not([class*='cell-bg-']) {
            background: var(
                --yfm-color-table-head-background,
                var(--yfm-color-table-head-background-private)
            );
        }
    }
}

.yfm table[sticky-header] {
    position: relative;

    thead {
        @include yfm-sticky-header-row;
    }

    &:not(:has(thead)) {
        tbody > tr:first-child,
        > tr:first-child {
            @include yfm-sticky-header-row;
        }
    }

    max-height: 70vh;
}
