/* Variation Image Swatches */

/* Hide WC's "Clear" / reset_variations link.
   The post-launch swatch redesign (task #21) removes it entirely; hiding now
   avoids the misplaced link visual glitch under the swatch grid. */
.reset_variations {
    display: none !important;
}

/* Hide the WooCommerce attribute label (th) when swatches replace the dropdown —
   our .vis-selected-label already shows "Color: [value]" inline.
   Make the value td span full width so swatches get more room. */
.variations tr:has(.vis-swatch-grid) th.label {
    display: none;
}

.variations tr:has(.vis-swatch-grid) td.value {
    width: 100%;
}

.vis-selected-label {
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.4;
}

.vis-label-prefix {
    font-weight: 600;
}

.vis-label-value {
    font-weight: 400;
}

/* Swatch grid — responsive flex layout */
.vis-swatch-grid {
    display: flex;
    flex-wrap: wrap;
    column-gap: 6px;
    row-gap: 16px;
    margin-bottom: 10px;
}

/* Individual swatch button — column: framed thumb on top, plain text label below */
.vis-swatch {
    position: relative;
    box-sizing: border-box;
    width: 100px;
    height: auto;
    margin: 0; /* override Flatsome's button margin */
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: none;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    line-height: 1;
    text-transform: none; /* override Flatsome button uppercase */
    font-weight: normal;
}

/* Image area — the framed square. Width inherits from parent .vis-swatch
   (which uses align-items: stretch) so it adapts on every breakpoint without
   needing per-breakpoint width overrides. */
.vis-swatch-thumb {
    position: relative;
    display: block;
    width: 100%;
    height: 100px;
    box-sizing: border-box;
    border: 2px solid #ddd;
    border-radius: 4px;
    background: #fff;
    overflow: hidden;
    transition: border-color 0.15s ease;
}

.vis-swatch:hover .vis-swatch-thumb {
    border-color: #888;
}

.vis-swatch.vis-selected .vis-swatch-thumb {
    border-color: #333;
    box-shadow: 0 0 0 1px #333;
}

/* Color name — plain text below the box, left-aligned, single line, ellipsis.
   No explicit width: parent .vis-swatch is flex with align-items:stretch,
   so the name span automatically matches the swatch width on every breakpoint. */
.vis-swatch-name {
    display: block;
    margin-top: 2px;
    padding: 0 2px 0 4px;
    font-size: 11px;
    line-height: 1.3;
    color: #333;
    text-align: left;
    text-transform: none;
    font-weight: normal;
    background: transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Discount sticker on on-sale variations (user_notes.md "Mark variations
   with discount"). #d26e4b = Flatsome's secondary color, the same red-orange
   the shop's "Tilbud" card badge uses. Sits INSIDE the framed thumb (which
   clips overflow); z-index keeps it above the OOS diagonal overlay (z=1).
   pointer-events off so clicks land on the swatch button. */
.vis-sale-badge {
    position: absolute;
    top: 3px;
    right: 3px;
    z-index: 2;
    padding: 1px 5px;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.4;
    color: #fff;
    background: #d26e4b;
    border-radius: 3px;
    pointer-events: none;
}

/* Text pills have no thumb frame — hang the sticker off the top-right corner. */
.vis-swatch--text .vis-sale-badge {
    top: -7px;
    right: -6px;
}

/* ===== Colour search (standalone PDPs; kits get theirs from the CBM modal).
   Input styling matches .cbm-color-modal-search so the two features read as
   one system. */
.vis-swatch-search {
    position: relative; /* anchors the clear (×) button */
    max-width: 420px;
    margin: 0 0 10px;
}
.vis-swatch-search__input {
    display: block;
    width: 100%;
    padding: 8px 36px 8px 12px; /* right space for the × */
    font-size: 0.95em;
    border: 1.5px solid #ddd;
    border-radius: 4px;
    box-shadow: none;
}
.vis-swatch-search__input:focus {
    border-color: #888;
    outline: none;
    box-shadow: none;
}
/* Hide the browser's own type=search cancel × — we render our own
   (consistent across browsers, big enough for touch). */
.vis-swatch-search__input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}
/* Clear (×): only visible while the field has text — pure CSS via
   :placeholder-shown, so no JS state to keep in sync. */
.vis-swatch-search__clear {
    display: none;
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    color: #888;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    text-transform: none;
    font-weight: normal;
}
.vis-swatch-search__input:not(:placeholder-shown) + .vis-swatch-search__clear {
    display: block;
}
.vis-swatch-search__clear:hover,
.vis-swatch-search__clear:focus {
    color: #333;
    background: transparent;
    outline: none;
}
/* Swatches filtered out by the search box. !important beats the grid's
   display:flex context and any theme button rules. */
.vis-swatch.vis-search-miss {
    display: none !important;
}

/* Hidden: variation not allowed by BOM configuration — removed from display */
.vis-swatch.vis-hidden {
    display: none;
}

.vis-swatch.vis-unavailable {
    opacity: 0.35;
    cursor: not-allowed;
}

.vis-swatch.vis-unavailable .vis-swatch-thumb::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #999;
    transform: rotate(-45deg);
}

/* Out of stock: visible but greyed out with diagonal line.
   Clickable — shows the color image + "Udsolgt" in lagerstatus,
   but ATC button is disabled by WC. Customer can see the color
   exists in the range even if they can't buy it right now. */
.vis-swatch.vis-out-of-stock {
    opacity: 0.45;
}

.vis-swatch.vis-out-of-stock .vis-swatch-thumb::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to top right,
        transparent calc(50% - 0.5px),
        #999 calc(50% - 0.5px),
        #999 calc(50% + 0.5px),
        transparent calc(50% + 0.5px)
    );
    pointer-events: none;
    z-index: 1;
}

/* Out-of-stock + selected: restore some opacity so the selection is clear */
.vis-swatch.vis-out-of-stock.vis-selected {
    opacity: 0.7;
}

/* Image swatches use the same two-level language as the text pills: one
   diagonal = sold out, an X = this combination does not exist. Colour swatches
   reach the second state inside kits, where a BOM restricts which colours a
   component may use. */
.vis-swatch.vis-unavailable-combo {
    opacity: 0.45;
}

.vis-swatch.vis-unavailable-combo .vis-swatch-thumb::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        linear-gradient(
            to top right,
            transparent calc(50% - 0.5px),
            #999 calc(50% - 0.5px),
            #999 calc(50% + 0.5px),
            transparent calc(50% + 0.5px)
        ),
        linear-gradient(
            to bottom right,
            transparent calc(50% - 0.5px),
            #999 calc(50% - 0.5px),
            #999 calc(50% + 0.5px),
            transparent calc(50% + 0.5px)
        );
    pointer-events: none;
    z-index: 1;
}

/* The no-match explanation, shown when a customer clicks an X-ed option.
   role="status" so it is announced; hidden until there is something to say.
   It is inserted just ABOVE .woocommerce-variation-add-to-cart — that container
   is a nowrap flex row (quantity + button), so a child would be squeezed in
   beside the button rather than taking its own line. */
.vis-no-match {
    display: none;
    width: 100%;
    margin: 8px 0;
    padding: 8px 10px;
    border-left: 3px solid #b36b00;
    background: #fff8ec;
    color: #6b4400;
    font-size: 0.9em;
    line-height: 1.4;
    /* showNoMatch() scrolls the box in with block:'nearest', which parks it
       flush against the bottom edge on a phone — readable, but with nothing
       below it and no hint that the buy button follows. scroll-margin gives
       that scroll somewhere to land. */
    scroll-margin-bottom: 24px;
    scroll-margin-top: 24px;
}
.vis-no-match.is-visible {
    display: block;
}

.vis-swatch img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 2px;
}

.vis-text-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
}

/* ===== Text-button pills (non-image attributes: needle size, length, ...) =====
   Same interaction/JS as image swatches, no image area. Styled to match the
   kit size chips (.cbm-size-chip) so the two share one visual language. */
.vis-swatch-grid--text {
    column-gap: 8px;
    row-gap: 8px;
}
/* Compound selector (grid + pill) raises specificity above the base
   `.vis-swatch { width: 100px }` AND the mobile `@media .vis-swatch { width:90px }`
   rules (both 0,1,0) so the UNIFORM pill width holds on every breakpoint.
   Without this, desktop fell back to content-width (uneven) while mobile picked
   up the 90px rule (uniform) — the PC/phone discrepancy. */
.vis-swatch-grid--text .vis-swatch--text {
    width: 84px;            /* uniform — aligns pills into a clean grid (PC + mobile) */
    min-height: 44px;       /* adequate touch target */
    padding: 6px 8px;
    border: 1.5px solid #ddd;
    border-radius: 4px;
    background: #fff;
    color: #333;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
    transition: border-color 0.12s ease, background-color 0.12s ease;
}
.vis-swatch-grid--text .vis-swatch--text:hover {
    border-color: #888;
}
.vis-swatch-grid--text .vis-swatch--text.vis-selected {
    border-color: #222;
    background: #222;
}
/* The name span is the whole pill label here — reset the image-swatch styling
   (centered, normal weight, inherit pill colour incl. selected). Allow wrap so
   longer labels (e.g. colour names) don't overflow the fixed pill width. */
.vis-swatch-grid--text .vis-swatch--text .vis-swatch-name {
    margin: 0;
    padding: 0;
    font-size: 0.95em;
    font-weight: 500;
    text-align: center;
    color: inherit;
    white-space: normal;
    overflow: visible;
}
.vis-swatch-grid--text .vis-swatch--text.vis-selected .vis-swatch-name {
    color: #fff;
}
/* Unavailable text pills — ONE shared mark for both states: out of stock
   (combo exists, no stock) AND invalid combination (no such variation given the
   other selection). A diagonal strike across the pill, matching the colour
   swatches' OOS mark. Pills stay clickable; the *reason* is shown in the buy box
   ("Udsolgt" vs WooCommerce's no-match notice). */
.vis-swatch-grid--text .vis-swatch--text.vis-out-of-stock,
.vis-swatch-grid--text .vis-swatch--text.vis-unavailable-combo,
.vis-swatch-grid--text .vis-swatch--text.vis-unavailable {
    opacity: 0.55;
}
.vis-swatch-grid--text .vis-swatch--text.vis-out-of-stock .vis-swatch-name,
.vis-swatch-grid--text .vis-swatch--text.vis-unavailable-combo .vis-swatch-name,
.vis-swatch-grid--text .vis-swatch--text.vis-unavailable .vis-swatch-name {
    color: #777;
}
.vis-swatch-grid--text .vis-swatch--text.vis-out-of-stock::after,
.vis-swatch-grid--text .vis-swatch--text.vis-unavailable-combo::after,
.vis-swatch-grid--text .vis-swatch--text.vis-unavailable::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 4px;
    background: linear-gradient(
        to top right,
        transparent calc(50% - 0.75px),
        #999 calc(50% - 0.75px),
        #999 calc(50% + 0.75px),
        transparent calc(50% + 0.75px)
    );
    pointer-events: none;
}

/* TWO diagonals (an X) when the combination does not exist at all, versus the
   ONE diagonal customers already read as "sold out" (Bo 2026-07-26). Before
   this the two states were styled identically, so a size that is merely not
   made in the chosen length looked exactly like one we had sold out of.
   The X gives the whole matrix at a glance without hiding any option; the
   reason is spelled out in .vis-no-match when the pill is clicked. */
.vis-swatch-grid--text .vis-swatch--text.vis-unavailable-combo::after {
    background:
        linear-gradient(
            to top right,
            transparent calc(50% - 0.75px),
            #999 calc(50% - 0.75px),
            #999 calc(50% + 0.75px),
            transparent calc(50% + 0.75px)
        ),
        linear-gradient(
            to bottom right,
            transparent calc(50% - 0.75px),
            #999 calc(50% - 0.75px),
            #999 calc(50% + 0.75px),
            transparent calc(50% + 0.75px)
        );
}
/* Selected-but-unavailable: keep it legible (the customer clicked to see why). */
.vis-swatch-grid--text .vis-swatch--text.vis-out-of-stock.vis-selected,
.vis-swatch-grid--text .vis-swatch--text.vis-unavailable-combo.vis-selected {
    opacity: 0.85;
}

/* Inside CP components — smaller swatches */
.composite_component .vis-swatch {
    width: 70px;
}
.composite_component .vis-swatch-thumb {
    height: 70px;
}
.composite_component .vis-swatch-name {
    font-size: 10px;
    padding: 3px 2px 4px;
}

/* Quick View lightbox — compact swatches for limited space */
.product-lightbox .vis-swatch {
    width: 70px;
}
.product-lightbox .vis-swatch-thumb {
    height: 70px;
}
.product-lightbox .vis-swatch-name {
    font-size: 10px;
    padding: 3px 2px 4px;
}

.product-lightbox .vis-swatch-grid {
    gap: 4px;
}

.product-lightbox .vis-selected-label {
    font-size: 13px;
    margin-bottom: 6px;
}

/* Mobile */
@media (max-width: 480px) {
    .vis-swatch {
        width: 90px;
    }
    .vis-swatch-thumb {
        height: 90px;
    }

    .vis-swatch-grid {
        column-gap: 5px;
        row-gap: 14px;
    }

    .vis-selected-label {
        font-size: 13px;
    }
}
