.khgb {
    /* Theme colours: .custom-btn background and its hover */
    --khgb-accent: #fbb76f;
    --khgb-accent-dark: #fa980a;
    --khgb-text: #272731;
    --khgb-muted: #777;
    --khgb-card: #f4f4f4;

    flex: 0 0 100%;
    width: 100%;
    margin: 0 0 24px;
    padding: 20px;
    background: #fff;
    border-radius: 16px;
    color: var(--khgb-text);
    text-align: left;
}

/* Same font as theme headings (product title, "APRAŠYMAS") */
.khgb__heading {
    margin-bottom: 14px;
    font-family: 'Crushed', 'Montserrat', sans-serif;
    font-size: 28px;
    font-weight: 400;
    line-height: 1.1;
    text-transform: uppercase;
}

.khgb-group + .khgb-group {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e5e5e5;
}

.khgb-group__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.khgb-group__title {
    font-size: 15px;
    font-weight: 600;
}

.khgb-group__count {
    flex: 0 0 auto;
    padding: 2px 10px;
    border-radius: 20px;
    background: var(--khgb-card);
    font-size: 13px;
    white-space: nowrap;
}

.khgb-group.is-complete .khgb-group__count {
    background: var(--khgb-accent-dark);
    color: #fff;
}

/* All choices in one row that scrolls sideways, part of the next card stays visible as a hint */
.khgb-row {
    --khgb-fade-left: 0px;
    --khgb-fade-right: 0px;

    position: relative;
}

.khgb-grid {
    --khgb-visible: 4.4;

    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

/* Navigation is done with arrows or swipe, like on broliumedus.lt */
.khgb-grid::-webkit-scrollbar {
    display: none;
}

.khgb-grid > .khgb-card {
    flex: 0 0 calc((100% - 10px * (var(--khgb-visible) - 1)) / var(--khgb-visible));
    scroll-snap-align: start;
}

/* Cut off cards fade out at the edge where more cards are hidden (classes set by picker.js) */

.khgb-row.has-prev {
    --khgb-fade-left: 60px;
}

.khgb-row.has-next {
    --khgb-fade-right: 80px;
}

.khgb-row .khgb-grid {
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--khgb-fade-left), #000 calc(100% - var(--khgb-fade-right)), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, #000 var(--khgb-fade-left), #000 calc(100% - var(--khgb-fade-right)), transparent 100%);
}

.khgb-arrow {
    position: absolute;
    top: 50%;
    z-index: 2;
    width: 34px;
    height: 34px;
    margin-top: -17px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
    color: var(--khgb-text);
    font-size: 20px;
    line-height: 34px;
    cursor: pointer;
    user-select: none;
}

.khgb-arrow--prev {
    left: -12px;
}

.khgb-arrow--next {
    right: -12px;
}

.khgb-arrow[hidden] {
    display: none;
}

.khgb-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 8px;
    border: 2px solid transparent;
    border-radius: 12px;
    background: var(--khgb-card);
    text-align: center;
    cursor: pointer;
    user-select: none;
    transition: border-color .15s, background-color .15s;
}

.khgb-card:hover,
.khgb-card:focus-visible {
    border-color: var(--khgb-accent);
    outline: none;
}

.khgb-card.is-selected {
    border-color: var(--khgb-accent-dark);
    background: #fff3e0;
}

.khgb-group.is-full .khgb-card:not(.is-selected):not(.is-disabled):not(:hover) {
    opacity: .75;
}

.khgb-card.is-disabled {
    cursor: not-allowed;
    opacity: .45;
    filter: grayscale(1);
}

.khgb-card__badge {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--khgb-accent-dark);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    line-height: 20px;
}

.khgb-card__badge:empty {
    display: none;
}

.khgb-card__image {
    display: block;
    width: 100%;
    margin-bottom: 6px;
}

.khgb .khgb-card__img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 80px;
    margin: 0 auto;
    object-fit: contain;
}

.khgb-card__name {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
}

.khgb-card__sub,
.khgb-card__stock {
    margin-top: 2px;
    color: var(--khgb-muted);
    font-size: 11px;
    line-height: 1.25;
}

.khgb-card__stock {
    color: #b00020;
}

.khgb-qty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: auto;
    padding-top: 8px;
}

.khgb .khgb-qty__btn {
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: var(--khgb-text);
    font-size: 16px;
    line-height: 26px;
    cursor: pointer;
}

.khgb .khgb-qty__btn:disabled {
    cursor: default;
    opacity: .35;
}

.khgb .khgb-qty__input {
    width: 34px;
    height: 26px;
    padding: 0;
    border: 0;
    background: transparent;
    font-size: 14px;
    text-align: center;
    -moz-appearance: textfield;
}

.khgb .khgb-qty__input::-webkit-outer-spin-button,
.khgb .khgb-qty__input::-webkit-inner-spin-button {
    margin: 0;
    -webkit-appearance: none;
}

/* Single choice group (e.g. chocolate) works like radio buttons, amount controls are not needed */
.khgb-group--single .khgb-qty {
    display: none;
}

.khgb__error {
    margin-top: 16px;
    padding: 10px 14px;
    border-radius: 8px;
    background: #fdecee;
    color: #b00020;
    font-size: 14px;
}

.khgb__error[hidden] {
    display: none;
}

@media (max-width: 991px) {
    .khgb-grid {
        --khgb-visible: 3.3;
    }
}

@media (max-width: 480px) {
    .khgb {
        padding: 14px;
    }

    .khgb-grid {
        --khgb-visible: 2.3;
    }

    /* On phones swiping is natural, arrows only cover the cards */
    .khgb-arrow {
        display: none;
    }
}
