/**
 * WC Gift with Purchase — cart-page chooser panel
 *
 * @version 0.10.0
 */

/* ===============================
   COLOURS

   Every colour in the chooser comes from these variables, so a site can
   restyle it without editing this file: re-declare any of them on :root
   in a stylesheet loaded after this one (e.g. wp_add_inline_style on
   'wcgwp-cart'). The defaults are the original green.
================================ */
:root {
    --wcgwp-border:     #2e7d32; /* panel border, chosen tile when the offer is complete */
    --wcgwp-bg:         #f1f8f2; /* panel background */
    --wcgwp-text:       #2e7d32; /* title, chevron, arrows, FREE label, gift notes */
    --wcgwp-text-hover: #1b5e20; /* chevron + arrow hover */
    --wcgwp-divider:    #cfe6d2; /* line between offers */
    --wcgwp-line:       #d8e6d9; /* tile + arrow borders */
    --wcgwp-hover-bg:   #e3f1e5; /* arrow hover background */
    --wcgwp-muted:      #5a6b5c; /* "1–4 of 6" count */
}
.wcgwp-panel,
.wcgwp-panel * {
    box-sizing: border-box; /* padding never causes horizontal overflow */
}
.wcgwp-panel {
    width: 100%;
    margin: 0 0 24px; /* equal (0) horizontal margin */
}
.wcgwp-panel-inner {
    border: 2px solid var(--wcgwp-border);
    border-radius: 8px;
    background: var(--wcgwp-bg);
    padding: 16px; /* equal padding all round */
}
.wcgwp-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}
.wcgwp-panel-title {
    font-size: 1.15em;
    font-weight: 700;
    color: var(--wcgwp-text);
}

/* ===============================
   COLLAPSE/EXPAND CHEVRON

   Same affordance as the header search box (wc-catalogue-search): a
   bare chevron button on the title row. When clicked, the gift options
   are hidden so only the title bar remains, and the chevron
   rotates 180° to point down. The collapsed state is held in JS so it
   survives the panel's re-renders as the cart updates.
================================ */
.wcgwp-collapse {
    flex: 0 0 auto;
    background: transparent;
    border: 0;
    padding: .35em .5em;
    cursor: pointer;
    color: var(--wcgwp-text);
    box-shadow: none;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.wcgwp-collapse:hover,
.wcgwp-collapse:focus {
    color: var(--wcgwp-text-hover);
    background: transparent;
    box-shadow: none;
    outline: 0;
}
.wcgwp-icon-chevron {
    display: block;
    transition: transform .2s ease;
}
/* Chevron up = expanded (default); rotate 180° to point down when
   collapsed, matching the search box. */
.wcgwp-panel-inner.wcgwp-collapsed .wcgwp-icon-chevron {
    transform: rotate(180deg);
}
.wcgwp-panel-inner.wcgwp-collapsed .wcgwp-panel-body {
    display: none;
}
/* Collapsed, the title row is the whole panel — drop its bottom gap so
   the box hugs the title evenly. */
.wcgwp-panel-inner.wcgwp-collapsed .wcgwp-panel-head {
    margin-bottom: 0;
}
.wcgwp-rule + .wcgwp-rule {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--wcgwp-divider);
}
.wcgwp-rule-head {
    margin-bottom: 10px;
}
.wcgwp-choose {
    color: #444;
}
/* ===============================
   GIFT STRIP

   Each offer's gifts sit in one left/right strip of small tiles, so the
   panel is one row tall however many gifts there are. Driven by the Page
   Builder carousel's Swiper in free-scroll mode when the page has it;
   `.wcgwp-native` is the fallback, a plain scrolling row. Wide strips show
   whole tiles with round arrows either side; phones swipe, with the next
   tile peeking in, and the arrows step aside.
================================ */
.wcgwp-strip {
    position: relative;
    padding: 0 46px; /* room for the arrows */
}
/* Force the list flush. Themes commonly indent content <ul>s with a rule like
   `.woocommerce ul { padding-left: … }`, whose specificity beats a plain
   `.wcgwp-opts` selector — that would shift the first tile off the strip's
   edge. `!important` (scoped to the panel) keeps the strip even. */
.wcgwp-panel .wcgwp-opts {
    list-style: none;
    margin: 0 !important;
    padding: 0 !important;
}
.wcgwp-panel .wcgwp-rule {
    margin-left: 0;
    margin-right: 0;
}
/* Tiles in a row share the tallest one's height, button on the bottom. */
.wcgwp-strip .wcgwp-opt.swiper-slide {
    height: auto;
}
.wcgwp-opt {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    margin: 0;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--wcgwp-line);
    border-radius: 6px;
    text-align: center;
}
.wcgwp-opt.is-chosen {
    opacity: .6;
}
/* Every gift of the offer is chosen: the chosen ones stand out, the rest
   step back (they can't be added until a chosen gift leaves the cart). */
.wcgwp-rule.is-complete .wcgwp-opt {
    opacity: .45;
}
.wcgwp-rule.is-complete .wcgwp-opt.is-chosen {
    opacity: 1;
    border-color: var(--wcgwp-border);
}
.wcgwp-rule.is-complete .wcgwp-choose {
    color: var(--wcgwp-text);
    font-weight: 600;
}
.wcgwp-opt-img {
    display: block;
    width: 100%;
    height: 72px;
    object-fit: contain;
    border-radius: 4px;
    margin: 0;
}
.wcgwp-opt-name {
    flex: 1 1 auto;
    font-size: .85em;
    line-height: 1.25;
    margin: 0;
    /* Two lines at most; the full name is in the cart once added. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}
.wcgwp-opt .wcgwp-add {
    width: 100%;
    margin: 0;
    padding: 6px 8px;
    font-size: .85em;
    line-height: 1.2;
    white-space: nowrap;
}

/* Arrows: round, white, coloured chevron — the carousel's arrows in the
   panel's colours. Swiper marks them disabled at each end, and locked
   (hidden here) when every gift already fits. */
.wcgwp-nav {
    position: absolute;
    top: calc(50% - 10px); /* centred on the tiles, not the count below */
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--wcgwp-line);
    border-radius: 50%;
    background: #fff;
    color: var(--wcgwp-text);
    box-shadow: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: background .2s ease, opacity .2s ease;
}
.wcgwp-nav svg {
    display: block;
}
.wcgwp-prev { left: 0; }
.wcgwp-next { right: 0; }
.wcgwp-nav:hover,
.wcgwp-nav:focus-visible {
    background: var(--wcgwp-hover-bg);
    color: var(--wcgwp-text-hover);
}
.wcgwp-nav:disabled,
.wcgwp-nav.swiper-button-disabled {
    opacity: .35;
    cursor: default;
    background: #fff;
}
.wcgwp-count {
    margin-top: 6px;
    min-height: 1.2em;
    font-size: .8em;
    line-height: 1.2;
    color: var(--wcgwp-muted);
    text-align: center;
}
/* Every gift fits: no arrows, no count, no side room. */
.wcgwp-strip.is-locked {
    padding: 0;
}
.wcgwp-strip.is-locked .wcgwp-nav,
.wcgwp-strip.is-locked .wcgwp-count {
    display: none;
}

/* Fallback without Swiper: a native free-scrolling row. */
.wcgwp-native .wcgwp-viewport {
    overflow-x: auto;
    scrollbar-width: none;
}
.wcgwp-native .wcgwp-viewport::-webkit-scrollbar {
    display: none;
}
.wcgwp-native .wcgwp-opts {
    display: flex;
    gap: 12px;
}
.wcgwp-native .wcgwp-opt {
    flex: 0 0 130px;
}
.wcgwp-native .wcgwp-count {
    display: none;
}

/* Gift cart-line presentation (classic cart + shared markers) */
.wcgwp-gift-free {
    color: var(--wcgwp-text);
    font-weight: 700;
    text-transform: uppercase;
}
.wcgwp-gift-qty {
    font-weight: 600;
}
.wcgwp-gift-note {
    color: var(--wcgwp-text);
    font-weight: 600;
}

/* Phones (≤600px): the strip is swiped, so the arrows step aside and the
   tiles use the full width, the next one peeking in at the edge. */
@media (max-width: 600px) {
    .wcgwp-panel-inner {
        padding: 14px;
    }
    .wcgwp-strip {
        padding: 0;
    }
    .wcgwp-nav {
        display: none;
    }
    .wcgwp-opt-img {
        height: 64px;
    }
    .wcgwp-native .wcgwp-opt {
        flex-basis: 40%;
    }
}
