/**
 * Cart Email Nudge – cart-nudge.css v3.0.0
 *
 * Design notes:
 *  - Signature moment: the first appearance dims the page (spotlight) and the
 *    card arrives from the top-right with a soft settle. Everything else stays
 *    quiet and disciplined.
 *  - Namespaced under .cpe- to avoid collisions with the theme.
 *  - Respects prefers-reduced-motion and is keyboard-focus friendly.
 */

:root {
    --cpe-radius: 16px;
    --cpe-shadow-lg: 0 18px 50px rgba(20, 20, 45, 0.22);
    --cpe-shadow-md: 0 8px 24px rgba(20, 20, 45, 0.16);
    --cpe-ink: #222222;
    --cpe-muted: #75808d;
    --cpe-line: #e5e9ee;
    /* Brand palette (USA Cabinets) */
    --cpe-blue: #1565d8;
    --cpe-blue-dark: #0e4fae;
    --cpe-red: #e22323;
    --cpe-red-deep: #d92237;
    --cpe-tint: #f6f8fa;
}

/* ============================================================
 *  SPOTLIGHT BACKDROP (first appearance + popup)
 * ========================================================== */
.cpe-nudge-backdrop {
    position: fixed;
    inset: 0;
    background: radial-gradient(120% 90% at 88% 8%, rgba(10, 10, 25, 0) 0%, rgba(10, 10, 25, 0.34) 42%, rgba(10, 10, 25, 0.5) 100%);
    opacity: 0;
    transition: opacity 0.45s ease;
    z-index: 2147483000;
    pointer-events: auto;
}
.cpe-nudge-backdrop.cpe-visible {
    opacity: 1;
}

/* ============================================================
 *  CORNER CARD (top-right)
 * ========================================================== */
.cpe-nudge-card {
    position: fixed;
    top: 22px;
    right: 22px;
    width: 340px;
    max-width: calc(100vw - 32px);
    background: #ffffff;
    border-radius: var(--cpe-radius);
    box-shadow: var(--cpe-shadow-lg);
    z-index: 2147483001;
    padding: 20px 20px 22px;
    opacity: 0;
    transform: translateY(-14px) scale(0.97);
    transform-origin: top right;
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(20, 20, 45, 0.06);
}
.cpe-nudge-card.cpe-in {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.cpe-nudge-card.cpe-out {
    opacity: 0;
    transform: translateY(-10px) scale(0.96);
    pointer-events: none;
}

/* Thin accent rail at the top edge for a crafted feel */
.cpe-nudge-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 22px;
    right: 22px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: currentColor;
    color: var(--cpe-accent, var(--cpe-red-deep));
    opacity: 0.9;
}

.cpe-nudge-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: #9099a5;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s ease, color 0.15s ease;
}
.cpe-nudge-close:hover { background: var(--cpe-tint); color: var(--cpe-blue); }

.cpe-nudge-body {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.cpe-nudge-icon {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: rgba(217, 34, 55, 0.08);
    margin-top: 2px;
}
.cpe-nudge-icon svg { width: 22px; height: 22px; }

.cpe-nudge-copy { min-width: 0; }

.cpe-nudge-heading {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.25;
    color: var(--cpe-ink);
}

.cpe-nudge-text {
    margin: 0 0 14px;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--cpe-muted);
}

.cpe-nudge-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 11px 18px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    letter-spacing: 0.2px;
    transition: transform 0.12s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    box-shadow: 0 4px 14px rgba(20, 20, 45, 0.18);
}
.cpe-nudge-cta:hover { transform: translateY(-1px); background: var(--cpe-blue-dark) !important; box-shadow: 0 6px 18px rgba(21, 101, 216, 0.3); }
.cpe-nudge-cta:active { transform: translateY(0); }

/* ============================================================
 *  QUIET ICON (dismissed, persistent)
 * ========================================================== */
.cpe-nudge-quiet {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid rgba(20, 20, 45, 0.08);
    box-shadow: var(--cpe-shadow-md);
    cursor: pointer;
    z-index: 2147483000;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cpe-blue);
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.2s ease, background 0.15s ease, color 0.15s ease;
}
.cpe-nudge-quiet.cpe-visible { opacity: 0.85; transform: scale(1); }
.cpe-nudge-quiet:hover {
    opacity: 1;
    background: var(--cpe-blue);
    color: #ffffff;
    box-shadow: var(--cpe-shadow-lg);
}

/* Glyph wrapper is the single centered element (keeps SVG dead-center) */
.cpe-quiet-glyph {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}
.cpe-nudge-quiet svg { width: 22px; height: 22px; display: block; }

/* Pulse is a pure overlay ring — absolutely positioned, does NOT affect
   the flex centering of the glyph, and uses the brand blue. */
.cpe-quiet-pulse {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    pointer-events: none;
    box-shadow: 0 0 0 0 rgba(21, 101, 216, 0.45);
    animation: cpe-pulse 2.6s ease-out 3;
}
@keyframes cpe-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(21, 101, 216, 0.40); }
    70%  { box-shadow: 0 0 0 14px rgba(21, 101, 216, 0); }
    100% { box-shadow: 0 0 0 0 rgba(21, 101, 216, 0); }
}

/* ============================================================
 *  POPUP MODAL (centered, dimmed backdrop)
 * ========================================================== */
.cpe-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 25, 0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    display: grid;
    place-items: center;
    padding: 20px;
    z-index: 2147483010;
    opacity: 0;
    transition: opacity 0.26s ease;
}
.cpe-popup-overlay.cpe-visible { opacity: 1; }

.cpe-popup {
    position: relative;
    width: 440px;
    max-width: 100%;
    background: #fff;
    border-radius: 20px;
    box-shadow: var(--cpe-shadow-lg);
    padding: 34px 30px 30px;
    text-align: center;
    transform: translateY(12px) scale(0.96);
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}
.cpe-popup-overlay.cpe-visible .cpe-popup { transform: translateY(0) scale(1); }

.cpe-popup-close {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #9099a5;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s ease, color 0.15s ease;
}
.cpe-popup-close:hover { background: var(--cpe-tint); color: var(--cpe-blue); }

.cpe-popup-icon {
    display: inline-grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: rgba(217, 34, 55, 0.08);
    margin-bottom: 14px;
}
.cpe-popup-icon svg { width: 28px; height: 28px; }

.cpe-popup-heading {
    margin: 0 0 6px;
    font-size: 21px;
    font-weight: 700;
    color: var(--cpe-ink);
}

.cpe-popup-sub {
    margin: 0 auto 20px;
    max-width: 340px;
    font-size: 14px;
    line-height: 1.55;
    color: var(--cpe-muted);
}

.cpe-popup-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cpe-popup-input {
    width: 100%;
    padding: 13px 15px;
    font-size: 15px;
    border: 1px solid #d7d7e2;
    border-radius: 11px;
    background: #fafafc;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    box-sizing: border-box;
}
.cpe-popup-input:focus {
    outline: none;
    border-color: var(--cpe-ink);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(26, 26, 46, 0.09);
}

.cpe-popup-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    padding: 14px 20px;
    margin-top: 2px;
    border: none;
    border-radius: 11px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    letter-spacing: 0.2px;
    transition: transform 0.12s ease, opacity 0.2s ease;
    box-shadow: 0 6px 18px rgba(20, 20, 45, 0.2);
}
.cpe-popup-submit:hover:not(:disabled) { transform: translateY(-1px); background: var(--cpe-blue-dark) !important; box-shadow: 0 6px 18px rgba(21, 101, 216, 0.3); }
.cpe-popup-submit:active { transform: translateY(0); }
.cpe-popup-submit:disabled { opacity: 0.72; cursor: default; }

.cpe-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: cpe-spin 0.7s linear infinite;
}
.cpe-popup-submit.loading .cpe-spinner { display: inline-block; }

.cpe-popup-status {
    margin: 16px 0 0;
    font-size: 14px;
    min-height: 18px;
    line-height: 1.45;
}

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

/* ============================================================
 *  RESPONSIVE
 * ========================================================== */
@media (max-width: 480px) {
    .cpe-nudge-card {
        top: 14px;
        right: 12px;
        left: 12px;
        width: auto;
        max-width: none;
    }
    .cpe-nudge-quiet { top: 14px; right: 14px; }
    .cpe-popup { padding: 30px 22px 26px; border-radius: 18px; }
}

/* ============================================================
 *  REDUCED MOTION
 * ========================================================== */
@media (prefers-reduced-motion: reduce) {
    .cpe-nudge-card,
    .cpe-nudge-quiet,
    .cpe-popup,
    .cpe-popup-overlay,
    .cpe-nudge-backdrop {
        transition-duration: 0.001ms !important;
    }
    .cpe-quiet-pulse { animation: none; }
}
