/**
 * Slide-in mini-cart.
 *
 * Was a PHP string in fru-timian-shopify.php injected with wp_add_inline_style, which
 * meant it could not be cached, minified or edited without touching PHP. Colours and
 * fonts now come from the theme's design tokens, with literal fallbacks so the plugin
 * still renders sanely under a theme that does not define them.
 */

.minicart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 900;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.minicart-overlay.open {
    opacity: 1;
    visibility: visible;
}

.minicart {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 440px;
    max-width: 100vw;
    background: var(--wp--preset--color--hvit, #fff);
    z-index: 901;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.12);
    font-family: var(--wp--preset--font-family--brod, Figtree, system-ui, -apple-system, sans-serif);
}

.minicart.open {
    transform: translateX(0);
}

/* ── Header ── */

.minicart__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

/* The glyph, the title and the count read as one thing, so the header's space-between has one
   child on the left rather than three. */
.minicart__heading {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.minicart__header h3 {
    font-size: var(--wp--preset--font-size--brodtekst-l, 1.1rem);
    font-weight: 600;
    margin: 0;
    color: var(--wp--preset--color--tekst, #1a1a1a);
}

/* The header's own cart glyph — the same line drawing the button that opened the drawer carries.
   22px is an icon dimension beside a title, not a text size. */
.minicart__icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    fill: none;
    stroke: var(--wp--preset--color--tekst, #1a1a1a);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* How many items are in there, painted by the same function that paints `.fts-cart-badge`. It shows
   the nought too, so it needs no rule for the empty case. 22px matches the glyph opposite it. */
.minicart__count {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 8px;
    border-radius: var(--wp--custom--radius--kant, 3px);
    background: var(--wp--preset--color--lys-blaa, #eaf8fb);
    color: var(--wp--preset--color--tekst, #1a1a1a);
    font-size: var(--wp--preset--font-size--brodtekst-s, 0.875rem);
    font-weight: 500;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

/*
 * A literal, and it stays one: this `font-size` sizes a **glyph**, not type. The button's whole
 * content is one character, so the value is an icon dimension that happens to be expressed as a
 * font size, and putting it on a text rung would make a future type change resize a control. Same
 * category error as reaching for `kicker` because 14px was close to the design's 12px.
 */
.minicart__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    background: none;
    border: none;
    border-radius: var(--wp--custom--radius--kant, 3px);
    font-size: 22px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    color: var(--wp--preset--color--tekst, #1a1a1a);
    transition: background 0.2s, color 0.2s;
}

.minicart__close:hover,
.minicart__close:focus-visible {
    background: var(--wp--preset--color--lys-blaa, #eaf8fb);
    color: var(--wp--preset--color--tekst, #1a1a1a);
}

/* ── Body ── */

.minicart__body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.minicart__items {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.minicart__item {
    display: flex;
    gap: 16px;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.minicart__item-img {
    width: 72px;
    height: 72px;
    border-radius: var(--wp--custom--radius--kant, 3px);
    object-fit: cover;
    background: var(--wp--preset--color--lys-blaa, #eaf8fb);
    flex-shrink: 0;
}

.minicart__item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

/* The stepper and the line's price, at opposite ends of one row. */
.minicart__item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.minicart__item-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.minicart__item-name {
    font-weight: 600;
    font-size: var(--wp--preset--font-size--brodtekst, 1rem);
    color: var(--wp--preset--color--tekst, #1a1a1a);
}

.minicart__item-variant {
    font-size: var(--wp--preset--font-size--brodtekst-s, 0.875rem);
    color: var(--wp--preset--color--tekst-svak, #5a6660);
}

/*
 * Removing a line is a bin, not a cross: a cross here is the same glyph as the close button in the
 * header, so the two controls read as the same one. 30px is a touch target, 17px an icon dimension.
 */
.minicart__item-remove {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: none;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--wp--preset--color--tekst-svak, #5a6660);
    transition: color 0.2s, background 0.2s;
}

.minicart__item-remove svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.minicart__item-remove:hover,
.minicart__item-remove:focus-visible {
    color: var(--wp--preset--color--roed, #c42821);
    background: #fdecea;
}

.minicart__item-price {
    font-size: var(--wp--preset--font-size--brodtekst, 1rem);
    font-weight: 600;
    white-space: nowrap;
    color: var(--wp--preset--color--tekst, #1a1a1a);
}

.minicart__item-qty {
    display: flex;
    align-items: center;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: var(--wp--custom--radius--kant, 3px);
    overflow: hidden;
    width: fit-content;
}

/*
 * A literal, and it stays one: this `font-size` sizes a **glyph**, not type. The button's whole
 * content is one character, so the value is an icon dimension that happens to be expressed as a
 * font size, and putting it on a text rung would make a future type change resize a control. Same
 * category error as reaching for `kicker` because 14px was close to the design's 12px.
 */
.minicart__item-qty button {
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--wp--preset--color--tekst, #1a1a1a);
    transition: background 0.2s;
}

.minicart__item-qty button:hover {
    background: var(--wp--preset--color--lys-blaa, #eaf8fb);
}

.minicart__item-qty button[disabled] {
    opacity: 0.4;
    cursor: default;
}

.minicart__item-qty span {
    width: 28px;
    text-align: center;
    font-size: var(--wp--preset--font-size--brodtekst-s, 0.875rem);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ── «Perfekt sammen med dette» ── */

.minicart__upsell {
    padding: 20px 24px 24px;
}

.minicart__upsell-title {
    margin: 0 0 12px;
    font-size: var(--wp--preset--font-size--brodtekst, 1rem);
    font-weight: 600;
    color: var(--wp--preset--color--tekst, #1a1a1a);
}

.minicart__upsell-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.minicart__upsell-item {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--wp--custom--radius--kant, 3px);
    background: var(--wp--preset--color--lys-blaa, #eaf8fb);
}

.minicart__upsell-img {
    width: 56px;
    height: 56px;
    border-radius: var(--wp--custom--radius--kant, 3px);
    object-fit: cover;
    background: var(--wp--preset--color--hvit, #fff);
}

/* Without an image the text takes the image's column too. */
.minicart__upsell-info:first-child {
    grid-column: 1 / 3;
}

.minicart__upsell-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.minicart__upsell-name {
    font-size: var(--wp--preset--font-size--brodtekst-s, 0.875rem);
    color: var(--wp--preset--color--tekst, #1a1a1a);
    text-decoration: none;
}

.minicart__upsell-name:hover,
.minicart__upsell-name:focus-visible {
    text-decoration: underline;
}

.minicart__upsell-prices {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 8px;
}

.minicart__upsell-price {
    font-size: var(--wp--preset--font-size--brodtekst-s, 0.875rem);
    font-weight: 600;
    color: var(--wp--preset--color--tekst, #1a1a1a);
    white-space: nowrap;
}

.minicart__upsell-compare {
    font-size: var(--wp--preset--font-size--brodtekst-s, 0.875rem);
    color: var(--wp--preset--color--tekst-svak, #5a6660);
    white-space: nowrap;
}

.minicart__upsell-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: var(--wp--custom--radius--kant, 3px);
    background: var(--wp--preset--color--gul, #e09900);
    color: var(--wp--preset--color--hvit, #fff);
    font-family: inherit;
    font-size: var(--wp--preset--font-size--brodtekst-s, 0.875rem);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: filter 0.2s;
}

/* «Velg» is a word rather than a glyph, so it gets the width it needs. */
.minicart__upsell-action--velg {
    width: auto;
    padding: 0 14px;
}

.minicart__upsell-action svg {
    width: 18px;
    height: 19px;
}

.minicart__upsell-action:hover {
    filter: brightness(1.1);
}

.minicart__upsell-action:focus-visible {
    outline: 2px solid var(--wp--preset--color--tekst, #1a1a1a);
    outline-offset: 2px;
}

.minicart__empty,
.minicart__loading {
    text-align: center;
    color: var(--wp--preset--color--tekst-svak, #5a6660);
    padding: 40px 24px;
    font-size: var(--wp--preset--font-size--brodtekst-s, 0.875rem);
}

/*
 * Shown instead of the empty state when a stored cart could not be revalidated — the
 * snapshot has a count but no lines, so "empty" would be a lie. Reassure, then retry.
 */
.minicart__unavailable {
    text-align: center;
    padding: 60px 24px;
}

.minicart__unavailable-text {
    color: var(--wp--preset--color--tekst-svak, #5a6660);
    font-size: var(--wp--preset--font-size--brodtekst, 1rem);
    margin: 0 0 20px;
}

.minicart__retry {
    background: var(--wp--preset--color--tekst, #1a1a1a);
    color: var(--wp--preset--color--hvit, #fff);
    border: 0;
    border-radius: var(--wp--custom--radius--pille, 30px);
    padding: 12px 28px;
    font-size: var(--wp--preset--font-size--brodtekst-s, 0.875rem);
    font-weight: 600;
    cursor: pointer;
}

.minicart__retry:hover {
    opacity: 0.85;
}

/*
 * Inline notice. --error is a userError (the operation failed); --warning is a Cart API
 * warning where Shopify accepted the change but altered it, e.g. capping a line to stock.
 */
.minicart__error {
    margin: 16px 24px 0;
    padding: 12px 14px;
    border-radius: var(--wp--custom--radius--kant, 3px);
    font-size: var(--wp--preset--font-size--brodtekst-s, 0.875rem);
}

.minicart__error--error {
    background: #fdecea;
    color: var(--wp--preset--color--roed, #c42821);
}

.minicart__error--warning {
    background: var(--wp--preset--color--lys-blaa, #eaf8fb);
    color: var(--wp--preset--color--tekst, #1a1a1a);
}

/* ── Free-shipping progress ── */

.minicart__shipping {
    padding: 20px 24px;
    text-align: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.minicart__shipping-text {
    font-size: var(--wp--preset--font-size--brodtekst-s, 0.875rem);
    color: var(--wp--preset--color--tekst-svak, #5a6660);
    margin: 0 0 10px;
}

.minicart__shipping-text--free {
    color: var(--wp--preset--color--tekst, #1a1a1a);
    font-weight: 600;
}

.minicart__progress {
    height: 6px;
    border-radius: 3px;
    background: var(--wp--preset--color--lys-blaa, #eaf8fb);
    overflow: hidden;
}

.minicart__progress-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--wp--preset--color--gul, #e09900), #c4a235);
    transition: width 0.4s ease;
}

/* ── Discount code and gift cards ── */

.minicart__codes {
    padding: 16px 24px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.minicart__code-form {
    display: flex;
    gap: 8px;
}

.minicart__code-input {
    flex: 1;
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: var(--wp--custom--radius--kant, 3px);
    font-family: inherit;
    font-size: var(--wp--preset--font-size--brodtekst-s, 0.875rem);
    color: var(--wp--preset--color--tekst, #1a1a1a);
    background: var(--wp--preset--color--hvit, #fff);
}

.minicart__code-input:focus-visible {
    outline: 2px solid var(--wp--preset--color--tekst, #1a1a1a);
    outline-offset: 1px;
}

.minicart__code-submit {
    padding: 12px 18px;
    border: 1.5px solid var(--wp--preset--color--tekst, #1a1a1a);
    border-radius: var(--wp--custom--radius--kant, 3px);
    background: none;
    color: var(--wp--preset--color--tekst, #1a1a1a);
    font-family: inherit;
    font-weight: 600;
    font-size: var(--wp--preset--font-size--brodtekst-s, 0.875rem);
    cursor: pointer;
    white-space: nowrap;
}

.minicart__code-submit:hover:not([disabled]) {
    background: var(--wp--preset--color--tekst, #1a1a1a);
    color: var(--wp--preset--color--hvit, #fff);
}

.minicart__code-submit[disabled] {
    opacity: 0.6;
    cursor: progress;
}

/* The applied discount code. Sits above the field rather than replacing it: the field also takes
   gift cards, so it has to stay even while the one discount slot is full. */
.minicart__code-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 8px 8px 8px 14px;
    border-radius: var(--wp--custom--radius--pille, 30px);
    background: var(--wp--preset--color--lys-blaa, #eaf8fb);
    color: var(--wp--preset--color--tekst, #1a1a1a);
    font-size: var(--wp--preset--font-size--brodtekst-s, 0.875rem);
    font-weight: 600;
}

/*
 * A literal, and it stays one: this `font-size` sizes a **glyph**, not type. The button's whole
 * content is one character, so the value is an icon dimension that happens to be expressed as a
 * font size, and putting it on a text rung would make a future type change resize a control. Same
 * category error as reaching for `kicker` because 14px was close to the design's 12px.
 */
.minicart__code-remove {
    background: none;
    border: none;
    padding: 0 4px;
    font-size: 18px;
    line-height: 1;
    color: inherit;
    cursor: pointer;
    opacity: 0.6;
}

.minicart__code-remove:hover {
    opacity: 1;
}

/* A redeemed gift card. A row rather than a chip, because unlike a discount code it carries a
   figure — and unlike a discount it may have siblings. */
.minicart__giftcard {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: var(--wp--preset--font-size--brodtekst-s, 0.875rem);
    color: var(--wp--preset--color--tekst, #1a1a1a);
}

.minicart__giftcard-label {
    flex: 1;
    min-width: 0;
}

.minicart__giftcard-amount {
    font-weight: 600;
    color: var(--wp--preset--color--tekst, #1a1a1a);
    white-space: nowrap;
}

/*
 * A literal, and it stays one: this `font-size` sizes a **glyph**, not type. The button's whole
 * content is one character, so the value is an icon dimension that happens to be expressed as a
 * font size, and putting it on a text rung would make a future type change resize a control. Same
 * category error as reaching for `kicker` because 14px was close to the design's 12px.
 */
.minicart__giftcard-remove {
    background: none;
    border: none;
    padding: 0 4px;
    font-size: 18px;
    line-height: 1;
    color: inherit;
    cursor: pointer;
    opacity: 0.6;
}

.minicart__giftcard-remove:hover {
    opacity: 1;
}

/* ── Footer ── */

.minicart__footer {
    padding: 20px 24px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.minicart__subtotal,
.minicart__discount-row,
.minicart__total-row,
.minicart__due-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
    color: var(--wp--preset--color--tekst, #1a1a1a);
}

.minicart__subtotal,
.minicart__total-row,
.minicart__due-row {
    font-weight: 700;
    font-size: var(--wp--preset--font-size--brodtekst, 1rem);
}

/* What is actually left to pay, once gift cards have drawn against the total. It is the last word
   on the money, so it gets the separator and the emphasis. */
.minicart__due-row {
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

/* A discount is a smaller, quieter row than the numbers it sits between: it explains the
   difference between them rather than being a figure the shopper has to add up. */
.minicart__discount-row {
    font-size: var(--wp--preset--font-size--brodtekst-s, 0.875rem);
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--wp--preset--color--tekst, #1a1a1a);
}

/* Where both are shown the subtotal is no longer the bottom line, so it stops looking like it. */
.minicart__discount-row ~ .minicart__total-row {
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

/* …and the same again once a gift card has moved the bottom line one row further down. */
.minicart__due-row ~ .minicart__total-row,
.minicart__total-row:has( ~ .minicart__due-row ) {
    padding-top: 0;
    border-top: none;
}

.minicart__checkout-btn {
    display: block;
    width: 100%;
    padding: 16px;
    text-align: center;
    background: var(--wp--preset--color--gul, #e09900);
    color: var(--wp--preset--color--hvit, #fff);
    border: none;
    border-radius: var(--wp--custom--radius--kant, 3px);
    font-family: inherit;
    font-weight: 600;
    font-size: var(--wp--preset--font-size--brodtekst, 1rem);
    cursor: pointer;
    transition: transform 0.2s, filter 0.2s;
}

.minicart__checkout-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.1);
}

.minicart__checkout-btn[disabled] {
    opacity: 0.6;
    cursor: default;
    transform: none;
    filter: none;
}

/* The marks the shop accepts, under the button — one claim about payment, on the drawer as on the
   product page. */
.minicart__pay-icons {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 14px;
}

.minicart__pay-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.minicart__pay-icon svg {
    display: block;
    width: 38px;
    height: 24px;
}

/* ── While a line edit is on its way to Shopify ── */

/* The money and the shipping promise are the shopper's own arithmetic until Shopify confirms them.
   The checkout button is left alone: its click waits for the queue, so it is not a lie. */
.minicart__footer[aria-busy="true"] .minicart__subtotal,
.minicart__footer[aria-busy="true"] .minicart__discount-row,
.minicart__footer[aria-busy="true"] .minicart__total-row,
.minicart__footer[aria-busy="true"] .minicart__due-row,
.minicart__shipping[aria-busy="true"] .minicart__shipping-text {
    opacity: 0.55;
    transition: opacity 0.2s;
}

/* ── Add-to-cart button states (shared by cards and the product CTA) ── */

.cart-btn--loading {
    opacity: 0.6;
    cursor: progress;
}

.cart-btn--success {
    background: var(--wp--preset--color--tekst, #1a1a1a);
}

/* The button's own glyph steps aside for the ring, so the label does not shift. */
.cart-btn[aria-busy="true"] {
    cursor: progress;
}

.cart-btn[aria-busy="true"]:hover {
    transform: none;
    filter: none;
}

.cart-btn[aria-busy="true"] svg,
.minicart__upsell-action[aria-busy="true"] svg {
    display: none;
}

.cart-btn[aria-busy="true"]::before,
.minicart__upsell-action[aria-busy="true"]::before {
    content: "";
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: fts-spinn 0.7s linear infinite;
}

@keyframes fts-spinn {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .minicart,
    .minicart-overlay,
    .minicart__progress-fill,
    .minicart__checkout-btn,
    .minicart__item-qty button,
    .minicart__item-remove,
    .minicart__upsell-action {
        transition: none;
    }

    .minicart__footer[aria-busy="true"] .minicart__subtotal,
    .minicart__footer[aria-busy="true"] .minicart__discount-row,
    .minicart__footer[aria-busy="true"] .minicart__total-row,
    .minicart__footer[aria-busy="true"] .minicart__due-row,
    .minicart__shipping[aria-busy="true"] .minicart__shipping-text {
        transition: none;
    }

    .cart-btn[aria-busy="true"]::before,
    .minicart__upsell-action[aria-busy="true"]::before {
        animation: none;
    }
}
