/**
 * The product page's package – "Köps ofta tillsammans" or a package of Ohyra → Paket (Together_Widget,
 * templates/product/together.php): a section of the product page of its own, the page's width; with a discount a pill
 * by the title ("Spara 10 %") and the package's price – the sum struck through, what it saves in green. Wide (a screen 1100px or more): the products as cards side by side on a grey panel, joined
 * by "+", the price for those chosen and the button beside them. Narrow: a white row each (as the volume discount's
 * rows), the price and the button under. A box in Ohyra's red to leave one out (left out: faded); "Mer info" the item
 * in a dialog on the page (a sheet from below on a phone).
 */

.gf-together {
    --gf-tg-ink: var(--e-global-color-secondary, #1a1a1a);
    --gf-tg-muted: var(--e-global-color-primary, #696969);
    --gf-tg-brand: var(--e-global-color-d49ac81, #97040d);
    --gf-tg-line: #e2e2e2;
    --gf-tg-panel: #f8f8f8;
    --gf-tg-pic: 52px;
    --gf-tg-card-pic: 150px;

    --gf-tg-save: #168a04;

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

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

.gf-together[hidden] {
    display: none !important;
}

/* The title – and the discount's pill beside it (under it when they don't fit) */
.gf-together-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px 14px;
    margin: 0 0 24px;
}

.gf-together .gf-together-title {
    margin: 0;
    text-align: center;
}

.gf-together-deal {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 12px;
    border-radius: 999px;
    background: var(--gf-tg-brand);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.01em;
    color: #fff;
    white-space: nowrap;
}

.gf-together-body {
    display: grid;
    gap: 16px;
}

.gf-together .gf-together-items {
    display: grid;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* An item: the box, the picture, the name (and "Denna produkt", "Mer info"), the price – the label's parts in the
   item's grid (display: contents), all of it choosing but "Mer info" */
.gf-together .gf-together-item {
    position: relative;
    display: grid;
    grid-template-columns: 20px var(--gf-tg-pic) minmax(0, 1fr) auto;
    grid-template-areas: "box pic text price";
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 10px 14px;
    border: 1.5px solid var(--gf-tg-line);
    border-radius: 12px;
    background: #fff;
    transition: border-color 0.15s ease;
}

.gf-together .gf-together-item:hover {
    border-color: #bdbdbd;
}

.gf-together .gf-together-row {
    display: contents;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.gf-together-row > * {
    cursor: pointer;
}

/* (the whole item chooses: the label stretched over it, under "Mer info") */
.gf-together-row::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
}

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

.gf-together-box {
    position: relative;
    grid-area: box;
    width: 20px;
    height: 20px;
    border: 2px solid #c4c4c4;
    border-radius: 5px;
    background: #fff;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.gf-together-input:checked + .gf-together-box {
    border-color: var(--gf-tg-brand);
    background: var(--gf-tg-brand);
}

/* (the tick) */
.gf-together-input:checked + .gf-together-box::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 5px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.gf-together-input:focus-visible + .gf-together-box {
    outline: 2px solid var(--gf-tg-brand);
    outline-offset: 2px;
}

.gf-together .gf-together-pic {
    display: block;
    grid-area: pic;
    width: var(--gf-tg-pic);
    height: var(--gf-tg-pic);
    overflow: hidden;
    border: 1px solid #ececec;
    border-radius: 8px;
    background: #fff;
}

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

/* "Mer info": a dialog on the page, not another page */
.gf-together .gf-together-info {
    justify-self: start;
    margin: 2px 0 0;
    padding: 2px 0;
    border: 0;
    background: none;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--gf-tg-muted);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

/* (the theme's buttons take a background on hover and focus – not this one) */
.gf-together .gf-together-info:is(:hover, :focus) {
    background: none;
    color: var(--gf-tg-brand);
}

.gf-together .gf-together-info:focus-visible {
    outline: 2px solid var(--gf-tg-brand);
    outline-offset: 2px;
}

/* (over the label's stretch – "Mer info" in it stays clickable when the item is faded; a click on the text still
   chooses: it's in the label) */
.gf-together-text {
    position: relative;
    z-index: 1;
    display: grid;
    grid-area: text;
    gap: 2px;
    min-width: 0;
}

.gf-together-this {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--gf-tg-brand);
}

.gf-together-name {
    display: -webkit-box;
    overflow: hidden;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.35;
    color: var(--gf-tg-ink);
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.gf-together-price {
    display: grid;
    grid-area: price;
    justify-items: end;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.gf-together-price del {
    font-size: 12.5px;
    font-weight: 400;
    color: var(--gf-tg-muted);
}

.gf-together-price ins {
    color: var(--gf-tg-brand);
    text-decoration: none;
}

/* The "+" between two items: its own place – a circle with a cross drawn in it (a glyph sits where its font puts it) */
.gf-together .gf-together-plus {
    display: grid;
    place-items: center;
    height: 30px;
    margin: 0;
    padding: 0;
}

.gf-together-plus span {
    position: relative;
    display: block;
    width: 24px;
    height: 24px;
    border: 1.5px solid var(--gf-tg-line);
    border-radius: 50%;
    background: #fff;
}

.gf-together-plus span::before,
.gf-together-plus span::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 2px;
    border-radius: 1px;
    background: var(--gf-tg-muted);
    transform: translate(-50%, -50%);
}

.gf-together-plus span::after {
    transform: translate(-50%, -50%) rotate(90deg);
}

/* Left out: faded */
.gf-together-item.is-off .gf-together-pic,
.gf-together-item.is-off .gf-together-text,
.gf-together-item.is-off .gf-together-price {
    opacity: 0.45;
}

/* The price for those chosen and the button */
.gf-together-foot {
    display: grid;
    gap: 10px;
}

.gf-together .gf-together-sum {
    margin: 0;
    font-size: 15px;
}

.gf-together-sum strong {
    font-size: 19px;
    font-weight: 700;
    white-space: nowrap;
}

/* (the package's price: the sum struck through before it) */
.gf-together-amounts {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 8px;
}

.gf-together .gf-together-amounts del {
    font-size: 14px;
    font-weight: 400;
    color: var(--gf-tg-muted);
    white-space: nowrap;
}

.gf-together .gf-together-amounts del[hidden] {
    display: none;
}

.gf-together .gf-together-saving,
.gf-together .gf-together-hint {
    margin: -4px 0 0;
    font-size: 13.5px;
    line-height: 1.4;
}

.gf-together .gf-together-saving {
    font-weight: 600;
    color: var(--gf-tg-save);
}

.gf-together .gf-together-hint {
    color: var(--gf-tg-muted);
}

.gf-together .gf-together-saving[hidden],
.gf-together .gf-together-hint[hidden] {
    display: none;
}

.gf-together .gf-together-add {
    width: 100%;
    min-height: 48px;
    margin: 0;
    padding: 10px 18px;
    border: 0;
    border-radius: 5px;
    background: var(--gf-tg-brand);
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.3;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.15s ease, opacity 0.15s ease;
}

/* (the theme's focus background: ours, until hovered or done) */
.gf-together .gf-together-add:focus {
    background: var(--gf-tg-brand);
    color: #fff;
}

.gf-together .gf-together-add:hover:not(:disabled) {
    background: color-mix(in srgb, var(--gf-tg-brand) 85%, #000);
}

.gf-together .gf-together-add:focus-visible {
    outline: 2px solid var(--gf-tg-brand);
    outline-offset: 2px;
}

.gf-together .gf-together-add:disabled {
    opacity: 0.5;
    cursor: default;
}

.gf-together .gf-together-add.is-busy {
    opacity: 0.75;
    cursor: progress;
}

.gf-together .gf-together-add.is-done {
    background: #189704;
}

.gf-together .gf-together-msg {
    margin: 0;
    font-size: 13px;
    color: var(--gf-tg-brand);
}

.gf-together .gf-together-msg:empty {
    display: none;
}

/* Wide (a screen 1100px or more – the section is the page's width; a container query would be the thing, but one
   inside Elementor's column containers leaves a gap under it on phones): cards side by side on a grey panel, the price
   and the button beside them */
@media (min-width: 1100px) {
    .gf-together-body {
        grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
        align-items: center;
        gap: 36px;
        padding: 28px 32px;
        border-radius: 16px;
        background: var(--gf-tg-panel);
    }

    .gf-together .gf-together-items {
        display: flex;
        align-items: stretch;
    }

    .gf-together .gf-together-item {
        flex: 1 1 0;
        max-width: 210px;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto 1fr auto;
        grid-template-areas: "pic" "text" "price";
        align-items: start;
        gap: 10px;
        padding: 14px;
    }

    .gf-together .gf-together-pic {
        width: 100%;
        height: var(--gf-tg-card-pic);
        border: 0;
    }

    /* (the "+": between two cards, in the middle of their height) */
    .gf-together .gf-together-plus {
        flex: 0 0 34px;
        align-self: center;
        height: auto;
    }

    .gf-together .gf-together-box {
        position: absolute;
        top: 12px;
        left: 12px;
        z-index: 2;
        width: 22px;
        height: 22px;
        box-shadow: 0 0 0 3px #fff;
    }

    .gf-together-input:checked + .gf-together-box::after {
        left: 6px;
        width: 6px;
        height: 11px;
    }

    .gf-together-price {
        justify-items: start;
        font-size: 16px;
    }

    .gf-together-foot {
        align-self: center;
        gap: 14px;
        padding-left: 32px;
        border-left: 1px solid var(--gf-tg-line);
    }

    .gf-together .gf-together-sum {
        display: grid;
        gap: 2px;
        color: var(--gf-tg-muted);
    }

    .gf-together-sum strong {
        font-size: 26px;
        color: var(--gf-tg-ink);
    }

    .gf-together .gf-together-amounts del {
        font-size: 16px;
    }

    .gf-together .gf-together-saving,
    .gf-together .gf-together-hint {
        margin-top: -8px;
    }
}

@media (max-width: 767px) {
    .gf-together {
        padding-top: 40px;
    }
}

@media (max-width: 480px) {
    .gf-together {
        --gf-tg-pic: 44px;
    }

    .gf-together .gf-together-item {
        gap: 10px;
        padding: 9px 12px;
    }

    .gf-together-name {
        font-size: 13.5px;
    }
}

/* "Mer info": the item in a dialog – a sheet from below on a phone */
.gf-together-dialog {
    width: min(620px, calc(100vw - 32px));
    max-height: calc(100dvh - 48px);
    padding: 0;
    overflow: auto;
    border: 0;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 24px 60px rgb(0 0 0 / 0.25);
    color: var(--gf-tg-ink);
}

.gf-together-dialog::backdrop {
    background: rgb(17 17 17 / 0.5);
}

.gf-together-dialog[open] {
    animation: gf-together-in 0.18s ease-out;
}

@keyframes gf-together-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
}

.gf-together .gf-together-dialog-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1;
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #f2f2f2;
    cursor: pointer;
}

/* (the cross, drawn) */
.gf-together-dialog-close::before,
.gf-together-dialog-close::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 2px;
    border-radius: 1px;
    background: var(--gf-tg-ink);
    transform: translate(-50%, -50%) rotate(45deg);
}

.gf-together-dialog-close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.gf-together .gf-together-dialog-close:is(:hover, :focus) {
    background: #e6e6e6;
}

.gf-together .gf-together-dialog-close:focus-visible {
    outline: 2px solid var(--gf-tg-brand);
    outline-offset: 2px;
}

.gf-together-detail {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 24px;
    padding: 28px 28px 8px;
}

.gf-together-detail-pic {
    overflow: hidden;
    border: 1px solid #ececec;
    border-radius: 12px;
    background: #fff;
    aspect-ratio: 1;
}

.gf-together-detail-pic img {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    object-fit: contain;
}

.gf-together-detail-text {
    display: grid;
    align-content: start;
    gap: 10px;
    padding-right: 28px;
}

.gf-together .gf-together-detail-name {
    margin: 0;
    font-family: inherit;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--gf-tg-ink);
}

.gf-together .gf-together-detail-price {
    display: flex;
    gap: 8px;
    align-items: baseline;
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.gf-together-detail-price del {
    font-size: 14px;
    font-weight: 400;
    color: var(--gf-tg-muted);
}

.gf-together-detail-price ins {
    color: var(--gf-tg-brand);
    text-decoration: none;
}

.gf-together-detail-about {
    font-size: 14px;
    line-height: 1.5;
    color: #444;
}

.gf-together-detail-about p {
    margin: 0 0 8px;
}

.gf-together .gf-together-detail-link {
    justify-self: start;
    font-size: 14px;
    font-weight: 500;
    color: var(--gf-tg-brand);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.gf-together-dialog-foot {
    padding: 16px 28px 28px;
}

.gf-together .gf-together-dialog-pick {
    width: 100%;
    min-height: 48px;
    margin: 0;
    padding: 10px 18px;
    border: 2px solid var(--gf-tg-brand);
    border-radius: 5px;
    background: var(--gf-tg-brand);
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    color: #fff;
    cursor: pointer;
}

.gf-together .gf-together-dialog-pick:is(:hover, :focus) {
    background: color-mix(in srgb, var(--gf-tg-brand) 85%, #000);
    color: #fff;
}

/* (chosen already: the way to leave it out, outlined) */
.gf-together .gf-together-dialog-pick.is-chosen {
    background: #fff;
    color: var(--gf-tg-brand);
}

.gf-together .gf-together-dialog-pick.is-chosen:is(:hover, :focus) {
    background: color-mix(in srgb, var(--gf-tg-brand) 6%, #fff);
    color: var(--gf-tg-brand);
}

.gf-together .gf-together-dialog-pick:focus-visible {
    outline: 2px solid var(--gf-tg-brand);
    outline-offset: 2px;
}

@media (max-width: 599px) {
    .gf-together-dialog {
        width: 100%;
        max-width: none;
        max-height: 88dvh;
        margin: auto 0 0;
        border-radius: 18px 18px 0 0;
    }

    .gf-together-detail {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 20px 20px 4px;
    }

    .gf-together-detail-pic {
        width: 180px;
        justify-self: center;
    }

    .gf-together-detail-text {
        padding-right: 0;
    }

    .gf-together-dialog-foot {
        padding: 14px 20px calc(20px + env(safe-area-inset-bottom));
    }
}

.gf-together-empty {
    padding: 16px;
    border: 1px dashed #c4c4c4;
    border-radius: 8px;
    font-size: 13px;
    color: #696969;
}

@media (prefers-reduced-motion: reduce) {
    .gf-together .gf-together-item,
    .gf-together-box,
    .gf-together .gf-together-add {
        transition: none;
    }

    .gf-together-dialog[open] {
        animation: none;
    }
}
