/* =========================================================
   LMGroup.se — site.css (Tailwind-first, production sane)
   - No legacy masthead measuring
   - No "all: unset"
   - Only: base, cookie, page transitions, cart item UI, drawers safety
   ========================================================= */

/* ================= Base / Tokens ================= */
:root {
    --bg: #fff;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e5e7eb;
    --brand: #CEE646;
    --brand-ink: #111;
    --lm-accent: #CEEB46;
    /* page transitions */
    --pt-duration: 360ms;
    --pt-ease: cubic-bezier(.22,.61,.36,1);
    /* z */
    --z-overlay: 850;
    --z-drawer: 900;
    --z-top: 2000;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,"Apple Color Emoji","Segoe UI Emoji";
    color: var(--ink);
    background: var(--bg);
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

body.no-scroll {
    overflow: hidden !important;
}

/* Optional: anchor jumps under sticky masthead */
:where(h1,h2,h3,h4,h5,h6,[id]) {
    scroll-margin-top: 96px;
}

/* ================= Cookie banner ================= */
.cookie-banner {
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    z-index: 1400;
    max-width: 640px;
    width: 95%;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 10px 25px rgba(0,0,0,.10);
    padding: 16px;
    padding-right: 52px;
}

.cookie-text {
    margin: 0 0 12px;
    font-size: 14px;
    color: #111827;
    line-height: 1.5;
}

.cookie-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.cookie-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: #6b7280;
    border-radius: 10px;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, transform .15s ease;
}

    .cookie-close:hover {
        background: #f3f4f6;
        color: #111827;
    }

    .cookie-close:active {
        transform: scale(0.96);
    }

.btn {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid #000;
    background: #000;
    color: #fff;
    cursor: pointer;
    transition: .15s;
}

.btn-outline {
    background: #fff;
    color: #111827;
    border-color: #9ca3af;
}

.btn:hover {
    background: var(--brand) !important;
    border-color: var(--brand) !important;
    color: #000 !important;
}

@media (max-width: 640px) {
    .cookie-banner {
        width: calc(100% - 16px);
        padding: 14px;
        padding-top: 44px;
        padding-right: 14px;
    }

    .cookie-actions {
        justify-content: stretch;
    }

        .cookie-actions .btn {
            flex: 1 1 100%;
        }

    .cookie-close {
        top: 8px;
        right: 8px;
    }
}
/* ================= Page transitions ================= */
.pt-topbar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    z-index: 99999;
    pointer-events: none;
    background: linear-gradient(90deg, #111827 0%, #CEEB46 55%, #111827 100%);
    box-shadow: 0 0 12px rgba(206, 235, 70, 0.45);
    transition: width 0.18s ease-out, opacity 0.25s ease;
    opacity: 1;
}

    .pt-topbar.loading {
        opacity: 1;
    }

    .pt-topbar.done {
        transition: width 0.22s ease-out, opacity 0.35s ease;
    }

.pt-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    pointer-events: none;
    background: radial-gradient(circle at top center, rgba(255,255,255,0.45), rgba(255,255,255,0.08) 35%, rgba(255,255,255,0) 70%), rgba(255,255,255,0.18);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
    opacity: 0;
    transition: opacity 0.22s ease;
}

    .pt-overlay.active {
        opacity: 1;
    }

#pageShell {
    transform-origin: center top;
    will-change: opacity, transform, filter;
}

    #pageShell.pt-leave {
        opacity: 0.32;
        transform: translateY(10px) scale(0.992);
        filter: blur(2px);
        transition: opacity 0.22s ease, transform 0.22s ease, filter 0.22s ease;
    }

    #pageShell.pt-enter {
        animation: pt-enter-kf 0.42s cubic-bezier(.2,.8,.2,1);
    }

@keyframes pt-enter-kf {
    0% {
        opacity: 0.3;
        transform: translateY(14px) scale(0.992);
        filter: blur(3px);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .pt-topbar,
    .pt-overlay,
    #pageShell,
    #pageShell.pt-leave,
    #pageShell.pt-enter {
        transition: none !important;
        animation: none !important;
        transform: none !important;
        filter: none !important;
    }
}

/* ================= Drawers & overlay (works with your JS) ================= */
/* These are “safety rails”. Tailwind does layout; this ensures nothing breaks. */
#overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
    z-index: var(--z-overlay);
}

    #overlay.is-open {
        opacity: 1;
        pointer-events: auto;
    }

/* mobile nav drawer (your #nav) */
#nav {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(86vw, 360px);
    background: #fff;
    box-shadow: 0 30px 80px rgba(0,0,0,.22);
    transform: translateX(-100%);
    transition: transform .18s ease;
    z-index: var(--z-drawer);
    display: block;
}

    #nav.is-open {
        transform: translateX(0);
    }

/* cart drawer */
#cart {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    width: min(92vw, 420px);
    background: #fff;
    box-shadow: 0 30px 80px rgba(0,0,0,.22);
    transform: translateX(100%);
    transition: transform .18s ease;
    z-index: var(--z-drawer);
    display: flex; /* IMPORTANT: keep your flex column layout alive */
    flex-direction: column; /* IMPORTANT */
}

    #cart.is-open {
        transform: translateX(0);
    }

/* compat if anything still adds .open */
#nav.open {
    transform: translateX(0) !important;
}

#cart.open {
    transform: translateX(0) !important;
}

/* cart badge sanity */
#cart-count {
    line-height: 1 !important;
    font-weight: 700;
}

/* Desktop nav failsafe if Tailwind ever fails to load */
@media (min-width: 768px) {
    nav[data-desktop-nav] {
        display: block !important;
    }
}

@media (max-width: 767.98px) {
    nav[data-desktop-nav] {
        display: none !important;
    }
}

/* ================= Cart: product list UI (inside #cart) ================= */
#cart #cart-items {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Optional: if cart.js uses .cart-list */
#cart .cart-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#cart .cart-item {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 12px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

    #cart .cart-item:last-child {
        border-bottom: 0;
    }

#cart .cart-product-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

#cart .cart-product-image {
    width: 64px;
    height: 64px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    display: grid;
    place-items: center;
    overflow: hidden;
}

    #cart .cart-product-image img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        display: block;
    }

#cart img.cart-product-image {
    width: 64px;
    height: 64px;
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    display: block;
}

#cart .cart-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

#cart .cart-name {
    display: block;
    font-size: .98rem;
    font-weight: 700;
    color: #111827;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

    #cart .cart-name:hover {
        text-decoration: underline;
    }

#cart .cart-attr {
    font-size: .85rem;
    color: #6b7280;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#cart .cart-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: .92rem;
    color: #1f2937;
}

#cart .cart-product-quantity {
    font-weight: 600;
}

#cart .cart-price {
    display: flex;
    align-items: center;
    gap: 8px;
}

#cart .cart-product-price {
    font-weight: 800;
    color: #111827;
}

#cart .cart-product-oldprice {
    color: #9ca3af;
    text-decoration: line-through;
    font-weight: 600;
    font-size: .9rem;
}

#cart .cart-quantity-controls {
    display: flex;
    gap: 8px;
    margin-top: 2px;
}

    #cart .cart-quantity-controls button {
        appearance: none;
        border: 1px solid #d1d5db;
        background: #f3f4f6;
        width: 32px;
        height: 32px;
        border-radius: 8px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: background .15s ease, transform .1s ease;
        color: #000;
    }

        #cart .cart-quantity-controls button:hover {
            background: #e5e7eb;
        }

        #cart .cart-quantity-controls button:active {
            transform: translateY(1px);
        }

#cart .cart-remove {
    border-color: #fecaca;
    background: #fff1f2;
    color: #b91c1c;
    padding: 0 10px;
    height: 32px;
    border-radius: 8px;
}

    #cart .cart-remove:hover {
        background: #fee2e2;
        color: #991b1b;
    }

#cart .cart-message {
    padding: 10px 0;
    color: #6b7280;
    font-size: .95rem;
    text-align: center;
}

/* Responsive tweaks */
@media (max-width:420px) {
    #cart .cart-item {
        grid-template-columns: 64px 1fr;
        gap: 10px;
    }

    #cart .cart-quantity-controls button {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }

    #cart .cart-remove {
        height: 36px;
    }
}

@media (pointer:coarse) {
    #cart .cart-quantity-controls button {
        width: 38px;
        height: 38px;
    }
}

/* Fancy checkout button (kept) */
button.checkout-button,
#cart button.checkout-button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: .6rem !important;
    width: 100% !important;
    min-height: 52px !important;
    padding: 14px 18px !important;
    border-radius: 16px !important;
    border: 0 !important;
    font-weight: 900 !important;
    font-size: 1rem !important;
    letter-spacing: .02em !important;
    color: #fff !important;
    background: linear-gradient(180deg, rgba(255,255,255,.10), transparent) padding-box, linear-gradient(135deg, #0b1324 0%, #0f1b35 36%, #22c55e 115%) border-box !important;
    background-size: 180% 180% !important;
    background-position: 0% 50% !important;
    box-shadow: 0 14px 28px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.08) !important;
    cursor: pointer !important;
    transition: transform .18s ease, box-shadow .18s ease, filter .18s ease, background-position .38s ease !important;
    position: relative;
    isolation: isolate;
}

    button.checkout-button:hover,
    #cart button.checkout-button:hover {
        transform: translateY(-1px);
        background-position: 100% 50%;
        filter: brightness(1.03);
        box-shadow: 0 18px 36px rgba(0,0,0,.28), inset 0 2px 0 rgba(255,255,255,.10) !important;
    }

    button.checkout-button:active,
    #cart button.checkout-button:active {
        transform: translateY(0);
        box-shadow: 0 10px 22px rgba(0,0,0,.20), inset 0 1px 0 rgba(255,255,255,.06) !important;
    }

    button.checkout-button:focus-visible,
    #cart button.checkout-button:focus-visible {
        outline: none;
        box-shadow: 0 0 0 4px color-mix(in srgb, #22c55e 28%, transparent), 0 0 0 1.5px rgba(255,255,255,.65) inset, 0 18px 36px rgba(0,0,0,.28) !important;
    }

    button.checkout-button[disabled],
    #cart button.checkout-button[disabled] {
        opacity: .65;
        cursor: not-allowed;
        filter: grayscale(.1);
        transform: none;
    }

/* Loading / success / error states */
.checkout-button.is-loading {
    pointer-events: none;
    filter: saturate(.9) brightness(.98);
}

    .checkout-button.is-loading::before {
        content: "";
        position: absolute;
        left: 50%;
        top: 50%;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        border: 2px solid rgba(255,255,255,.65);
        border-top-color: transparent;
        transform: translate(-50%,-50%);
        animation: cb-spin .8s linear infinite;
        z-index: 1;
    }

.checkout-button.is-success {
    background: linear-gradient(180deg, rgba(255,255,255,.10), transparent) padding-box, linear-gradient(135deg, #0b1324 0%, #0f1b35 20%, #16a34a 100%) border-box !important;
    animation: cb-pulse .6s ease;
}

    .checkout-button.is-success::before {
        content: "";
        position: absolute;
        left: 50%;
        top: 50%;
        width: 16px;
        height: 8px;
        border: 2px solid #fff;
        border-top: none;
        border-right: none;
        transform: translate(-50%,-60%) rotate(-45deg);
        opacity: .95;
    }

.checkout-button.is-error {
    background: linear-gradient(180deg, rgba(255,255,255,.08), transparent) padding-box, linear-gradient(135deg, #0b1324 0%, #0f1b35 28%, #ef4444 115%) border-box !important;
    animation: cb-shake .36s ease;
}

@keyframes cb-spin {
    to {
        transform: translate(-50%,-50%) rotate(360deg);
    }
}

@keyframes cb-pulse {
    0% {
        filter: brightness(1)
    }

    50% {
        filter: brightness(1.08)
    }

    100% {
        filter: brightness(1)
    }
}

@keyframes cb-shake {
    0%,100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-3px);
    }

    40% {
        transform: translateX(3px);
    }

    60% {
        transform: translateX(-2px);
    }

    80% {
        transform: translateX(2px);
    }
}

@media (prefers-reduced-motion: reduce) {
    button.checkout-button {
        transition: none !important;
    }

    .checkout-button.is-success,
    .checkout-button.is-error {
        animation: none;
    }
}

#cart .cart-empty {
    min-height: 220px;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 18px 12px;
    color: #64748b;
    font-weight: 600;
}

/* När korgen är tom: centrera tomtexten i body-ytan */
#cart[aria-hidden="false"] .cart-body--empty {
    display: grid;
    place-items: center;
}

/* Bonus: lite “card” känsla för tom-state */
#cart .cart-empty__card {
    width: 100%;
    max-width: 320px;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 16px;
    background: #f9fafb;
}

/* --- SVG safety net: stop giant stretching --- */
svg {
    display: inline-block;
    vertical-align: middle;
    max-width: 100%;
    height: auto;
}

/* Lock sizes where we use inline icons */
.hero-cta svg,
.lm-fitment__btn svg {
    width: 18px !important;
    height: 18px !important;
    flex: 0 0 18px;
}

.lm-fitment__btn {
    position: relative;
    overflow: hidden;
}

    .lm-fitment__btn::after {
        pointer-events: none;
    }


/* tiny helpers (because Tailwind CDN can't see dynamic class toggles sometimes) */
.is-hidden {
    display: none !important;
}

/* Loading overlay */
#loading {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(255,255,255,.72);
    backdrop-filter: blur(3px);
}

    #loading.is-hidden {
        display: none !important;
    }

.fitment-spinner {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 2px solid rgba(0,0,0,.2);
    border-top-color: rgba(0,0,0,.8);
    display: inline-block;
    animation: spin .8s linear infinite;
}

/* Dialog baseline */
dialog::backdrop {
    background: rgba(0,0,0,.45);
}

dialog[open] {
    display: block;
}
