/**
 * The product page's buy box (Product_Page_Controller): swatches – buttons or picture tiles, the chosen one in the
 * dark ink with the red line, sold out struck through –, the stock by the buy button and − / + around the quantity.
 * Ohyra's look: the kit's colours and fonts with fallbacks.
 */

.gf-swatches,
.gf-stock-row,
.gf-qty-btn {
    --gf-v-ink: var(--e-global-color-secondary, #1a1a1a);
    --gf-v-muted: var(--e-global-color-primary, #696969);
    --gf-v-brand: var(--e-global-color-d49ac81, #97040d);
    --gf-v-tile: color-mix(in srgb, var(--e-global-color-cfa1f76, #f2d6d6) 38%, #fff);
    --gf-v-go: #189704;
    --gf-v-backorder: #b56e00;
    --gf-v-font: var(--e-global-typography-text-font-family, "Poppins"), system-ui, sans-serif;
}

/* WooCommerce's variations table: one attribute per block, the label in the legend */
.variations_form table.variations,
.variations_form table.variations :is(tbody, tr, td, th) {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
}

.variations_form table.variations tr + tr {
    margin-top: 16px;
}

.variations_form table.variations tr:has(.gf-swatches) th.label {
    display: none;
}

.variations_form table.variations {
    margin-bottom: 20px;
}

.gf-swatches {
    display: grid;
    gap: 10px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
    font-family: var(--gf-v-font);
}

.gf-swatches .gf-swatches-legend {
    float: none;
    width: auto;
    margin: 0;
    padding: 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--gf-v-ink);
}

.gf-swatches-chosen {
    margin-left: 4px;
    font-weight: 400;
    color: var(--gf-v-muted);
}

.gf-swatches-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.gf-swatch {
    position: relative;
    margin: 0;
    cursor: pointer;
}

.gf-swatches .gf-swatch-input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

/* Buttons */
.gf-swatches--buttons .gf-swatch-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid #d6d6d6;
    border-radius: 5px;
    background: #fff;
    font-size: 14px;
    font-weight: 400;
    color: var(--gf-v-ink);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.gf-swatches--buttons .gf-swatch:hover .gf-swatch-label {
    border-color: var(--gf-v-ink);
}

.gf-swatches--buttons .gf-swatch.is-selected .gf-swatch-label {
    border-color: var(--gf-v-ink);
    background: var(--gf-v-ink);
    font-weight: 500;
    color: #fff;
}

/* Picture tiles */
.gf-swatches--images .gf-swatch {
    display: grid;
    justify-items: center;
    gap: 6px;
    width: 92px;
}

.gf-swatch-media {
    display: grid;
    place-items: center;
    width: 92px;
    height: 92px;
    overflow: hidden;
    border: 1px solid #e3e3e3;
    border-radius: 6px;
    background: var(--gf-v-tile);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.gf-swatches .gf-swatch-img {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 6px;
    object-fit: contain;
    mix-blend-mode: multiply;
}

.gf-swatches--images .gf-swatch-label {
    max-width: 100%;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.3;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--gf-v-muted);
}

.gf-swatches--images .gf-swatch:hover .gf-swatch-media {
    border-color: var(--gf-v-ink);
}

.gf-swatches--images .gf-swatch.is-selected .gf-swatch-media {
    border-color: var(--gf-v-brand);
    box-shadow: 0 0 0 1px var(--gf-v-brand);
}

.gf-swatches--images .gf-swatch.is-selected .gf-swatch-label {
    font-weight: 500;
    color: var(--gf-v-ink);
}

/* Not with the other choices: dimmed. Sold out: struck through (still choosable – to see it) */
.gf-swatch.is-unavailable {
    opacity: 0.4;
}

.gf-swatches--buttons .gf-swatch.is-sold-out .gf-swatch-label {
    color: var(--gf-v-muted);
    text-decoration: line-through;
}

.gf-swatches--images .gf-swatch.is-sold-out .gf-swatch-media {
    background:
        linear-gradient(to top right, transparent calc(50% - 1px), #c4c4c4 calc(50% - 1px), #c4c4c4 calc(50% + 1px), transparent calc(50% + 1px)),
        var(--gf-v-tile);
}

.gf-swatches--images .gf-swatch.is-sold-out .gf-swatch-img {
    opacity: 0.45;
}

.gf-swatch-input:focus-visible + :is(.gf-swatch-label, .gf-swatch-media) {
    outline: 2px solid var(--gf-v-brand);
    outline-offset: 2px;
}

.variations_form .reset_variations {
    display: none !important;
}

/* The stock by the buy button: its own row under the quantity and the button (Elementor's buy box is one row, its
   button a whole row's width – the button takes what the quantity leaves) */
:is(form.cart, .woocommerce-variation-add-to-cart):has(> .gf-stock-row) {
    flex-wrap: wrap !important;
}

:is(form.cart, .woocommerce-variation-add-to-cart):has(> .gf-stock-row) > .single_add_to_cart_button {
    flex: 1 1 0% !important;
    min-width: 0;
}

.gf-stock-row {
    flex: 1 1 100%;
    width: 100%;
    margin-top: 12px;
}

.gf-stock-row:empty {
    display: none;
}

.gf-stock-row .gf-stock {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-family: var(--gf-v-font);
    font-size: 14px;
    font-weight: 500;
    color: var(--gf-v-go);
}

.gf-stock-row .gf-stock .gf-icon {
    width: 18px;
    height: 18px;
}

.gf-stock-row .gf-stock--backorder {
    color: var(--gf-v-backorder);
}

.gf-stock-row .gf-stock--out-of-stock {
    color: var(--gf-v-brand);
}

/* The chosen variant's price above the quantity */
.variations_form .woocommerce-variation-price .price {
    margin: 0 0 12px;
    font-family: var(--e-global-typography-primary-font-family, "NeueHaasDisplay-Mediu"), var(--gf-v-font, sans-serif);
    font-size: 22px;
    font-weight: 500;
    color: var(--e-global-color-secondary, #1a1a1a);
}

.variations_form .woocommerce-variation-price .price ins {
    color: var(--e-global-color-d49ac81, #97040d);
    text-decoration: none;
}

/* − / + around the quantity. The add to cart widget styles every button and the quantity field in its form with
   its own (higher) selectors – the stepper's own look wins here with !important on what it sets. */
form.cart .quantity:has(.gf-qty-btn) {
    display: inline-flex !important;
    flex-wrap: nowrap !important;
    flex: 0 0 auto;
    align-items: stretch;
    width: auto !important;
    overflow: hidden;
    border: 1px solid #d6d6d6;
    border-radius: 5px;
    background: #fff;
}

form.cart .quantity:has(.gf-qty-btn) input.qty {
    flex: 0 0 46px !important;
    width: 46px !important;
    max-width: 46px !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    font-size: 16px;
    text-align: center;
    box-shadow: none !important;
    appearance: textfield;
    -moz-appearance: textfield;
}

form.cart .quantity:has(.gf-qty-btn) input.qty::-webkit-inner-spin-button,
form.cart .quantity:has(.gf-qty-btn) input.qty::-webkit-outer-spin-button {
    margin: 0;
    appearance: none;
}

form.cart .quantity button.gf-qty-btn {
    display: grid !important;
    flex: 0 0 40px !important;
    max-width: 40px !important;
    place-items: center;
    width: 40px !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 44px;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    font-family: var(--gf-v-font);
    font-size: 20px !important;
    font-weight: 400;
    line-height: 1;
    color: var(--gf-v-ink) !important;
    box-shadow: none !important;
    cursor: pointer;
}

form.cart .quantity button.gf-qty-btn:hover {
    background: #f3f3f3 !important;
}

form.cart .quantity button.gf-qty-btn:focus-visible {
    outline: 2px solid var(--gf-v-brand);
    outline-offset: -2px;
}
