/* =============================================================================
 * PAYMENT METHODS (CHECKOUT)
 * =============================================================================
 * Component: the list of payment methods under "دفع آمن" on the checkout page
 *            (WooCommerce "#payment .wc_payment_methods"). Today there is one method,
 *            cash on delivery; the rules also hold for several.
 * Owner:     Child theme. Markup comes from WooCommerce (checkout/payment-method.php):
 *              <li class="wc_payment_method payment_method_cod">
 *                <input type="radio" class="input-radio" id="payment_method_cod" ...>
 *                <label for="payment_method_cod">Title + icon</label>
 *                <div class="payment_box">description (optional)</div>
 *              </li>
 *
 * The problem this fixes
 * ----------------------
 * The parent theme draws the radio mark on the label with  input[type=radio]~label::before
 * at "left: 0" with "padding-left: 24px". It has a right-to-left version of those rules,
 * but it is written for  body.wp-theme-unimart.rtl , and this site's parent theme folder is
 * "unimart-multipurpose-woocommerce-wordpress-theme", so the body class is
 * "wp-theme-unimart-multipurpose-woocommerce-wordpress-theme" and the right-to-left
 * rules never match (670 of the 678 rules in the parent's common-rtl.css are in this
 * state). Result in Arabic: the mark sits on the LEFT and the text starts next to it, the
 * opposite of how the rest of the page reads.
 *
 * Why only this component and not "add the missing body class"
 * ------------------------------------------------------------
 * Adding the class would switch on all 670 dormant rules at once. Measured with the class
 * added by hand, it moved the header search box, the top announcement swiper and about
 * 120 elements of the home page. Too wide for a checkout fix. This file corrects the one
 * component that is wrong.
 *
 * Layout (same family as the shipping region cards, assets/css/components/shipping-regions.css)
 * ---------------------------------------------------------------------------------------------
 * Each method is a full-width card: the radio mark at the start edge (the RIGHT in Arabic),
 * the title to its left, then the icon if the gateway has one. Only logical properties are
 * used, so there is nothing direction-specific to maintain.
 *
 * The parent's mark is drawn with two pseudo-elements (::before ring, ::after dot) positioned
 * with left/right. Here the card is a flex row: ::before becomes the ring AND the dot (an inner
 * white/colored shadow), is an ordinary flex item (so it follows the reading direction), and
 * ::after is switched off.
 *
 * Specificity: every selector starts with  .woocommerce-checkout-payment .wc_payment_methods
 * and the card with  > .wc_payment_method > label , which beats the parent's
 * "input[type=radio]~label" family (0,1,2) and its ".rbt-..." variants.
 * ============================================================================= */

.woocommerce-checkout-payment .wc_payment_methods {
    display: grid;
    gap: 8px;
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
}

.woocommerce-checkout-payment .wc_payment_methods > .wc_payment_method {
    position: relative;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* -----------------------------------------------------------------------------
 * The native radio input
 * -----------------------------------------------------------------------------
 * The theme hides it with an inline "display: none", which also removes it from the
 * keyboard order. It is kept visually hidden but focusable instead, so that with several
 * payment methods the arrow keys and Tab still work. "!important" is needed only to beat
 * the inline style.
 * --------------------------------------------------------------------------- */
.woocommerce-checkout-payment .wc_payment_methods > .wc_payment_method > input.input-radio {
    display: block !important;
    position: absolute;
    inset-inline-start: 0;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

/* -----------------------------------------------------------------------------
 * The card (the label)
 * --------------------------------------------------------------------------- */
.woocommerce-checkout-payment .wc_payment_methods > .wc_payment_method > label {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    box-sizing: border-box;
    width: 100%;
    min-height: 52px;
    margin: 0;
    padding-block: 10px;
    padding-inline: 14px;
    background-color: #fff;
    border: 1.5px solid var(--color-gray-200, #e6e6e6);
    border-radius: 10px;
    font-size: var(--font-size-b2, 16px);
    font-weight: 500;
    line-height: 1.5;
    color: var(--color-heading, #000);
    text-align: start;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

/* The mark: a ring, with a dot drawn inside it when the method is chosen. First flex item,
   so it sits at the start edge: the right in Arabic. */
.woocommerce-checkout-payment .wc_payment_methods > .wc_payment_method > label::before {
    content: "";
    position: static;
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    box-sizing: border-box;
    transform: none;
    border: 2px solid var(--color-gray-300, #cfcfcf);
    border-radius: 50%;
    background-color: #fff;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

/* The parent's check mark / dot is not used. */
.woocommerce-checkout-payment .wc_payment_methods > .wc_payment_method > label::after {
    display: none;
}

/* The gateway's icon (for example card brands) goes to the far end of the card. */
.woocommerce-checkout-payment .wc_payment_methods > .wc_payment_method > label img {
    margin-inline-start: auto;
    max-height: 24px;
    width: auto;
}

/* -----------------------------------------------------------------------------
 * States
 * --------------------------------------------------------------------------- */
@media (hover: hover) {
    .woocommerce-checkout-payment .wc_payment_methods > .wc_payment_method > input.input-radio:not(:checked) ~ label:hover {
        border-color: var(--color-primary);
    }
}

.woocommerce-checkout-payment .wc_payment_methods > .wc_payment_method > input.input-radio:checked ~ label {
    border-color: var(--color-primary);
    background-color: var(--color-gray-100, #f3f3f3);
    font-weight: 600;
    color: var(--color-heading, #000);
}

@supports (background-color: color-mix(in srgb, red 10%, white)) {
    .woocommerce-checkout-payment .wc_payment_methods > .wc_payment_method > input.input-radio:checked ~ label {
        background-color: color-mix(in srgb, var(--color-primary) 8%, #fff);
    }
}

.woocommerce-checkout-payment .wc_payment_methods > .wc_payment_method > input.input-radio:checked ~ label::before {
    border-color: var(--color-primary);
    background-color: var(--color-primary);
    box-shadow: inset 0 0 0 3px #fff;
}

/* Keyboard focus only (a mouse or touch choice does not draw the ring). */
.woocommerce-checkout-payment .wc_payment_methods > .wc_payment_method > input.input-radio:focus-visible ~ label {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* -----------------------------------------------------------------------------
 * The method's description box (shown under the card of the chosen method)
 * --------------------------------------------------------------------------- */
.woocommerce-checkout-payment .wc_payment_methods > .wc_payment_method > .payment_box {
    margin: 8px 0 0;
    padding-block: 0;
    padding-inline: 4px;
    font-size: var(--font-size-b3, 14px);
    line-height: 1.6;
    color: var(--color-body, #737373);
    text-align: start;
}

@media (prefers-reduced-motion: reduce) {
    .woocommerce-checkout-payment .wc_payment_methods > .wc_payment_method > label,
    .woocommerce-checkout-payment .wc_payment_methods > .wc_payment_method > label::before {
        transition: none;
    }
}
