/* ── Coupon Applied Popup ─────────────────────────────────── */

/* ── Overlay ─────────────────────────────────────────────── */
#coupon-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999990;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Prevent page scroll from propagating through the overlay on iOS */
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s ease;
}

#coupon-popup-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

/* ── Popup card ──────────────────────────────────────────── */
#coupon-popup {
    position: relative;
    background: #ffffff;
    border-radius: 20px;
    padding: 48px 36px 36px;
    width: min(420px, calc(100vw - 32px));
    /* Prevent popup from overflowing very short viewports (landscape mobile) */
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px); /* dynamic viewport height for mobile browsers */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow:
        0 2px 4px rgba(0,0,0,.04),
        0 8px 24px rgba(0,0,0,.10),
        0 32px 64px rgba(0,0,0,.12);
    text-align: center;
    transform: translateY(24px) scale(0.97);
    transition: transform 0.32s cubic-bezier(0.34, 1.48, 0.64, 1);
    /* Promote to own layer for smooth GPU-composited animation */
    will-change: transform;
    overflow: hidden;
    /* iOS: prevent tap highlight flash on the card itself */
    -webkit-tap-highlight-color: transparent;
}

#coupon-popup-overlay.is-visible #coupon-popup {
    transform: translateY(0) scale(1);
}

/* ── Confetti canvas — sits behind all content ───────────── */
#coupon-confetti-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* ── All content above canvas ────────────────────────────── */
#coupon-popup-close,
#coupon-popup-icon,
#coupon-popup-title,
#coupon-popup-message,
#coupon-popup-cta {
    position: relative;
    z-index: 1;
}

/* ── Close button ────────────────────────────────────────── */
#coupon-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    /*
     * Visual size 32 × 32 px but the touch/click hit-area is 44 × 44 px
     * via negative margin trick — meets Apple HIG & Material Design guidelines.
     */
    width: 32px;
    height: 32px;
    margin: -6px;          /* expands hit area to 44 × 44 without shifting visual position */
    padding: 6px;          /* keeps the visual icon centred within the larger hit area */
    border: none;
    background: #f2f2f5;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    box-sizing: content-box; /* so width/height refer to the inner circle only */
    transition: background 0.15s, color 0.15s;
    z-index: 2;
    /* Suppress iOS tap flash */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

#coupon-popup-close:hover,
#coupon-popup-close:focus-visible {
    background: #e5e5ea;
    color: #111;
    outline: 2px solid #92c72f;
    outline-offset: 2px;
}

#coupon-popup-close svg {
    width: 15px;
    height: 15px;
    /* Prevent SVG from capturing pointer events so the button receives them */
    pointer-events: none;
    display: block;
}

/* ── Icon ────────────────────────────────────────────────── */
#coupon-popup-icon {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    color: #16a34a;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 0 0 8px rgba(22, 163, 74, 0.08);
    /* Emoji sizing (😍) — font-size drives the visible glyph inside the box */
    font-size: 38px;
    line-height: 1;
}

#coupon-popup-icon svg {
    width: 30px;
    height: 30px;
}

/* ── Title ───────────────────────────────────────────────── */
#coupon-popup-title {
    font-family: -apple-system, 'Segoe UI', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: #111;
    margin: 0 0 8px;
    line-height: 1.3;
}

/* ── Message (WC notice text) ────────────────────────────── */
#coupon-popup-message {
    font-family: -apple-system, 'Segoe UI', sans-serif;
    font-size: 0.925rem;
    color: #555;
    margin: 0 0 28px;
    line-height: 1.55;
}

#coupon-popup-message:empty {
    display: none;
}

/* ── CTA button ──────────────────────────────────────────── */
#coupon-popup-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #92c72f;
    color: #fff !important;
    font-family: -apple-system, 'Segoe UI', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    text-decoration: none !important;
    padding: 14px 26px;
    border-radius: 12px;
    transition: background 0.18s, transform 0.18s, box-shadow 0.18s;
    letter-spacing: 0.01em;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    /* Ensure minimum touch target height */
    min-height: 44px;
}

#coupon-popup-cta:hover {
    background: #7db025;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(146, 199, 47, 0.35);
}

#coupon-popup-cta:active {
    transform: translateY(0);
    box-shadow: none;
}

#coupon-popup-cta:focus-visible {
    outline: 2px solid #92c72f;
    outline-offset: 3px;
}

#coupon-popup-cta svg {
    transition: transform 0.18s;
    flex-shrink: 0;
    /* Prevent SVG from blocking button clicks */
    pointer-events: none;
}

#coupon-popup-cta:hover svg {
    transform: translateX(3px);
}

/* ── Mobile — small screens (≤ 480 px) ──────────────────── */
@media (max-width: 480px) {
    #coupon-popup {
        padding: 40px 24px 28px;
        border-radius: 16px;
    }

    #coupon-popup-title {
        font-size: 1.1rem;
    }

    #coupon-popup-icon {
        width: 56px;
        height: 56px;
        font-size: 32px;
    }

    #coupon-popup-icon svg {
        width: 26px;
        height: 26px;
    }

    #coupon-popup-cta {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
    }
}

/* ── Landscape mobile (short viewport) ───────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
    #coupon-popup {
        padding: 32px 28px 24px;
    }

    #coupon-popup-icon {
        width: 48px;
        height: 48px;
        margin-bottom: 12px;
    }

    #coupon-popup-message {
        margin-bottom: 18px;
    }
}

/* ── iOS notch / safe-area support ──────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    #coupon-popup-overlay {
        /* Push overlay content clear of the home-indicator bar */
        padding-bottom: env(safe-area-inset-bottom);
    }
}
