/* ReleaseRun Engagement Popups CSS */
/* Design tokens consistent with Phase 3 newsletter forms */

:root {
    /* Design tokens (extend Phase 3) */
    --rr-cream: #FDFBF7;
    --rr-orange: #FF4500;
    --rr-orange-hover: #E03E00;
    --rr-text: #333333;
    --rr-border: #E5E5E5;
    --rr-font-heading: 'Playfair Display', Georgia, serif;
    --rr-font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Z-index scale for popup layer */
    --rr-popup-backdrop-z: 1040;
    --rr-popup-z: 1050;
}

/* =====================================================
   BACKDROP
   ===================================================== */
.rr-popup-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--rr-popup-backdrop-z);
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.rr-popup-backdrop--visible {
    display: flex;
    opacity: 1;
}

/* =====================================================
   MODAL CONTAINER
   ===================================================== */
.rr-popup {
    position: relative;
    background: var(--rr-cream);
    border-radius: 12px;
    padding: 2rem;
    max-width: 480px;
    width: 90%;
    z-index: var(--rr-popup-z);
    transform: scale(0.95);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.rr-popup--visible {
    transform: scale(1);
    opacity: 1;
}

/* =====================================================
   CLOSE BUTTON
   ===================================================== */
.rr-popup__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #999;
    cursor: pointer;
    padding: 0.25rem;
    transition: color 0.2s ease;
}

.rr-popup__close:hover {
    color: var(--rr-text);
}

.rr-popup__close:focus {
    outline: 2px solid var(--rr-orange);
    outline-offset: 2px;
}

/* =====================================================
   TITLE & DESCRIPTION
   ===================================================== */
.rr-popup__title {
    font-family: var(--rr-font-heading);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--rr-text);
    margin: 0 0 0.5rem;
    padding-right: 2rem; /* Space for close button */
}

.rr-popup__description {
    font-family: var(--rr-font-body);
    font-size: 1rem;
    color: #666;
    margin: 0 0 1.5rem;
    line-height: 1.5;
}

/* =====================================================
   FORM
   ===================================================== */
.rr-popup__form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.rr-popup__input {
    padding: 0.75rem 1rem;
    border: 1px solid var(--rr-border);
    border-radius: 4px;
    font-family: var(--rr-font-body);
    font-size: 1rem;
    color: var(--rr-text);
    background: white;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.rr-popup__input:focus {
    outline: none;
    border-color: var(--rr-orange);
    box-shadow: 0 0 0 3px rgba(255, 69, 0, 0.1);
}

.rr-popup__input::placeholder {
    color: #999;
}

/* =====================================================
   SUBMIT BUTTON
   ===================================================== */
.rr-popup__submit {
    background: var(--rr-orange);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.75rem 1.5rem;
    font-family: var(--rr-font-body);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background-color 0.2s ease;
}

.rr-popup__submit:hover {
    background: var(--rr-orange-hover);
}

.rr-popup__submit:focus {
    outline: 2px solid var(--rr-orange);
    outline-offset: 2px;
}

.rr-popup__submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Loading state */
.rr-popup__submit-text {
    transition: opacity 0.2s ease;
}

.rr-popup__spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: rr-popup-spin 0.8s linear infinite;
}

.rr-popup__form--loading .rr-popup__submit-text {
    opacity: 0.7;
}

.rr-popup__form--loading .rr-popup__spinner {
    display: block;
}

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

/* =====================================================
   DISMISS BUTTON
   ===================================================== */
.rr-popup__dismiss {
    background: transparent;
    border: none;
    color: #666;
    font-family: var(--rr-font-body);
    font-size: 0.9rem;
    cursor: pointer;
    margin-top: 0.5rem;
    padding: 0.5rem;
    text-align: center;
    width: 100%;
    transition: color 0.2s ease, text-decoration 0.2s ease;
}

.rr-popup__dismiss:hover {
    color: var(--rr-text);
    text-decoration: underline;
}

.rr-popup__dismiss:focus {
    outline: 2px solid var(--rr-orange);
    outline-offset: 2px;
}

/* =====================================================
   IOS BODY SCROLL PREVENTION
   ===================================================== */
.rr-body-scroll-locked {
    overflow: hidden;
    position: fixed;
    width: 100%;
    /* JS sets top position to preserve scroll position */
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 480px) {
    .rr-popup {
        padding: 1.5rem;
        width: 95%;
        max-width: none;
        margin: 1rem;
    }

    .rr-popup__title {
        font-size: 1.5rem;
    }

    .rr-popup__description {
        font-size: 0.95rem;
    }

    .rr-popup__close {
        top: 0.75rem;
        right: 0.75rem;
    }
}

/* =====================================================
   SUCCESS STATE
   ===================================================== */
.rr-popup__success {
    display: none;
    text-align: center;
    padding: 1rem 0;
}

.rr-popup__success--visible {
    display: block;
}

.rr-popup__success-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.rr-popup__success-title {
    font-family: var(--rr-font-heading);
    font-size: 1.5rem;
    color: var(--rr-text);
    margin: 0 0 0.5rem;
}

.rr-popup__success-message {
    font-family: var(--rr-font-body);
    color: #666;
    margin: 0;
}

/* Hide form when success is visible */
.rr-popup--success .rr-popup__form,
.rr-popup--success .rr-popup__title,
.rr-popup--success .rr-popup__description,
.rr-popup--success .rr-popup__dismiss {
    display: none;
}

.rr-popup--success .rr-popup__success {
    display: block;
}
