/**
 * OptionGrid Variation Matrix Frontend Styles
 *
 * All styles are namespaced with the .wcvm- prefix to avoid theme conflicts.
 *
 * Every colour, size and radius is driven by the custom properties declared in
 * the DESIGN TOKENS block below. The plugin settings screen writes the site
 * owner's values into an inline block that redeclares the same properties on
 * .wcvm-variation-matrix, so no rule below ever needs a hard coded colour.
 *
 * Version: 1.0.0
 */

/* ==================== DESIGN TOKENS ==================== */

.wcvm-variation-matrix {
    /* Overridable from Settings -> Variation Matrix -> Styling. */
    --wcvm-accent: #2563eb;
    --wcvm-accent-rgb: 37, 99, 235;
    --wcvm-accent-contrast: #ffffff;
    --wcvm-text: #1f2937;
    --wcvm-muted: #6b7280;
    --wcvm-border: #e5e7eb;
    --wcvm-head-bg: #f8fafc;
    --wcvm-surface: #ffffff;
    --wcvm-font-size: 14px;
    --wcvm-radius: 8px;

    /* Derived from the values above. */
    --wcvm-radius-sm: calc(var(--wcvm-radius) * 0.5);
    --wcvm-accent-soft: rgba(var(--wcvm-accent-rgb), 0.07);
    --wcvm-accent-ring: rgba(var(--wcvm-accent-rgb), 0.22);

    /* Status colours. Override from your theme if needed. */
    --wcvm-success: #15803d;
    --wcvm-success-bg: #ecfdf3;
    --wcvm-warning: #92400e;
    --wcvm-warning-bg: #fffbeb;
    --wcvm-danger: #b42318;
    --wcvm-danger-bg: #fef3f2;

    /* Matrix geometry. --wcvm-matrix-cols is set per product by the template. */
    --wcvm-cell-min: 170px;
    --wcvm-axis-width: 118px;
}

/* ==================== COMMON STYLES ==================== */

.wcvm-variation-matrix {
    margin: 24px 0;
    padding: 0;
    box-sizing: border-box;
    font-family: inherit;
    font-size: var(--wcvm-font-size);
    line-height: 1.5;
    color: var(--wcvm-text);
}

.wcvm-variation-matrix *,
.wcvm-variation-matrix *::before,
.wcvm-variation-matrix *::after {
    box-sizing: border-box;
}

/* Headers */
.wcvm-header {
    margin: 0 0 16px;
}

.wcvm-grid-header,
.wcvm-variation-matrix > h3,
.wcvm-header > h3 {
    margin: 0;
    padding: 0;
    font-size: 1.28em;
    font-weight: 650;
    color: var(--wcvm-text);
    line-height: 1.3;
}

.wcvm-header > p,
.wcvm-grid-header p {
    margin: 6px 0 0;
    font-size: 0.92em;
    color: var(--wcvm-muted);
    font-weight: 400;
}

/* Message Notifications */
.wcvm-messages:empty {
    display: none;
}

.wcvm-messages {
    margin: 0 0 14px;
}

.wcvm-message {
    position: relative;
    padding: 11px 40px 11px 14px;
    margin: 0 0 8px;
    border-radius: var(--wcvm-radius-sm);
    border: 1px solid transparent;
    font-size: 0.93em;
    line-height: 1.5;
    animation: wcvm-slide-in 0.3s ease-out;
}

@keyframes wcvm-slide-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wcvm-message-success {
    background-color: var(--wcvm-success-bg);
    border-color: var(--wcvm-success);
    color: var(--wcvm-success);
}

.wcvm-message-error {
    background-color: var(--wcvm-danger-bg);
    border-color: var(--wcvm-danger);
    color: var(--wcvm-danger);
}

.wcvm-message-warning {
    background-color: var(--wcvm-warning-bg);
    border-color: var(--wcvm-warning);
    color: var(--wcvm-warning);
}

.wcvm-message-close {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: inherit;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    opacity: 0.65;
    transition: opacity 0.2s ease, background-color 0.2s ease;
}

.wcvm-message-close:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.06);
}

/* Loading States */
.wcvm-loading {
    text-align: center;
    padding: 16px;
    color: var(--wcvm-muted);
    font-size: 0.93em;
}

.wcvm-add-to-cart-btn.loading,
.wcvm-bulk-add-to-cart.loading,
.wcvm-single-add-btn.loading {
    color: transparent !important;
    cursor: not-allowed;
    position: relative;
    pointer-events: none;
}

.wcvm-add-to-cart-btn.loading::after,
.wcvm-bulk-add-to-cart.loading::after,
.wcvm-single-add-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: var(--wcvm-accent-contrast);
    border-radius: 50%;
    animation: wcvm-spin 0.8s linear infinite;
}

@keyframes wcvm-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Quantity Inputs */
.wcvm-variation-matrix .wcvm-qty-input {
    width: 76px;
    max-width: 100%;
    height: 40px;
    padding: 6px 8px;
    margin: 0;
    border: 1px solid var(--wcvm-border);
    border-radius: var(--wcvm-radius-sm);
    background-color: var(--wcvm-surface);
    color: var(--wcvm-text);
    font-size: 0.95em;
    font-family: inherit;
    line-height: 1.2;
    text-align: center;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.wcvm-variation-matrix .wcvm-qty-input:focus {
    border-color: var(--wcvm-accent);
    box-shadow: 0 0 0 3px var(--wcvm-accent-ring);
    outline: none;
}

.wcvm-variation-matrix .wcvm-qty-input:disabled {
    background-color: var(--wcvm-head-bg);
    color: var(--wcvm-muted);
    cursor: not-allowed;
}

/* Buttons */
.wcvm-variation-matrix .wcvm-add-to-cart-btn,
.wcvm-variation-matrix .wcvm-bulk-add-to-cart,
.wcvm-variation-matrix .wcvm-single-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
    padding: 10px 18px;
    border: 1px solid var(--wcvm-accent);
    border-radius: var(--wcvm-radius-sm);
    background-color: var(--wcvm-accent);
    color: var(--wcvm-accent-contrast);
    font-family: inherit;
    font-size: 0.95em;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    text-transform: none;
    cursor: pointer;
    transition: filter 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.wcvm-variation-matrix .wcvm-add-to-cart-btn:hover:not(:disabled),
.wcvm-variation-matrix .wcvm-bulk-add-to-cart:hover:not(:disabled),
.wcvm-variation-matrix .wcvm-single-add-btn:hover:not(:disabled) {
    filter: brightness(0.92);
    box-shadow: 0 2px 8px var(--wcvm-accent-ring);
    color: var(--wcvm-accent-contrast);
    background-color: var(--wcvm-accent);
}

.wcvm-variation-matrix .wcvm-add-to-cart-btn:active:not(:disabled),
.wcvm-variation-matrix .wcvm-bulk-add-to-cart:active:not(:disabled) {
    transform: translateY(1px);
}

.wcvm-variation-matrix .wcvm-add-to-cart-btn:disabled,
.wcvm-variation-matrix .wcvm-bulk-add-to-cart:disabled,
.wcvm-variation-matrix .wcvm-single-add-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Stock Status Badges */
.wcvm-matrix-stock,
.wcvm-stock-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.8em;
    font-weight: 600;
    line-height: 1.45;
}

/* Keeps the badge hugging its text inside the grid card's column flexbox. */
.wcvm-stock-status {
    align-self: flex-start;
}

.wcvm-matrix-stock::before,
.wcvm-stock-status::before {
    content: '';
    flex: 0 0 auto;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
}

.wcvm-matrix-stock.wcvm-in-stock,
.wcvm-stock-status.wcvm-in-stock {
    color: var(--wcvm-success);
    background-color: var(--wcvm-success-bg);
}

.wcvm-matrix-stock.wcvm-low-stock,
.wcvm-stock-status.wcvm-low-stock {
    color: var(--wcvm-warning);
    background-color: var(--wcvm-warning-bg);
}

.wcvm-matrix-stock.wcvm-out-of-stock,
.wcvm-stock-status.wcvm-out-of-stock {
    color: var(--wcvm-danger);
    background-color: var(--wcvm-danger-bg);
}

/* Bulk Actions Section */
.wcvm-add-to-cart-section,
.wcvm-bulk-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 16px;
    padding: 0;
}

.wcvm-variation-matrix .wcvm-bulk-add-to-cart {
    min-width: 220px;
    padding: 12px 28px;
    font-size: 1em;
}

/* The grid template nests its messages and loader inside this row. */
.wcvm-add-to-cart-section .wcvm-messages {
    order: -1;
    flex: 1 0 100%;
    margin: 0 0 4px;
}

.wcvm-add-to-cart-section .wcvm-loading {
    flex: 0 0 auto;
    padding: 0;
}

/* ==================== MATRIX LAYOUT ==================== */

.wcvm-matrix-layout {
    width: 100%;
}

/*
 * The matrix scrolls sideways instead of squeezing its columns, so every cell
 * keeps a usable width no matter how many attribute values a product has.
 */
.wcvm-matrix-container {
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    margin: 0;
    border: 1px solid var(--wcvm-border);
    border-radius: var(--wcvm-radius);
    background-color: var(--wcvm-surface);
}

.wcvm-matrix-container:focus-visible {
    outline: 2px solid var(--wcvm-accent);
    outline-offset: 2px;
}

/*
 * table-layout: fixed keeps every attribute column the same width regardless
 * of how much content lands in each cell, which is what stops one long
 * description from stretching a single column across the whole table.
 */
.wcvm-matrix-table {
    table-layout: fixed;
    width: 100%;
    min-width: calc(var(--wcvm-axis-width) + (var(--wcvm-matrix-cols, 1) * var(--wcvm-cell-min)));
    margin: 0;
    border: 0;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
    font-size: 1em;
}

.wcvm-matrix-table col.wcvm-axis-col {
    width: var(--wcvm-axis-width);
}

.wcvm-matrix-table th,
.wcvm-matrix-table td {
    padding: 10px;
    border: 0;
    border-right: 1px solid var(--wcvm-border);
    border-bottom: 1px solid var(--wcvm-border);
    text-align: center;
    vertical-align: top;
    word-break: normal;
    overflow-wrap: break-word;
}

.wcvm-matrix-table tr > *:last-child {
    border-right: 0;
}

.wcvm-matrix-table tbody tr:last-child > * {
    border-bottom: 0;
}

.wcvm-matrix-table thead th {
    padding: 13px 10px;
    background-color: var(--wcvm-head-bg);
    color: var(--wcvm-text);
    font-size: 0.95em;
    font-weight: 650;
    line-height: 1.35;
    vertical-align: middle;
}

/* The attribute value column stays visible while the matrix scrolls. */
.wcvm-matrix-table .wcvm-matrix-corner,
.wcvm-matrix-table .wcvm-row-header {
    position: sticky;
    left: 0;
    z-index: 2;
    background-color: var(--wcvm-head-bg);
    background-clip: padding-box;
}

.wcvm-matrix-table .wcvm-matrix-corner {
    z-index: 3;
}

.wcvm-matrix-table .wcvm-row-header {
    padding: 12px 8px;
    color: var(--wcvm-text);
    font-size: 0.95em;
    font-weight: 650;
    line-height: 1.35;
    vertical-align: middle;
    hyphens: none;
}

.wcvm-attr-labels {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 0.8em;
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1.3;
    text-transform: uppercase;
    color: var(--wcvm-muted);
}

.wcvm-attr-labels > span {
    white-space: nowrap;
}

.wcvm-separator {
    opacity: 0.6;
}

/* --- Matrix cells --- */

/*
 * height: 1px is the long standing way to give a table cell a definite height
 * so its child can resolve height: 100%. Rows still grow to fit their content,
 * and every card in a row ends up the same height.
 */
.wcvm-matrix-cell {
    height: 1px;
    padding: 8px;
    background-color: var(--wcvm-surface);
}

.wcvm-matrix-variation {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    height: 100%;
    padding: 10px 9px;
    border: 1px solid var(--wcvm-border);
    border-radius: var(--wcvm-radius-sm);
    background-color: var(--wcvm-surface);
    text-align: center;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.wcvm-matrix-variation.wcvm-out-of-stock {
    background-color: var(--wcvm-head-bg);
    border-style: dashed;
}

.wcvm-matrix-variation.wcvm-out-of-stock .wcvm-matrix-image img,
.wcvm-matrix-variation.wcvm-out-of-stock .wcvm-matrix-price {
    opacity: 0.6;
}

.wcvm-matrix-variation:hover {
    border-color: var(--wcvm-muted);
}

/* Selected cells are highlighted as soon as a quantity is entered. */
.wcvm-matrix-variation.wcvm-has-quantity,
.wcvm-matrix-variation.wcvm-out-of-stock.wcvm-has-quantity {
    border: 1px solid var(--wcvm-accent);
    background-color: var(--wcvm-accent-soft);
    box-shadow: 0 0 0 3px var(--wcvm-accent-ring);
}

.wcvm-matrix-image {
    line-height: 0;
}

.wcvm-matrix-image img {
    display: block;
    width: 64px;
    height: 64px;
    max-width: 100%;
    object-fit: cover;
    border: 1px solid var(--wcvm-border);
    border-radius: var(--wcvm-radius-sm);
    background-color: var(--wcvm-surface);
}

.wcvm-matrix-sku {
    font-size: 0.8em;
    color: var(--wcvm-muted);
    letter-spacing: 0.02em;
    overflow-wrap: anywhere;
}

.wcvm-matrix-price {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: center;
    gap: 3px 7px;
    font-size: 1em;
    font-weight: 700;
    line-height: 1.3;
    color: var(--wcvm-text);
}

.wcvm-matrix-price del,
.wcvm-matrix-price del .woocommerce-Price-amount {
    color: var(--wcvm-muted);
    font-size: 0.86em;
    font-weight: 500;
    text-decoration: line-through;
}

.wcvm-matrix-price ins {
    background: none;
    color: var(--wcvm-text);
    text-decoration: none;
}

.wcvm-matrix-price .woocommerce-Price-amount {
    white-space: nowrap;
}

.wcvm-matrix-price .woocommerce-price-suffix,
.wcvm-matrix-price small {
    display: block;
    width: 100%;
    font-size: 0.78em;
    font-weight: 400;
    color: var(--wcvm-muted);
}

.wcvm-matrix-description {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.8em;
    line-height: 1.45;
    color: var(--wcvm-muted);
}

.wcvm-matrix-description p {
    margin: 0;
}

/* Quantity + add button share one row pinned to the bottom of the cell. */
.wcvm-matrix-buy {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    margin-top: auto;
    padding-top: 3px;
}

.wcvm-matrix-quantity {
    flex: 1 1 auto;
    min-width: 0;
}

.wcvm-variation-matrix .wcvm-matrix-quantity .wcvm-qty-input {
    width: 100%;
}

.wcvm-matrix-action {
    flex: 0 0 auto;
}

.wcvm-variation-matrix .wcvm-matrix-action .wcvm-add-to-cart-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 1.3em;
    font-weight: 400;
}

.wcvm-matrix-unavailable {
    margin-top: auto;
    padding-top: 4px;
    font-size: 0.8em;
    font-style: italic;
    color: var(--wcvm-muted);
}

/* Attribute combinations that have no variation at all. */
.wcvm-matrix-cell.wcvm-cell-empty {
    background-color: var(--wcvm-head-bg);
}

.wcvm-matrix-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 84px;
    height: 100%;
    border-radius: var(--wcvm-radius-sm);
    color: var(--wcvm-muted);
    font-size: 1.1em;
    opacity: 0.55;
}

/* ==================== GRID LAYOUT ==================== */

/*
 * The grid sits inside the product summary column, whose width has nothing to
 * do with the viewport width: on a 900px screen WooCommerce puts the summary
 * beside the gallery, leaving roughly 430px. So the container itself is the
 * query context and the breakpoints below read its width, not the screen's.
 */
.wcvm-grid-container {
    max-width: 100%;
    container: wcvm / inline-size;
}

/*
 * Column count and gap are supplied per product as the --wcvm-columns and
 * --wcvm-gap custom properties, set on the element by the grid template.
 *
 * The configured count is honoured exactly. The earlier version put a 190px
 * floor under each track, which quietly won whenever the summary column was
 * narrow and pinned the layout to three columns however many were configured.
 * The container queries below step the count down instead, and only once the
 * cards would drop under roughly 150px and stop being usable.
 */
.wcvm-grid {
    display: grid;
    grid-template-columns: repeat(var(--wcvm-columns, 3), minmax(0, 1fr));
    gap: var(--wcvm-gap, 20px);
    margin-bottom: 20px;
}

/*
 * Step-downs, keyed to the count the shop owner asked for. A product set to 3
 * columns is left alone until the container is genuinely too narrow for 3.
 */
@container wcvm (max-width: 1000px) {
    .wcvm-grid-container[data-columns="6"] .wcvm-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@container wcvm (max-width: 830px) {
    .wcvm-grid-container[data-columns="6"] .wcvm-grid,
    .wcvm-grid-container[data-columns="5"] .wcvm-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@container wcvm (max-width: 660px) {
    .wcvm-grid-container[data-columns="6"] .wcvm-grid,
    .wcvm-grid-container[data-columns="5"] .wcvm-grid,
    .wcvm-grid-container[data-columns="4"] .wcvm-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@container wcvm (max-width: 490px) {
    .wcvm-grid-container[data-columns="6"] .wcvm-grid,
    .wcvm-grid-container[data-columns="5"] .wcvm-grid,
    .wcvm-grid-container[data-columns="4"] .wcvm-grid,
    .wcvm-grid-container[data-columns="3"] .wcvm-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@container wcvm (max-width: 320px) {
    .wcvm-grid-container .wcvm-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/*
 * Fallback for browsers without container queries (Chrome < 105, Safari < 16,
 * Firefox < 110). It cannot see the container width, so it falls back to
 * auto-fill against a 150px floor: less faithful to the configured count, but
 * it never produces cards too small to tap.
 */
@supports not (container-type: inline-size) {
    .wcvm-grid {
        grid-template-columns: repeat(
            auto-fill,
            minmax(
                min(
                    100%,
                    max(
                        150px,
                        (100% - (var(--wcvm-columns, 3) - 1) * var(--wcvm-gap, 20px)) / var(--wcvm-columns, 3)
                    )
                ),
                1fr
            )
        );
    }
}

/*
 * min-width: 0 is required: a grid item defaults to min-width: auto, so a card
 * refuses to shrink below the widest thing inside it (a long stock badge, for
 * example) and pushes the whole grid wider than the page.
 */
.wcvm-grid-item {
    position: relative;
    display: flex;
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--wcvm-border);
    border-radius: var(--wcvm-radius);
    background: var(--wcvm-surface);
    transition: box-shadow 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}

.wcvm-grid-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.wcvm-grid-item.wcvm-out-of-stock {
    background-color: var(--wcvm-head-bg);
    border-style: dashed;
}

.wcvm-grid-item.wcvm-out-of-stock .wcvm-variation-image img,
.wcvm-grid-item.wcvm-out-of-stock .wcvm-variation-price {
    opacity: 0.6;
}

.wcvm-grid-item.wcvm-has-quantity,
.wcvm-grid-item.wcvm-out-of-stock.wcvm-has-quantity {
    border: 1px solid var(--wcvm-accent);
    background-color: var(--wcvm-accent-soft);
    box-shadow: 0 0 0 3px var(--wcvm-accent-ring);
}

.wcvm-variation-info {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

/*
 * Price, stock and quantity are pinned to the bottom of the card so they line
 * up across the row, however much content sits above them.
 */
.wcvm-grid-footer {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-top: auto;
    padding-top: 4px;
}

.wcvm-variation-image {
    width: 100%;
    margin-bottom: 2px;
    border-radius: var(--wcvm-radius-sm);
    overflow: hidden;
    background-color: var(--wcvm-head-bg);
}

/*
 * A fixed ratio keeps every card's image box the same height, so the names,
 * prices and quantity boxes line up even when the variation images (and the
 * WooCommerce placeholder) have different proportions.
 */
.wcvm-variation-image img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: var(--wcvm-radius-sm);
}

.wcvm-variation-name {
    font-size: 1.05em;
    font-weight: 650;
    line-height: 1.35;
    color: var(--wcvm-text);
}

.wcvm-variation-sku {
    font-size: 0.85em;
    color: var(--wcvm-muted);
    overflow-wrap: anywhere;
}

.wcvm-variation-attributes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.wcvm-attribute {
    padding: 3px 9px;
    border-radius: var(--wcvm-radius-sm);
    background: var(--wcvm-head-bg);
    color: var(--wcvm-text);
    font-size: 0.84em;
    line-height: 1.5;
}

.wcvm-attribute-label {
    color: var(--wcvm-muted);
}

.wcvm-variation-price {
    margin: 0;
    font-size: 1.2em;
    font-weight: 700;
    line-height: 1.3;
    color: var(--wcvm-text);
}

.wcvm-variation-price del {
    margin-right: 8px;
    color: var(--wcvm-muted);
    font-size: 0.8em;
    font-weight: 500;
}

.wcvm-variation-price ins {
    background: none;
    color: var(--wcvm-text);
    text-decoration: none;
}

.wcvm-variation-description {
    font-size: 0.9em;
    color: var(--wcvm-muted);
    line-height: 1.5;
}

/* Long descriptions must not push a card taller than the rest of the row. */
.wcvm-grid-item .wcvm-variation-description {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wcvm-grid-item .wcvm-variation-description p {
    margin: 0;
}

.wcvm-quantity-input {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.wcvm-quantity-input label {
    margin: 0;
    font-size: 0.95em;
    font-weight: 500;
    color: var(--wcvm-text);
}

.wcvm-quantity-unavailable {
    min-height: 40px;
    align-items: center;
}

/* Shown in place of the quantity box when a variation cannot be ordered. */
.wcvm-unavailable {
    color: var(--wcvm-muted);
    font-style: italic;
    font-size: 0.9em;
}

/* ==================== RESPONSIVE DESIGN ==================== */

/*
 * The grid's own column count needs no breakpoints: it follows the width of
 * the container it sits in. See the .wcvm-grid rule above.
 */

@media (max-width: 768px) {
    .wcvm-grid-item {
        padding: 12px;
    }

    .wcvm-add-to-cart-section,
    .wcvm-bulk-actions {
        justify-content: stretch;
    }

    .wcvm-variation-matrix .wcvm-bulk-add-to-cart {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .wcvm-variation-matrix {
        --wcvm-cell-min: 152px;
        --wcvm-axis-width: 82px;
    }

    .wcvm-matrix-table thead th,
    .wcvm-matrix-table .wcvm-row-header {
        padding: 10px 6px;
        font-size: 0.9em;
    }

    .wcvm-matrix-cell {
        padding: 6px;
    }

    .wcvm-matrix-variation {
        gap: 6px;
        padding: 8px 7px;
    }

    .wcvm-matrix-image img {
        width: 54px;
        height: 54px;
    }

    .wcvm-variation-matrix .wcvm-qty-input,
    .wcvm-variation-matrix .wcvm-matrix-action .wcvm-add-to-cart-btn {
        height: 36px;
    }

    .wcvm-variation-matrix .wcvm-matrix-action .wcvm-add-to-cart-btn {
        width: 36px;
    }

}

/* ==================== ANIMATION & EFFECTS ==================== */

@keyframes wcvm-success-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.04); }
    100% { transform: scale(1); }
}

.wcvm-success-animation {
    animation: wcvm-success-pulse 0.4s ease-in-out;
}

@keyframes wcvm-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wcvm-grid-item {
    animation: wcvm-fade-in 0.3s ease-out backwards;
}

.wcvm-grid-item:nth-child(1) { animation-delay: 0.05s; }
.wcvm-grid-item:nth-child(2) { animation-delay: 0.1s; }
.wcvm-grid-item:nth-child(3) { animation-delay: 0.15s; }
.wcvm-grid-item:nth-child(4) { animation-delay: 0.2s; }
.wcvm-grid-item:nth-child(5) { animation-delay: 0.25s; }
.wcvm-grid-item:nth-child(6) { animation-delay: 0.3s; }

/* ==================== NOTICES ==================== */

/*
 * Shown to users who can edit products when the matrix cannot be rendered
 * and WooCommerce's default form is displayed instead.
 */
.wcvm-notice,
.wcvm-error {
    margin: 15px 0;
    padding: 12px 16px;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
}

.wcvm-notice-warning {
    background-color: #fffbeb;
    border: 1px solid #fcd34d;
    color: #92400e;
}

.wcvm-error {
    background-color: #fef3f2;
    border: 1px solid #fda29b;
    color: #b42318;
}

/* ==================== ACCESSIBILITY ==================== */

.wcvm-variation-matrix .wcvm-qty-input:focus-visible,
.wcvm-variation-matrix .wcvm-add-to-cart-btn:focus-visible,
.wcvm-variation-matrix .wcvm-bulk-add-to-cart:focus-visible {
    outline: 2px solid var(--wcvm-accent);
    outline-offset: 2px;
}

/* Screen reader only text */
.wcvm-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ==================== PRINT STYLES ==================== */

@media print {
    .wcvm-add-to-cart-btn,
    .wcvm-bulk-add-to-cart,
    .wcvm-single-add-btn,
    .wcvm-add-to-cart-section,
    .wcvm-bulk-actions,
    .wcvm-messages {
        display: none !important;
    }

    .wcvm-matrix-container {
        overflow: visible;
    }

    .wcvm-grid-item,
    .wcvm-matrix-table {
        page-break-inside: avoid;
    }
}

/* ==================== REDUCED MOTION ==================== */

@media (prefers-reduced-motion: reduce) {

    .wcvm-grid-item,
    .wcvm-matrix-variation,
    .wcvm-message,
    .wcvm-variation-matrix .wcvm-add-to-cart-btn,
    .wcvm-variation-matrix .wcvm-bulk-add-to-cart,
    .wcvm-variation-matrix .wcvm-single-add-btn,
    .wcvm-variation-matrix .wcvm-qty-input {
        animation: none !important;
        transition: none !important;
    }

    .wcvm-grid-item:hover,
    .wcvm-variation-matrix .wcvm-add-to-cart-btn:active:not(:disabled),
    .wcvm-variation-matrix .wcvm-bulk-add-to-cart:active:not(:disabled) {
        transform: none;
    }
}
