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

    @screen sm {
        font-size: config('textSizes.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 config('colors.grey-light');
    border-radius: config('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: config('borderRadius.sm') 0 0 config('borderRadius.sm');
}

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

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

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

.tb-pagination__item {
    margin: 0;

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

    &:not(:first-child) .tb-pagination__link {
        border-left: 1px solid config('colors.grey-light');
    }
}

.tb-pagination__link {
    text-align: center;
    text-decoration: none;
    display: block;
    padding: config('padding.3') config('padding.4');
    color: config('colors.grey-darker');

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

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

    &:active {
        background: config('colors.primary-darker');
    }

    &[disabled] {
        cursor: not-allowed;
        color: config('colors.grey');

        &:hover,
        &:focus,
        &:active {
            background: config('colors.white');
            color: config('colors.grey');
        }
    }

    // Prevent hover effects on devices not supporting :hover
    @media (hover: none) {
        &:hover {
            background: transparent;
            color: config('colors.grey-darker');
        }
    }
}

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

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

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

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

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

// Buttons stand below the pagination on narrow viewports.
.tb-pagination__navigation {
    list-style: none;
    display: inline-flex;
    border: 1px solid config('colors.grey-light');
    margin-top: config('margin.4');
    border-radius: config('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: config('margin.6');

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