.tb-pagination {
    margin-top: theme('margin.6');
    font-size: theme('fontSize.sm');
    line-height: 1;

    @screen sm {
        font-size: theme('fontSize.base');
        display: flex;
        align-items: center;
    }
}

.tb-pagination__list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline; // Set all items on the text baseline.
    overflow-x: auto;
    margin: 0;
    padding: 0;
    width: 100%;

    @screen sm {
        display: inline-flex;
        width: auto;
    }
}

.tb-pagination__item-group {
    overflow: hidden;
    border: 1px solid theme('colors.gray.400');
    border-radius: theme('borderRadius.sm');

    ul {
        display: flex;
        list-style: none;
        margin: 0;
        padding: 0;
    }

    + .tb-pagination__item-group {
        border-left: 0;
    }
}

.tb-pagination__item-group--first.tb-pagination__item-group--connect,
.tb-pagination__item-group--end {
    border-radius: theme('borderRadius.sm') 0 0 theme('borderRadius.sm');
}

.tb-pagination__item-group--start {
    border-radius: 0 theme('borderRadius.sm') theme('borderRadius.sm') 0;
    border-left: 0;
}

.tb-pagination__item-group--last.tb-pagination__item-group--connect {
    border-radius: 0 theme('borderRadius.sm') theme('borderRadius.sm') 0;
}

.tb-pagination__item-group--full {
    border-radius: 0;
}

.tb-pagination__item {
    margin: 0;

    &:hover,
    &:focus {
        border-color: theme('colors.primary.800');
    }

    &:not(:first-child) .tb-pagination__link {
        border-left: 1px solid theme('colors.gray.400');
    }
}

.tb-pagination__link {
    text-align: center;
    text-decoration: none;
    display: block;
    padding: theme('padding.3') theme('padding.4');
    color: theme('colors.gray.800');

    &[aria-current],
    &:hover,
    &:focus {
        background: theme('colors.primary.500');
        color: theme('colors.white');
    }

    &:focus {
        outline: theme('borderRadius.sm') solid theme('colors.blue-light');
        outline-offset: -1px;
    }

    &:active {
        background: theme('colors.primary.800');
    }

    &[disabled] {
        cursor: not-allowed;
        color: theme('colors.gray.500');

        &:hover,
        &:focus,
        &:active {
            background: theme('colors.white');
            color: theme('colors.gray.500');
        }
    }

    // Prevent hover effects on devices not supporting :hover
    @media (hover: none) {
        &:hover {
            background: transparent;
            color: theme('colors.gray.800');
        }
    }
}

.tb-pagination__link--prev {
    border-radius: theme('borderRadius.sm') 0 0 theme('borderRadius.sm');
}

.tb-pagination__link--next {
    border-radius: 0 theme('borderRadius.sm') theme('borderRadius.sm') 0;
}

.tb-pagination__divider {
    font-size: .125rem;
    text-align: center;
    padding: theme('padding.2') 0;
    color: theme('colors.gray.500');

    @media screen and (min-width: 360px) {
        padding: theme('padding.2');
    }

    @screen sm {
        font-size: theme('fontSize.base');
        padding: theme('padding.2') theme('padding.4');
    }
}

// Buttons stand below the pagination on narrow viewports.
.tb-pagination__navigation {
    list-style: none;
    display: inline-flex;
    border: 1px solid theme('colors.gray.400');
    margin-top: theme('margin.4');
    border-radius: theme('borderRadius.sm');

    .tb-pagination__link {
        border: 0;
        padding: .6875rem .75rem;
    }

    // Scale the icon so the height matches with other pagination items.
    .tb-pagination__icon {
        height: .875rem;
        width: .875rem;
    }

    @screen sm {
        margin-top: 0;
        margin-left: theme('margin.6');

        .tb-pagination__icon {
            height: 1rem;
            width: 1rem;
        }
    }
}
