/* =============================================================================
 * VARIATION SWATCHES — COLOUR CIRCLES AND THEIR NAMES
 * =============================================================================
 * Component: The colour picker of a variable product.
 * Owner:     Rainbow Store plugin (markup) + parent theme (sizes).
 * Scope:     Product page, quick view and the cart-edit popup
 *            (#quickviewEditCartModal), because all three print the same
 *            ".variations_form .rbt-color-select-area" markup.
 *
 * WHAT THIS FILE DOES
 *   1. Makes the circles 2px larger than the sizes this site used before
 *      (34px on desktop and tablet, 30px on phones). The parent theme draws them
 *      at 24px / 20px / 12px, which is hard to see and to tap.
 *   2. Gives every colour a name under its circle (the text itself is added by
 *      inc/variations/swatch-names.php), centred under the circle's centre, always
 *      visible, readable and not oversized.
 *   3. Makes the selected colour obvious in the text as well as in the ring.
 *
 * LAYOUT, AND WHY IT HOLDS UP WITH TEN COLOURS
 *   - Every colour is one fixed-width cell (68px). The circle is centred in the
 *     cell and the name is centred under the circle, so the name is always
 *     centred under the circle's centre, in any direction and any width.
 *   - Cells wrap (the list is a wrapping flex row, set by the plugin), so ten
 *     colours become two or more tidy rows and never push the page sideways.
 *   - The name is cut at 10 characters on the server; "text-overflow" is only a
 *     safety net for very wide letters, so a long name can never overlap the cell
 *     next to it.
 *   - The name is absolutely positioned under the circle (it adds no width) and
 *     the cell reserves the room below with padding, so rows do not overlap.
 *
 * TEXT STATES (contrast checked against the white card)
 *   - Not selected: dark grey #333, regular weight, 13px (12px on phones).
 *   - Selected:     black, bold, with a short brand-colour underline. The circle
 *                   keeps the plugin's selection ring, so the choice is clear
 *                   from the ring, the weight and the colour, not from colour alone.
 *
 * SPECIFICITY: the selectors are more specific than the parent theme's and
 * Rainbow Store's (including their media queries), so no !important is needed.
 * The size rules were moved here from pages/single-product.css, which only kept
 * the page-specific rules.
 * ========================================================================== */

/* The heading ("اللون") gets its own line above the swatches. Next to them (the parent
   theme's flex row) the swatches only had ~160px, so more than two colours squeezed
   into a column. Only colour pickers are affected (:has), size/button pickers keep
   the parent layout. The heading sits at the reading-direction start (the right in RTL).
   The longer chain outranks the plugin's cart-edit popup rule that forces a row. */
.variations_form .rbt-store-variation-controls .rbt-info-wrapper .prd-id-text:has(.rbt-switcher-color-list-lg) {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    /* Full width, so the cells can wrap along the whole row instead of a ~160px column. */
    width: 100%;
}

.variations_form .prd-id-text:has(.rbt-switcher-color-list-lg) .unimart-variation-value,
.variations_form .prd-id-text:has(.rbt-switcher-color-list-lg) .rbt-store-color-variaiton-root,
.variations_form .prd-id-text:has(.rbt-switcher-color-list-lg) .rbt-color-select-area {
    width: 100%;
    height: auto;
}

/* The "reset all" button used to sit in the same row and kept ~130px of it even while
   hidden, which is what squeezed the swatches. It now floats on the heading line, at
   the end side (the left in RTL), and takes no room. */
.variations_form .prd-info-section:has( > .prd-id-text .rbt-switcher-color-list-lg) {
    position: relative;
    width: 100%;
}

.variations_form .prd-info-section:has( > .prd-id-text .rbt-switcher-color-list-lg) > .reset_variations {
    position: absolute;
    top: 0;
    inset-inline-end: 0;
}

/* One cell per colour: circle on top, name below. */
/* "ul" is in the selector to outrank the theme's ul.rbt-switcher-variation-list rule. */
.variations_form .rbt-color-select-area ul.rbt-switcher-color-list.rbt-switcher-color-list-lg.product-switcher-activation {
    gap: 6px 8px;
    /* The parent theme fixes the list at 36px, which cut off the room for the names. */
    height: auto;
    min-height: 36px;
    margin-inline-start: 0;
}

.variations_form .rbt-color-select-area .rbt-switcher-color-list.rbt-switcher-color-list-lg li {
    display: flex;
    justify-content: center;
    width: 68px;
    /* Room for the name that hangs under the circle (it is absolutely positioned). */
    padding-bottom: 26px;
}

/* Circle size: 34px (was 32px). */
.variations_form .rbt-color-select-area .rbt-switcher-color-list.rbt-switcher-color-list-lg li .rbt-switcher--color,
.variations_form .rbt-color-select-area .rbt-switcher-color-list.rbt-switcher-color-list-lg li .rbt-switcher--color .rbt-color-circle {
    width: 34px;
    height: 34px;
}

/* The selection ring stays 10px larger than the circle. */
.variations_form .rbt-color-select-area .rbt-switcher-color-list.rbt-switcher-color-list-lg li .rbt-switcher--color::after {
    width: calc(100% + 10px);
    height: calc(100% + 10px);
}

/* The name, centred under the circle's centre. */
.variations_form .rbt-color-select-area .rbt-switcher-color-list.rbt-switcher-color-list-lg li .rbt-switcher--color .unimart-swatch-name {
    position: absolute;
    /* Below the circle and its 5px ring, plus a small gap. */
    top: calc(100% + 11px);
    /* "left: 50%" + translate is centring on purpose: it is the same in both directions. */
    left: 50%;
    transform: translateX(-50%);
    width: 68px;
    text-align: center;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.3;
    color: var(--color-gray-700, #333);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* The link is the click target; the label must not eat the tooltip hover. */
    pointer-events: none;
}

/* Selected colour: black and bold, with a short underline in the brand colour. */
.variations_form .rbt-color-select-area .rbt-switcher-color-list.rbt-switcher-color-list-lg li .rbt-switcher--color.active .unimart-swatch-name {
    color: #000;
    font-weight: 700;
    text-decoration: underline;
    text-decoration-color: var(--color-primary, #e85a9b);
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}

/* Phones: circle 30px (was 28px), name 12px, ring 8px larger than the circle. */
@media only screen and (max-width: 767px) {
    .variations_form .rbt-color-select-area .rbt-switcher-color-list.rbt-switcher-color-list-lg li .rbt-switcher--color,
    .variations_form .rbt-color-select-area .rbt-switcher-color-list.rbt-switcher-color-list-lg li .rbt-switcher--color .rbt-color-circle {
        width: 30px;
        height: 30px;
    }

    .variations_form .rbt-color-select-area .rbt-switcher-color-list.rbt-switcher-color-list-lg li .rbt-switcher--color::after {
        width: calc(100% + 8px);
        height: calc(100% + 8px);
    }

    .variations_form .rbt-color-select-area .rbt-switcher-color-list.rbt-switcher-color-list-lg li .rbt-switcher--color .unimart-swatch-name {
        top: calc(100% + 9px);
        font-size: 12px;
    }
}
