/**
 * Volume discount (Volume_Controller): the ladder in the product page's buy box – a row per quantity to choose by, the
 * product's picture as many times, the chosen one outlined in Ohyra's red; the last – the best price – stands out: a
 * red edge of its own, "Bästa pris/st" on its top edge, its price per piece larger and red –, and "Mängdrabatt från
 * 2 st" under the product cards' price (when that's on). Savings in the cart's green. The admin's preview of a
 * product's ladder uses the rows too.
 */

.gf-volume {
    --gf-vol-ink: var(--e-global-color-secondary, #1a1a1a);
    --gf-vol-muted: var(--e-global-color-primary, #696969);
    --gf-vol-brand: var(--e-global-color-d49ac81, #97040d);
    --gf-vol-go: #189704;
    --gf-vol-line: #e2e2e2;

    flex: 1 1 100%;
    width: 100%;
    margin: 0 0 20px;
    font-family: var(--e-global-typography-text-font-family, "Poppins"), system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.35;
    color: var(--gf-vol-ink);
}

.gf-volume[hidden] {
    display: none;
}

/* (a variable product's: under the variation's price) */
.woocommerce-variation-add-to-cart > .gf-volume {
    margin-top: 14px;
}

/* (Elementor's buy box is one row, its button a whole row's width: the ladder takes its own row above, the quantity
   and the button share the next) */
form.cart:has(> .gf-volume),
.woocommerce-variation-add-to-cart:has(> .gf-volume) {
    flex-wrap: wrap !important;
}

:is(form.cart, .woocommerce-variation-add-to-cart):has(> .gf-volume) > .single_add_to_cart_button {
    flex: 1 1 0% !important;
    min-width: 0;
}

.gf-volume *,
.gf-volume *::before,
.gf-volume *::after {
    box-sizing: border-box;
}

.gf-volume .gf-volume-title {
    margin: 0 0 16px;
    font-size: 15px;
    font-weight: 600;
}

.gf-volume-title span {
    font-weight: 400;
    color: var(--gf-vol-muted);
}

.gf-volume-title span .amount {
    font-weight: inherit;
}

/* (the most off: in red) */
.gf-volume-title span strong {
    font-weight: 600;
    color: var(--gf-vol-brand);
}

/* The rows: one per quantity, under each other – room between them for the best one's tag on its edge */
.gf-volume-rows {
    display: grid;
    gap: 14px;
}

/* A row: the dot, the pictures, the quantity with its discount and the saving, the price per piece and the total */
.gf-volume .gf-volume-row {
    position: relative;
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    align-items: center;
    column-gap: clamp(8px, 2.4vw, 14px);
    min-height: 68px;
    margin: 0;
    padding: 11px clamp(12px, 3vw, 18px);
    border: 1.5px solid var(--gf-vol-line);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.gf-volume .gf-volume-row:hover {
    border-color: #bdbdbd;
}

/* The best price: a red edge of its own even when not chosen */
.gf-volume .gf-volume-row.is-best {
    border-color: color-mix(in srgb, var(--gf-vol-brand) 45%, #fff);
}

.gf-volume .gf-volume-row.is-best:hover {
    border-color: color-mix(in srgb, var(--gf-vol-brand) 70%, #fff);
}

.gf-volume .gf-volume-row:has(input:checked) {
    border-color: var(--gf-vol-brand);
    background: color-mix(in srgb, var(--gf-vol-brand) 4%, #fff);
    box-shadow: 0 0 0 1px var(--gf-vol-brand);
}

.gf-volume .gf-volume-row:has(input:focus-visible) {
    outline: 2px solid var(--gf-vol-brand);
    outline-offset: 2px;
}

.gf-volume .gf-volume-row input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

.gf-volume-dot {
    width: 20px;
    height: 20px;
    border: 2px solid #c4c4c4;
    border-radius: 50%;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.gf-volume-row:has(input:checked) .gf-volume-dot {
    border-color: var(--gf-vol-brand);
    box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 10px var(--gf-vol-brand);
}

/* (a preview without radios – the admin's: no dot) */
.gf-volume-row:not(:has(input)) .gf-volume-dot {
    display: none;
}

/* The product's picture as many times as the quantity (three at most), fanned out – its white edge cut away; the
   column as wide as three, so the rows' text lines up */
.gf-volume-pics {
    --gf-vol-pic: clamp(32px, 8.5vw, 44px);

    display: flex;
    justify-content: center;
    align-items: center;
    width: calc(var(--gf-vol-pic) * 1.9 + 6px);
    height: calc(var(--gf-vol-pic) + 6px);
}

.gf-volume-pic {
    position: relative;
    flex: 0 0 auto;
    width: var(--gf-vol-pic);
    height: var(--gf-vol-pic);
    overflow: hidden;
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 1px 4px rgb(0 0 0 / 0.08);
}

.gf-volume .gf-volume-pic img {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    object-fit: contain;
    transform: scale(1.3);
}

.gf-volume-pic + .gf-volume-pic {
    margin-left: calc(var(--gf-vol-pic) * -0.55);
}

.gf-volume-pic:nth-child(1):not(:only-child) {
    transform: rotate(-7deg) translateY(1px);
}

.gf-volume-pic:nth-child(2) {
    z-index: 1;
    transform: rotate(6deg);
}

.gf-volume-pic:nth-child(2):not(:last-child) {
    transform: translateY(-2px);
}

.gf-volume-pic:nth-child(3) {
    z-index: 2;
    transform: rotate(8deg) translateY(1px);
}

.gf-volume-main {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.gf-volume-qty {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
}

.gf-volume-off {
    padding: 1px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--gf-vol-brand) 10%, #fff);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.5;
    white-space: nowrap;
    color: var(--gf-vol-brand);
}

.gf-volume-off .amount {
    font-weight: inherit;
}

.gf-volume-save {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--gf-vol-go);
}

.gf-volume-prices {
    display: grid;
    justify-items: end;
    gap: 2px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.gf-volume-each {
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
}

.gf-volume-each .amount {
    font-size: 17px;
    font-weight: 700;
}

.gf-volume-row.is-best .gf-volume-each {
    color: var(--gf-vol-brand);
}

.gf-volume-row.is-best .gf-volume-each .amount {
    font-size: 20px;
}

.gf-volume-total {
    font-size: 12.5px;
    line-height: 1.3;
    white-space: nowrap;
    color: var(--gf-vol-muted);
}

.gf-volume-total del {
    margin-left: 2px;
    opacity: 0.75;
}

/* "Bästa pris/st" on the best row's top edge, over its prices */
.gf-volume-tag {
    position: absolute;
    top: 0;
    right: clamp(12px, 3vw, 18px);
    padding: 0 10px;
    border-radius: 999px;
    background: var(--gf-vol-brand);
    box-shadow: 0 0 0 3px #fff;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 22px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    color: #fff;
    transform: translateY(-50%);
}

/* (a narrow screen: the pictures and the dot smaller, the gaps tighter) */
@media (max-width: 420px) {
    .gf-volume-dot {
        width: 18px;
        height: 18px;
    }

    .gf-volume-qty {
        font-size: 14px;
    }

    .gf-volume-each .amount {
        font-size: 16px;
    }

    .gf-volume-row.is-best .gf-volume-each .amount {
        font-size: 18px;
    }
}

.gf-volume .gf-volume-sum {
    margin: 12px 0 0;
    font-size: 14px;
    color: var(--gf-vol-ink);
}

.gf-volume .gf-volume-sum[hidden] {
    display: none;
}

.gf-volume-sum strong {
    font-weight: 600;
}

.gf-volume-sum strong:last-child {
    color: var(--gf-vol-go);
}

.gf-volume .gf-volume-note {
    margin: 8px 0 0;
    font-size: 12.5px;
    color: var(--gf-vol-muted);
}

/* The product cards: under the price */
.gf-volume-badge {
    display: block;
    margin-top: 6px;
    font-family: var(--e-global-typography-text-font-family, "Poppins"), system-ui, sans-serif;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: 0;
    color: var(--e-global-color-d49ac81, #97040d);
}

@media (prefers-reduced-motion: reduce) {
    .gf-volume .gf-volume-row,
    .gf-volume-dot {
        transition: none;
    }
}
