/**
 * WooForm 2.2 — order button, delivery line, honest urgency and the small
 * conversion helpers. Loaded only where the order form is.
 *
 * Logical properties throughout, so RTL (Arabic) needs no mirror rules.
 * Every animation is switched off under prefers-reduced-motion.
 */

/* ------------------------------------------------------------------ *
 * 1. Button content: icon, template, second line
 * ------------------------------------------------------------------ */

.codwo-product-form-wrapper .codwo-submit-btn .codwo-btn-icon {
    flex: none;
    width: 1.2em;
    height: 1.2em;
}

.codwo-product-form-wrapper .codwo-btn-text--stack {
    flex-direction: column;
    gap: 2px;
}

.codwo-product-form-wrapper .codwo-btn-main {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 10px;
}

.codwo-product-form-wrapper .codwo-btn-sub {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.35;
    opacity: 0.92;
    letter-spacing: 0;
}

/* Template mode: the total sits inside the sentence, not in a chip. */
.codwo-product-form-wrapper.codwo-product-form-wrapper .codwo-btn-text--tpl .codwo-btn-price--inline {
    display: inline;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    unicode-bidi: isolate;
    white-space: nowrap;
}

.codwo-product-form-wrapper .codwo-btn-text--tpl .codwo-btn-label {
    display: inline;
}

.codwo-product-form-wrapper .codwo-btn-qty {
    font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ *
 * 2. Button animations (CSS only)
 * ------------------------------------------------------------------ */

/* A chosen animation replaces the skin's own nudge / shine. */
.codwo-product-form-wrapper.codwo-cta-anim-override.codwo-cta-anim-override .codwo-submit-btn {
    animation: none;
}

.codwo-product-form-wrapper.codwo-cta-anim-override.codwo-cta-anim-override .codwo-submit-btn::after {
    content: none;
}

/* "Always": loop with a rest between beats so it never feels frantic. */
.codwo-product-form-wrapper.codwo-cta-anim-override .codwo-submit-btn.codwo-cta-anim--pulse.codwo-cta-play-loop { animation: codwo-cta-pulse 2.6s ease-in-out 1s infinite; }
.codwo-product-form-wrapper.codwo-cta-anim-override .codwo-submit-btn.codwo-cta-anim--shake.codwo-cta-play-loop { animation: codwo-cta-shake 4s ease-in-out 1.5s infinite; }
.codwo-product-form-wrapper.codwo-cta-anim-override .codwo-submit-btn.codwo-cta-anim--bounce.codwo-cta-play-loop { animation: codwo-cta-bounce 3.2s ease-in-out 1s infinite; }
.codwo-product-form-wrapper.codwo-cta-anim-override .codwo-submit-btn.codwo-cta-anim--heartbeat.codwo-cta-play-loop { animation: codwo-cta-heartbeat 2.4s ease-in-out 1s infinite; }
.codwo-product-form-wrapper.codwo-cta-anim-override .codwo-submit-btn.codwo-cta-anim--glow.codwo-cta-play-loop { animation: codwo-cta-glow 2.4s ease-in-out 1s infinite; }
.codwo-product-form-wrapper.codwo-cta-anim-override .codwo-submit-btn.codwo-cta-anim--shine.codwo-cta-play-loop::before { animation: codwo-cta-shine 3.4s ease-in-out 1s infinite; }

/* One-shot plays (every N seconds, in view, idle): one full beat. */
.codwo-product-form-wrapper.codwo-cta-anim-override .codwo-submit-btn.codwo-cta-anim--pulse.codwo-cta-play { animation: codwo-cta-pulse-once 0.9s ease-in-out 2; }
.codwo-product-form-wrapper.codwo-cta-anim-override .codwo-submit-btn.codwo-cta-anim--shake.codwo-cta-play { animation: codwo-cta-shake-once 0.7s ease-in-out 1; }
.codwo-product-form-wrapper.codwo-cta-anim-override .codwo-submit-btn.codwo-cta-anim--bounce.codwo-cta-play { animation: codwo-cta-bounce-once 0.9s ease 1; }
.codwo-product-form-wrapper.codwo-cta-anim-override .codwo-submit-btn.codwo-cta-anim--heartbeat.codwo-cta-play { animation: codwo-cta-heartbeat-once 1.2s ease-in-out 1; }
.codwo-product-form-wrapper.codwo-cta-anim-override .codwo-submit-btn.codwo-cta-anim--glow.codwo-cta-play { animation: codwo-cta-glow-once 1.4s ease-in-out 1; }
.codwo-product-form-wrapper.codwo-cta-anim-override .codwo-submit-btn.codwo-cta-anim--shine.codwo-cta-play::before { animation: codwo-cta-shine-once 1.1s ease-in-out 1; }

/* The shine sweep lives on ::before (skins use ::after). */
.codwo-product-form-wrapper .codwo-submit-btn.codwo-cta-anim--shine::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.34) 46%, transparent 62%);
    transform: translateX(-130%);
    pointer-events: none;
}

.codwo-product-form-wrapper .codwo-submit-btn.codwo-cta-anim--shine > * {
    position: relative;
    z-index: 1;
}

[dir="rtl"] .codwo-product-form-wrapper .codwo-submit-btn.codwo-cta-anim--shine::before,
.codwo-rtl.codwo-product-form-wrapper .codwo-submit-btn.codwo-cta-anim--shine::before {
    transform: translateX(130%);
}

/* Hold still while the shopper is pointing at it or it is busy. */
.codwo-product-form-wrapper .codwo-submit-btn.codwo-cta-anim:hover,
.codwo-product-form-wrapper .codwo-submit-btn.codwo-cta-anim:focus-visible,
.codwo-product-form-wrapper .codwo-submit-btn.codwo-cta-anim:disabled,
.codwo-product-form-wrapper .codwo-submit-btn.codwo-cta-anim:hover::before,
.codwo-product-form-wrapper .codwo-submit-btn.codwo-cta-anim:disabled::before {
    animation-play-state: paused;
}

@keyframes codwo-cta-pulse {
    0%, 70%, 100% { transform: scale(1); }
    78% { transform: scale(1.035); }
    86% { transform: scale(1); }
    93% { transform: scale(1.02); }
}

@keyframes codwo-cta-pulse-once {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.035); }
}

@keyframes codwo-cta-shake {
    0%, 82%, 100% { transform: translateX(0); }
    84%, 88%, 92% { transform: translateX(-4px); }
    86%, 90%, 94% { transform: translateX(4px); }
}

@keyframes codwo-cta-shake-once {
    0%, 100% { transform: translateX(0); }
    15%, 45%, 75% { transform: translateX(-4px); }
    30%, 60%, 90% { transform: translateX(4px); }
}

@keyframes codwo-cta-bounce {
    0%, 72%, 100% { transform: translateY(0); }
    78% { transform: translateY(-6px); }
    84% { transform: translateY(0); }
    89% { transform: translateY(-3px); }
    94% { transform: translateY(0); }
}

@keyframes codwo-cta-bounce-once {
    0%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
    55% { transform: translateY(0); }
    75% { transform: translateY(-3px); }
}

@keyframes codwo-cta-heartbeat {
    0%, 60%, 100% { transform: scale(1); }
    66% { transform: scale(1.045); }
    72% { transform: scale(1); }
    78% { transform: scale(1.045); }
    86% { transform: scale(1); }
}

@keyframes codwo-cta-heartbeat-once {
    0%, 100% { transform: scale(1); }
    15% { transform: scale(1.045); }
    30% { transform: scale(1); }
    45% { transform: scale(1.045); }
    65% { transform: scale(1); }
}

@keyframes codwo-cta-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0), var(--codwo-shadow-cta, none); }
    50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--codwo-button-bg) 28%, transparent), 0 0 22px 2px color-mix(in srgb, var(--codwo-button-bg) 45%, transparent); }
}

@keyframes codwo-cta-glow-once {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); }
    50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--codwo-button-bg) 28%, transparent), 0 0 22px 2px color-mix(in srgb, var(--codwo-button-bg) 45%, transparent); }
}

@keyframes codwo-cta-shine {
    0%, 60% { transform: translateX(-130%); }
    85%, 100% { transform: translateX(130%); }
}

@keyframes codwo-cta-shine-once {
    from { transform: translateX(-130%); }
    to { transform: translateX(130%); }
}

/* ------------------------------------------------------------------ *
 * 3. Delivery line, savings, nudge, social proof, urgency
 * ------------------------------------------------------------------ */

.codwo-product-form-wrapper .codwo-cta-zone {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Nothing to show (all lines hidden): take no room in the form. */
.codwo-product-form-wrapper .codwo-cta-zone:not(:has(> :not([hidden]))) {
    display: none;
}

.codwo-product-form-wrapper .codwo-cta-zone [hidden],
.codwo-product-form-wrapper [data-codwo-delivery][hidden] {
    display: none !important;
}

.codwo-product-form-wrapper .codwo-delivery-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 10px;
    margin: 0;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.45;
    color: var(--codwo-text);
}

.codwo-product-form-wrapper .codwo-delivery-eta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.codwo-product-form-wrapper .codwo-delivery-eta svg {
    width: 18px;
    height: 18px;
    flex: none;
    color: var(--codwo-primary);
}

.codwo-product-form-wrapper .codwo-free-ship-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    background: #e8f6ee;
    color: #14532d;
    font-size: 12.5px;
    font-weight: 800;
    line-height: 1.6;
}

.codwo-product-form-wrapper .codwo-ship-nudge,
.codwo-product-form-wrapper .codwo-savings,
.codwo-product-form-wrapper .codwo-social-proof,
.codwo-product-form-wrapper .codwo-urgency-stock {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0;
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.45;
    text-align: center;
}

.codwo-product-form-wrapper .codwo-ship-nudge {
    padding: 7px 12px;
    border-radius: 10px;
    background: #fff7e6;
    color: #7a4b00;
}

.codwo-product-form-wrapper .codwo-savings {
    color: #166534;
}

.codwo-product-form-wrapper .codwo-social-proof {
    color: var(--codwo-text-muted);
    font-weight: 600;
}

.codwo-product-form-wrapper .codwo-urgency-stock {
    color: #b42318;
}

.codwo-product-form-wrapper .codwo-urgency-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
    animation: codwo-cta-dot 1.6s ease-in-out infinite;
}

@keyframes codwo-cta-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.codwo-product-form-wrapper .codwo-countdown {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    background: #fef3f2;
    color: #912018;
    font-size: 13.5px;
    font-weight: 700;
}

.codwo-product-form-wrapper .codwo-countdown__time {
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    letter-spacing: 0.02em;
    unicode-bidi: isolate;
}

/* Trust badges directly under the button: a compact row. */
.codwo-product-form-wrapper .codwo-trust-badges.codwo-trust-badges--under {
    margin-block-start: 12px;
    padding-block-start: 12px;
}

/* Free delivery says "Free" in the summary instead of disappearing. */
.codwo-product-form-wrapper .codwo-shipping-row--free .codwo-shipping-amount {
    color: #166534;
    font-weight: 800;
}

/* ------------------------------------------------------------------ *
 * 4. City dropdown and product extra fields
 * ------------------------------------------------------------------ */

.codwo-product-form-wrapper .codwo-field-group .codwo-city-select,
.codwo-product-form-wrapper .codwo-field-group .codwo-pf-select {
    width: 100%;
    height: var(--codwo-input-height, 46px);
    padding-inline-end: 38px;
    background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 16px;
    background-position: right 14px center;
    cursor: pointer;
}

.codwo-rtl.codwo-product-form-wrapper .codwo-field-group .codwo-city-select,
.codwo-rtl.codwo-product-form-wrapper .codwo-field-group .codwo-pf-select {
    background-position: left 14px center;
}

.codwo-product-form-wrapper .codwo-field-group .codwo-city-other:not(.codwo-is-hidden) {
    margin-block-start: 8px;
}

.codwo-product-form-wrapper .codwo-city-other.codwo-is-hidden {
    display: none !important;
}

/* ------------------------------------------------------------------ *
 * 5. Small feedback animations
 * ------------------------------------------------------------------ */

.codwo-micro .codwo-promo-option.codwo-pop,
.codwo-product-form-wrapper .codwo-free-ship-badge.codwo-pop {
    animation: codwo-cta-pop 0.32s ease-out;
}

.codwo-micro .codwo-bump {
    display: inline-block;
    animation: codwo-cta-bump 0.36s ease-out;
}

.codwo-micro .codwo-field-group.codwo-shake {
    animation: codwo-cta-field-shake 0.4s ease-in-out;
}

@keyframes codwo-cta-pop {
    0% { transform: scale(1); }
    45% { transform: scale(1.025); }
    100% { transform: scale(1); }
}

@keyframes codwo-cta-bump {
    0% { transform: scale(1); }
    40% { transform: scale(1.12); }
    100% { transform: scale(1); }
}

@keyframes codwo-cta-field-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

/* ------------------------------------------------------------------ *
 * 6. Sticky bar: button-only variant
 * ------------------------------------------------------------------ */

.codwo-sticky-cta.codwo-sticky-cta--button-only {
    justify-content: center;
}

.codwo-sticky-cta.codwo-sticky-cta--button-only .codwo-sticky-cta__btn {
    flex: 1 1 auto;
    width: 100%;
}

/* ------------------------------------------------------------------ *
 * 7. Reduced motion: nothing moves
 * ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
    .codwo-product-form-wrapper .codwo-submit-btn,
    .codwo-product-form-wrapper .codwo-submit-btn::before,
    .codwo-product-form-wrapper .codwo-submit-btn::after,
    .codwo-product-form-wrapper .codwo-urgency-dot,
    .codwo-product-form-wrapper .codwo-pop,
    .codwo-product-form-wrapper .codwo-bump,
    .codwo-product-form-wrapper .codwo-shake,
    .codwo-sticky-cta {
        animation: none !important;
        transition: none !important;
    }
}

/* ------------------------------------------------------------------ *
 * 8. Success modal + celebration
 * ------------------------------------------------------------------ */

.codwo-success-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, 0.55);
    opacity: 0;
    transition: opacity 0.2s ease;
    overflow: hidden;
}

.codwo-success-modal.is-in {
    opacity: 1;
}

.codwo-success-modal__box {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
    padding: 28px 22px 22px;
    border-radius: 22px;
    background: #fff;
    color: #0f172a;
    text-align: center;
    box-shadow: 0 30px 60px -20px rgba(15, 23, 42, 0.5);
    transform: scale(0.86) translateY(14px);
    transition: transform 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.codwo-success-modal.is-in .codwo-success-modal__box {
    transform: none;
}

.codwo-success-modal__burst {
    position: relative;
    display: grid;
    place-items: center;
    width: 84px;
    height: 84px;
    margin: -64px auto 10px;
    border-radius: 50%;
    background: var(--codwo-success, #16a34a);
    color: #fff;
    box-shadow: 0 12px 26px -8px rgba(22, 163, 74, 0.6);
}

/* The "boom": a ring that bursts out of the check. */
.codwo-success-modal__burst::before,
.codwo-success-modal__burst::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid var(--codwo-success, #16a34a);
    opacity: 0;
    animation: codwo-success-boom 0.9s ease-out 0.15s 1 both;
}

.codwo-success-modal__burst::after {
    animation-delay: 0.35s;
}

.codwo-success-modal__check svg circle {
    stroke: rgba(255, 255, 255, 0.35);
    stroke-width: 3;
}

.codwo-success-modal__check svg path {
    stroke: #fff;
    stroke-width: 5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
    animation: codwo-success-draw 0.45s ease-out 0.25s forwards;
}

.codwo-success-modal__title {
    margin: 4px 0 6px;
    font-size: 22px;
    font-weight: 800;
    line-height: 1.35;
    color: #0f172a;
}

.codwo-success-modal__msg,
.codwo-success-modal__note {
    margin: 0 0 10px;
    font-size: 15px;
    line-height: 1.6;
    color: #334155;
}

.codwo-success-modal__number {
    display: inline-flex;
    gap: 6px;
    align-items: baseline;
    margin: 4px 0 10px;
    padding: 8px 14px;
    border-radius: 12px;
    background: #f1f5f9;
    font-size: 15px;
    color: #0f172a;
}

.codwo-success-modal__number strong {
    font-size: 18px;
    letter-spacing: 0.02em;
    unicode-bidi: isolate;
}

.codwo-success-modal__total {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}

.codwo-success-modal__actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-block-start: 14px;
}

.codwo-success-modal__ok {
    min-height: 50px;
    border: 0;
    border-radius: 14px;
    background: var(--codwo-button-bg, #0f4c81);
    color: var(--codwo-button-text, #fff);
    font: inherit;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
}

.codwo-success-modal__ok:focus-visible,
.codwo-success-modal__shop:focus-visible {
    outline: 3px solid #0f172a;
    outline-offset: 2px;
}

.codwo-success-modal__shop {
    font-size: 14px;
    font-weight: 700;
    color: var(--codwo-primary, #0f4c81);
    text-decoration: underline;
}

.codwo-success-modal__redirect {
    margin: 0;
    font-size: 13px;
    color: #64748b;
}

.codwo-confetti {
    position: absolute;
    left: 50%;
    top: 42%;
    width: 0;
    height: 0;
    z-index: 2;
    pointer-events: none;
}

.codwo-confetti i {
    position: absolute;
    width: 8px;
    height: 13px;
    border-radius: 2px;
    opacity: 0;
    animation: codwo-confetti var(--d, 1.4s) cubic-bezier(0.15, 0.7, 0.4, 1) forwards;
}

.codwo-confetti i.is-round {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

@keyframes codwo-confetti {
    0% { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(0.6); }
    70% { opacity: 1; }
    100% { opacity: 0; transform: translate(var(--x), calc(var(--y) + 160px)) rotate(var(--r)) scale(1); }
}

@keyframes codwo-success-boom {
    0% { opacity: 0.8; transform: scale(1); }
    100% { opacity: 0; transform: scale(2.1); }
}

@keyframes codwo-success-draw {
    to { stroke-dashoffset: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .codwo-success-modal,
    .codwo-success-modal__box,
    .codwo-success-modal__burst::before,
    .codwo-success-modal__burst::after {
        animation: none !important;
        transition: none !important;
    }
    .codwo-success-modal__check svg path {
        animation: none !important;
        stroke-dashoffset: 0;
    }
    .codwo-confetti {
        display: none !important;
    }
}
