/* ==========================================================================
   Nettbutikk – mini cart, cart page and checkout (inc/shop-cart.php).
   Figma: «Minihandlekorj» 2183:11464, «Handlekorj» 2183:11466.
   Price, quantity stepper, payment logos and «Handle trygt» come from shop.css.
   ========================================================================== */

/* Uncode's own cart dropdown under the header icon – the mini cart drawer replaces it */
.uncode-cart .uncode-cart-dropdown {
    display: none !important;
}

/* Quantity stepper, Size Small (32px) – in the mini cart */

.shop-quantity--small {
    gap: 0.25rem;
}

.shop-quantity--small .shop-quantity__button,
.shop-quantity--small .shop-quantity__input {
    width: 2rem;
    height: 2rem;
}

/* Cart line (Figma 2155:435) – Compact in the mini cart, Large on the cart page */

.shop-cart-line {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin: 0;
    padding-block: 1rem;
    border-bottom: 1px solid var(--roros-color-border-subtle);
    list-style: none;
    font-family: var(--roros-font-family-ui);
    color: var(--roros-color-text-primary);
}

.shop-cart-line__thumb {
    flex-shrink: 0;
    width: 4.5rem; /* 72px */
    height: 4.5rem;
    overflow: hidden;
    background: var(--roros-color-bg-page);
}

.shop-cart-line--large .shop-cart-line__thumb {
    width: 7.5rem; /* 120px */
    height: 7.5rem;
}

.shop-cart-line__thumb a {
    display: block;
    height: 100%;
}

.shop-cart-line__thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.shop-cart-line__info {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    min-width: 0;
}

/* Uncode sets margin and weight 600 on form p */
.shop-cart-line .shop-cart-line__title,
.shop-cart-line .shop-cart-line__meta,
.shop-cart-line .shop-cart-line__price {
    margin: 0;
    font-family: var(--roros-font-family-ui);
    font-weight: 400;
    color: var(--roros-color-text-primary);
}

.shop-cart-line .shop-cart-line__title {
    font-size: var(--roros-font-size-label);
    font-weight: 500;
    line-height: var(--roros-line-height-label);
}

.shop-cart-line__title a {
    color: inherit;
    text-decoration: none;
}

.shop-cart-line__title a:hover {
    text-decoration: underline;
}

.shop-cart-line .shop-cart-line__meta {
    font-size: var(--roros-font-size-body-sm);
    line-height: var(--roros-line-height-body-sm);
    color: var(--roros-color-text-secondary);
}

.shop-cart-line__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    padding-top: 0.25rem;
}

.shop-cart-line--large .shop-cart-line__actions {
    padding-top: 0.75rem;
}

.shop-cart-line .shop-cart-line__remove {
    font-size: var(--roros-font-size-caption);
    line-height: var(--roros-line-height-caption);
    color: var(--roros-color-text-primary);
    text-decoration: underline;
}

.shop-cart-line .shop-cart-line__price {
    flex-shrink: 0;
    font-size: var(--roros-font-size-body);
    line-height: var(--roros-line-height-body);
    text-align: right;
    white-space: nowrap;
}

/* Uncode sets its own font and size on WooCommerce's amount markup */
:is(.shop-cart-line, .shop-minicart, .shop-cart-summary, .shop-checkout) .woocommerce-Price-amount {
    font: inherit;
}

.shop-cart-line.is-updating {
    opacity: 0.5;
    pointer-events: none;
}

/* Mini cart (Figma 2156:6925) – a drawer from the right */

html.minicart-open {
    overflow: hidden;
}

.shop-minicart {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(27.5rem, 100%); /* 440px */
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: var(--roros-color-bg-page);
    color: var(--roros-color-text-primary);
    overflow: hidden; /* the lines scroll instead, so the summary stays in view */
}

.shop-minicart[open] {
    animation: shop-minicart-in 0.25s ease-out;
}

.shop-minicart::backdrop {
    background: var(--roros-color-bg-image-overlay);
}

@keyframes shop-minicart-in {
    from {
        transform: translateX(100%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .shop-minicart[open] {
        animation: none;
    }
}

/* WooCommerce's mini cart wrapper, replaced by its cart fragment */
.shop-minicart .widget_shopping_cart_content {
    height: 100%;
}

.shop-minicart__content {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 2rem;
    height: 100%;
    padding: 2rem 1.5rem 1.5rem;
    font-family: var(--roros-font-family-ui);
}

.shop-minicart__top {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 0;
}

.shop-minicart__content.is-empty .shop-minicart__top {
    gap: 3rem;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.shop-minicart__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.shop-minicart .shop-minicart__title {
    margin: 0;
    font-family: var(--roros-font-family-display);
    font-size: var(--roros-font-size-h3);
    font-weight: normal;
    line-height: var(--roros-line-height-h3);
    color: var(--roros-color-text-primary);
}

.shop-minicart__close {
    display: flex;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
}

.shop-minicart__items {
    min-height: 0;
    /* The padding keeps focus outlines inside the scroll area */
    margin: 0 -0.25rem;
    padding: 0 0.25rem;
    list-style: none;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.shop-minicart__summary {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.shop-minicart .shop-minicart__subtotal {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 0;
    font-size: var(--roros-font-size-label);
    font-weight: 500;
    line-height: var(--roros-line-height-label);
}

.shop-minicart__amount {
    font-family: var(--roros-font-family-display);
    font-size: var(--roros-font-size-h3);
    font-weight: normal;
    line-height: var(--roros-line-height-h3);
}

.shop-minicart .shop-minicart__note {
    margin: 0;
    font-family: var(--roros-font-family-ui);
    font-size: var(--roros-font-size-caption);
    line-height: var(--roros-line-height-caption);
    color: var(--roros-color-text-secondary);
}

.shop-minicart__cart {
    text-align: center;
    text-decoration: none;
}

.shop-minicart__cart:hover {
    color: var(--roros-color-text-inverse);
}

.shop-minicart__continue,
.shop-cart-empty__link {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    font-family: var(--roros-font-family-ui);
    font-size: var(--roros-font-size-ui-body);
    line-height: var(--roros-line-height-ui-body);
    color: var(--roros-color-text-primary);
    text-align: center;
    text-decoration: underline;
    cursor: pointer;
}

/* Empty cart (Figma 2165:9070) – in the mini cart and on the cart page */

.shop-cart-empty {
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.shop-cart-empty__intro {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
}

.shop-cart-empty__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 999px;
    background: var(--roros-color-surface-cream);
}

.shop-cart-empty .shop-cart-empty__title {
    margin: 0;
    font-family: var(--roros-font-family-display);
    font-size: var(--roros-font-size-h3);
    line-height: var(--roros-line-height-h3);
    color: var(--roros-color-text-primary);
}

.shop-cart-empty .shop-cart-empty__text {
    margin: 0;
    font-family: var(--roros-font-family-ui);
    font-size: var(--roros-font-size-body);
    line-height: var(--roros-line-height-body);
    color: var(--roros-color-text-secondary);
}

.shop-cart-empty__button {
    text-align: center;
    text-decoration: none;
}

.shop-cart-empty__button:hover {
    color: var(--roros-color-text-inverse);
}

.shop-cart-empty__popular {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    font-family: var(--roros-font-family-ui);
}

.shop-cart-empty .shop-cart-empty__popular-title {
    margin: 0;
    font-family: var(--roros-font-family-ui);
    font-size: var(--roros-font-size-label);
    font-weight: 500;
    line-height: var(--roros-line-height-label);
}

.shop-cart-empty__rows {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Cart page (Figma 2157:7124) */

.shop-cart,
.shop-checkout {
    width: min(100% - 2rem, 67.5rem); /* 1080px */
    margin: 3rem auto 0;
    padding-bottom: 7.5rem;
    font-family: var(--roros-font-family-ui);
    color: var(--roros-color-text-primary);
}

.shop-cart--empty {
    max-width: 27.5rem;
}

.shop-cart--empty .shop-cart__header {
    text-align: center;
    justify-content: center;
}

.shop-cart__header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 3rem;
}

.shop-page .shop-cart__title {
    margin: 0;
    font-family: var(--roros-font-family-display);
    font-size: var(--roros-font-size-h1);
    font-weight: normal;
    line-height: var(--roros-line-height-h1);
    color: var(--roros-color-text-primary);
}

.shop-cart-count {
    font-size: var(--roros-font-size-body);
    line-height: var(--roros-line-height-body);
    color: var(--roros-color-text-secondary);
}

.shop-cart__layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 24rem; /* 648 + 384 */
    grid-template-rows: auto auto 1fr; /* the taller summary's extra height goes below */
    grid-template-areas:
        "items aside"
        "continue aside"
        ". aside";
    gap: 0 3rem;
    align-items: start;
}

.shop-cart__items {
    grid-area: items;
    margin: 0;
    border-top: 1px solid var(--roros-color-border-strong);
}

.shop-cart__lines {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Without JavaScript quantities need the button; cart.js presses it for you */
.shop-cart__actions {
    padding-top: 1rem;
}

.woocommerce-js .shop-cart__update {
    display: none;
}

.shop-cart__update {
    width: auto;
}

.shop-cart__aside {
    grid-area: aside;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Desktop: the summary stays in view on long carts, 24px under the fixed header (102px) */
@media (min-width: 960px) {
    .shop-cart__aside {
        position: sticky;
        top: calc(6.375rem + 1.5rem);
    }

    /* Uncode's overflow: hidden here would stop sticky; clip hides the same without it */
    .woocommerce-cart .box-wrapper {
        overflow: clip;
    }
}

.shop-page .shop-cart__continue {
    grid-area: continue;
    justify-self: start;
    padding-top: 1.5rem;
    font-size: var(--roros-font-size-ui-body);
    line-height: var(--roros-line-height-ui-body);
    color: var(--roros-color-text-primary);
    text-decoration: underline;
}

/* «Oppsummering» (Figma 2157:7247) */

.shop-cart-summary {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--roros-color-surface-blue);
}

.shop-page .shop-cart-summary__title {
    margin: 0;
    font-family: var(--roros-font-family-display);
    font-size: var(--roros-font-size-h3);
    font-weight: normal;
    line-height: var(--roros-line-height-h3);
    color: var(--roros-color-text-primary);
}

.shop-cart-summary__rows {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 0;
}

.shop-cart-summary__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: var(--roros-font-size-body);
    line-height: var(--roros-line-height-body);
}

.shop-cart-summary__row :is(dt, dd) {
    margin: 0;
    font: inherit;
}

.shop-cart-summary__row dd {
    text-align: right;
}

.shop-cart-summary__row--total {
    flex-wrap: wrap;
    padding-top: 1rem;
    border-top: 1px solid var(--roros-color-border-strong);
}

.shop-cart-summary__row--total dt {
    font-size: var(--roros-font-size-label);
    font-weight: 500;
    line-height: var(--roros-line-height-label);
}

.shop-cart-summary__row--total dd {
    font-family: var(--roros-font-family-display);
    font-size: var(--roros-font-size-h3);
    line-height: var(--roros-line-height-h3);
}

/* WooCommerce adds «(inkl. kr … MVA)» to the checkout total */
.shop-cart-summary__row--total dd small {
    display: block;
    font-family: var(--roros-font-family-ui);
    font-size: var(--roros-font-size-caption);
    line-height: var(--roros-line-height-caption);
    color: var(--roros-color-text-secondary);
}

.shop-cart-summary__checkout {
    text-align: center;
    text-decoration: none;
}

.shop-cart-summary__checkout:hover {
    color: var(--roros-color-text-inverse);
}

.shop-cart-summary .shop-payment {
    justify-content: center;
}

/* «Du vil kanskje også like» */

.shop-cart__related {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 3rem;
}

.shop-page .shop-cart__related-title {
    margin: 0;
    font-family: var(--roros-font-family-display);
    font-size: var(--roros-font-size-h3);
    font-weight: normal;
    line-height: var(--roros-line-height-h3);
    color: var(--roros-color-text-primary);
}

/* Checkout – Kustom's iframe to the left, the summary to the right. The markup is the
   plugin's own template (#kco-wrapper, #kco-iframe, #kco-order-review). */

.shop-checkout #kco-wrapper {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 24rem;
    grid-template-areas: "payment summary";
    gap: 3rem;
    align-items: start;
}

/* Uncode floats Kustom's two columns at fixed widths – the grid places them here */
.shop-checkout #kco-wrapper > :is(#kco-order-review, #kco-iframe) {
    float: none;
    width: auto;
    margin: 0;
}

.shop-checkout #kco-wrapper {
    padding: 0;
}

.shop-checkout #kco-iframe {
    grid-area: payment;
    min-width: 0;
}

.shop-checkout #kco-order-review {
    grid-area: summary;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.shop-cart-summary--checkout {
    border-bottom: 0; /* Uncode's .woocommerce-checkout-review-order-table */
}

.shop-checkout__items {
    margin: 0;
    padding: 0;
    list-style: none;
}

.shop-checkout__item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin: 0;
    padding-block: 0.75rem;
    border-bottom: 1px solid var(--roros-color-border-subtle);
}

.shop-checkout__item:first-child {
    padding-top: 0;
}

.shop-checkout__thumb {
    flex-shrink: 0;
    width: 3.5rem;
    height: 3.5rem;
    overflow: hidden;
    background: var(--roros-color-bg-page);
}

.shop-checkout__thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.shop-checkout__name {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.shop-checkout__title {
    font-size: var(--roros-font-size-body-sm);
    font-weight: 500;
    line-height: var(--roros-line-height-body-sm);
}

.shop-checkout__meta {
    font-size: var(--roros-font-size-caption);
    line-height: var(--roros-line-height-caption);
    color: var(--roros-color-text-secondary);
}

.shop-checkout__price {
    flex-shrink: 0;
    font-size: var(--roros-font-size-body-sm);
    line-height: var(--roros-line-height-body-sm);
    white-space: nowrap;
}

.shop-checkout__before {
    margin-bottom: 1.5rem;
}

.shop-checkout__before:empty {
    display: none;
}

.shop-checkout__before .woocommerce-notices-wrapper:not(:empty) {
    width: auto;
    margin: 0;
}

/* Fields Kustom moves out of its iframe – order notes, «create an account» */

.shop-checkout #kco-extra-checkout-fields {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.shop-checkout #kco-extra-checkout-fields :is(h3, label) {
    margin: 0;
    font-family: var(--roros-font-family-ui);
    font-size: var(--roros-font-size-label);
    font-weight: 500;
    line-height: var(--roros-line-height-label);
    color: var(--roros-color-text-primary);
}

.shop-checkout #kco-extra-checkout-fields :is(textarea, input[type="text"], input[type="email"], input[type="password"]) {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--roros-color-border-strong);
    background: var(--roros-color-bg-page);
    font-family: var(--roros-font-family-ui);
    font-size: var(--roros-font-size-input);
    line-height: var(--roros-line-height-input);
    color: var(--roros-color-text-primary);
}

.shop-checkout #kco-extra-checkout-fields input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    margin: 0 0.5rem 0 0;
    appearance: auto;
    vertical-align: middle;
}

.shop-checkout .shop-cart__continue {
    display: inline-block;
}

/* WooCommerce notices on the shop pages – «Handlekorja ble oppdatert», «… fjernet. Angre?», errors,
   and the checkout's «log in» / «coupon» prompts */

.shop-redesign .woocommerce-notices-wrapper:not(:empty) {
    width: min(100% - 2rem, 67.5rem);
    margin: 1.5rem auto 0;
}

.shop-redesign :is(.woocommerce-notices-wrapper, .shop-checkout__before) :is(.woocommerce-message, .woocommerce-info, .woocommerce-error) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin: 0 0 0.5rem;
    padding: 0.75rem 1rem;
    border: 0;
    background: var(--roros-color-surface-cream);
    font-family: var(--roros-font-family-ui);
    font-size: var(--roros-font-size-body-sm);
    font-weight: 400;
    line-height: var(--roros-line-height-body-sm);
    color: var(--roros-color-text-primary);
    list-style: none;
}

.shop-redesign :is(.woocommerce-notices-wrapper, .shop-checkout__before) .woocommerce-error {
    background: var(--roros-color-surface-accent);
}

.shop-redesign :is(.woocommerce-notices-wrapper, .shop-checkout__before) :is(.woocommerce-message, .woocommerce-info, .woocommerce-error)::before {
    content: none;
}

.shop-redesign :is(.woocommerce-notices-wrapper, .shop-checkout__before) a {
    font: inherit;
    color: inherit;
    text-decoration: underline;
}

/* Mobile – 959px matches the header's mobile/desktop switch */

@media (max-width: 959px) {
    .shop-minicart__content {
        padding: 1rem;
    }

    .shop-cart,
    .shop-checkout {
        margin-top: 1rem;
        padding-bottom: 4rem;
    }

    .shop-cart__header {
        gap: 0.75rem;
        margin-bottom: 1.5rem;
    }

    .shop-cart__layout {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
        grid-template-areas:
            "items"
            "aside"
            "continue";
        gap: 1.5rem;
    }

    .shop-page .shop-cart__continue {
        padding-top: 0;
    }

    .shop-cart-line--large {
        gap: 0.75rem;
    }

    .shop-cart-line--large .shop-cart-line__actions {
        gap: 0.5rem 0.75rem;
    }

    /* Not on the mobile cart page in Figma */
    .shop-cart__related {
        display: none;
    }

    .shop-checkout #kco-wrapper {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "summary"
            "payment";
        gap: 1.5rem;
    }
}
