/**
 * @author      Ghulam Dastgir <ghulam.dastgir@knfilters.com>
 * @copyright   © K&N Engineering, Inc. All rights reserved.
 * SPDX-License-Identifier: NONE
 *
 * Scoped styles for the KN auto-gift selector banner on the cart page.
 * Colour tokens mirror theme-frontend-kn:
 *   red    #f32835  (@color-primary-a)
 *   orange #ff6e00  (@color-primary-c)
 *   dark   #1d1d1d  (@color-secondary-a)
 *   mid    #636363  (@color-secondary-b)
 *   rule   #dedede  (@color-secondary-c)
 *   bg     #f9f9f9  (@color-secondary-d)
 */

/* ─── Layout: neutralise the -66px summary pull when the banner is present ── */
/*
 * The theme pulls .cart-summary up by -66px at ≥992px to align it with the
 * page title. When the gift banner occupies checkout.cart.form.before (full
 * width, above the float columns) that negative margin drags the summary into
 * the banner. We reset it only when the selector is rendered.
 */
.checkout-cart-index .kn-gift-selector-wrapper ~ .cart-container .cart-summary,
.checkout-cart-index .cart-container:has(.kn-gift-selector-wrapper) .cart-summary {
    margin-top: 0;
}

/* Fallback for browsers without :has() — JS adds .kn-gift-active to body */
@media (min-width: 992px) {
    body.kn-gift-active.checkout-cart-index .cart-container .cart-summary {
        margin-top: 0;
    }
}

/* ─── Wrapper ────────────────────────────────────────────────────────────── */

.kn-gift-selector-wrapper {
    margin: 0 0 24px;
    box-sizing: border-box;
    /* BFC: fully contains the banner before the float columns begin */
    overflow: hidden;
}

/* ─── Banner card ────────────────────────────────────────────────────────── */

.kn-gift-selector-banner {
    background: #ffffff;
    border: 1px solid #dedede;
    border-top: 3px solid #f32835;
    border-radius: 2px;
    padding: 20px 24px;
    box-sizing: border-box;
    font-family: inherit; /* Montserrat via body */
}

/* ─── Title ──────────────────────────────────────────────────────────────── */

.kn-gift-selector-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1d1d1d;
    margin: 0 0 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Red accent rule under the title */
.kn-gift-selector-title::after {
    content: '';
    display: block;
    width: 32px;
    height: 2px;
    background: #f32835;
    margin-top: 6px;
    margin-bottom: 10px;
}

/* ─── Description ────────────────────────────────────────────────────────── */

.kn-gift-selector-desc {
    margin: 0 0 16px;
    font-size: 0.95rem;
    color: #1d1d1d;
}

/* ─── Size button grid ───────────────────────────────────────────────────── */

.kn-gift-selector-sizes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.kn-gift-size-btn {
    min-width: 52px;
    min-height: 44px;
    padding: 8px 16px;
    border: 1px solid #dedede;
    border-radius: 2px;
    background: #f9f9f9;
    color: #1d1d1d;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    line-height: 1.4;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    box-sizing: border-box;
    position: relative;
}

.kn-gift-size-btn:hover:not(:disabled) {
    border-color: #ff6e00;
    background: #ffffff;
    color: #1d1d1d;
}

.kn-gift-size-btn:focus-visible {
    outline: 3px solid #f32835;
    outline-offset: 2px;
}

/* Selected: K&N red fill, white text, checkmark */
.kn-gift-size-btn.selected {
    border-color: #f32835;
    background: #f32835;
    color: #ffffff;
}

.kn-gift-size-btn.selected:hover:not(:disabled) {
    border-color: #ff6e00;
    background: #ff6e00;
    color: #ffffff;
}

/* Disabled / out-of-stock */
.kn-gift-size-btn.out-of-stock,
.kn-gift-size-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f9f9f9;
    color: #636363;
    border-color: #dedede;
}

/* Sold-out label inside button */
.kn-gift-size-out {
    display: block;
    font-size: 0.7rem;
    font-weight: 400;
    color: inherit;
    line-height: 1.2;
}

/* Checkmark for selected state */
.kn-gift-size-check {
    margin-left: 4px;
    font-style: normal;
}

/* ─── Selected confirmation message ─────────────────────────────────────── */

.kn-gift-selector-selected-msg {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1d1d1d;
    margin: 0 0 12px;
}

/* ─── Decline / secondary action ─────────────────────────────────────────── */

.kn-gift-selector-decline {
    margin-top: 8px;
}

.kn-gift-selector-decline-btn {
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    color: #1d1d1d;
    background: #ffffff;
    border: 1px solid #dedede;
    border-radius: 2px;
    padding: 8px 16px;
    min-height: 44px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.kn-gift-selector-decline-btn:hover {
    border-color: #636363;
    color: #1d1d1d;
}

.kn-gift-selector-decline-btn:focus-visible {
    outline: 3px solid #f32835;
    outline-offset: 2px;
}

/* ─── Declined / unavailable states ─────────────────────────────────────── */

.kn-gift-selector-unavailable,
.kn-gift-selector-declined {
    margin: 0;
    font-size: 0.95rem;
    color: #636363;
}

/* ─── "Change my mind" link ──────────────────────────────────────────────── */

.kn-gift-selector-reopen {
    background: none;
    border: none;
    color: #f32835;
    text-decoration: underline;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    padding: 0;
}

.kn-gift-selector-reopen:hover {
    color: #ff6e00;
}

.kn-gift-selector-reopen:focus-visible {
    outline: 3px solid #f32835;
    outline-offset: 2px;
}

/* ─── Inline error ───────────────────────────────────────────────────────── */

.kn-gift-selector-error {
    color: #f32835;
    font-size: 0.9rem;
    margin-top: 10px;
}

/* ─── Loader ─────────────────────────────────────────────────────────────── */

.kn-gift-selector-loading {
    color: #636363;
    font-size: 0.9rem;
    margin-top: 8px;
}

/* ─── Responsive: 768–991px tablet ──────────────────────────────────────── */

@media (min-width: 768px) and (max-width: 991px) {
    .kn-gift-selector-wrapper {
        margin-bottom: 20px;
    }

    .kn-gift-selector-banner {
        padding: 18px 20px;
    }
}

/* ─── Responsive: ≤767px mobile ─────────────────────────────────────────── */

@media (max-width: 767px) {
    .kn-gift-selector-banner {
        padding: 16px;
    }

    .kn-gift-selector-sizes {
        gap: 6px;
    }

    .kn-gift-size-btn {
        min-width: 44px;
        padding: 8px 12px;
        font-size: 0.95rem;
    }

    .kn-gift-selector-decline-btn {
        width: 100%;
    }
}
