/**
 * Pop-up CTA Component
 * Used on blog post pages for engagement-triggered lead capture.
 * Loaded only on pages that include components/popup_cta.html.
 *
 * Uses local amber-on-ink palette consistent with blog-editorial.css.
 * Strict color-token rule disabled here.
 */
/* stylelint-disable scale-unlimited/declaration-strict-value */

.popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgb(15 23 42 / 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: popupOverlayFadeIn 0.25s ease-out;
}

.popup-overlay[hidden] {
    display: none;
}

@keyframes popupOverlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.popup-card {
    position: relative;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgb(0 0 0 / 0.35);
    width: 100%;
    max-width: 480px;
    padding: 2.25rem 2rem;
    animation: popupCardSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 95vh;
    overflow-y: auto;
}

@keyframes popupCardSlideUp {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.popup-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.popup-close:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.popup-close:focus-visible {
    outline: 2px solid #d97706;
    outline-offset: 2px;
}

.popup-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.popup-header h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.75rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 0.5rem;
    line-height: 1.2;
}

.popup-subtitle {
    color: #475569;
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0;
}

.popup-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.popup-form input[type="text"],
.popup-form input[type="email"],
.popup-form input[type="tel"] {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: #ffffff;
    box-sizing: border-box;
}

.popup-form input:focus {
    outline: none;
    border-color: #d97706;
    box-shadow: 0 0 0 3px rgb(217 119 6 / 0.15);
}

.popup-form input:invalid:not(:placeholder-shown) {
    border-color: #dc2626;
}

.popup-submit {
    background: #d97706;
    color: #ffffff;
    font-size: 1.05rem;
    font-weight: 600;
    padding: 1rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, transform 0.05s;
    margin-top: 0.25rem;
}

.popup-submit:hover {
    background: #b45309;
}

.popup-submit:active {
    transform: scale(0.98);
}

.popup-submit:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

.popup-trust {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: #64748b;
    text-align: center;
    border-top: 1px solid #e2e8f0;
    padding-top: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.popup-trust span {
    flex: 1;
    min-width: 0;
}

.popup-success {
    text-align: center;
    padding: 1rem 0;
}

.popup-success[hidden] {
    display: none;
}

.popup-success-icon {
    width: 64px;
    height: 64px;
    background: #16a34a;
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 1rem;
}

.popup-success h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.75rem;
    color: #0f172a;
    margin: 0 0 0.5rem;
}

.popup-success p {
    color: #475569;
    margin: 0;
}

.popup-error {
    background: #fef2f2;
    color: #991b1b;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    border: 1px solid #fecaca;
    margin-bottom: 0.5rem;
}

.popup-error[hidden] {
    display: none;
}

/* Mobile adjustments */
@media (max-width: 540px) {
    .popup-card {
        padding: 1.75rem 1.25rem;
        max-width: 100%;
    }

    .popup-header h3 {
        font-size: 1.5rem;
    }

    .popup-subtitle {
        font-size: 0.9rem;
    }

    .popup-trust {
        font-size: 0.75rem;
    }

    .popup-trust span {
        flex-basis: 100%;
        text-align: center;
    }
}

/* Honor reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .popup-overlay,
    .popup-card {
        animation: none;
    }
}

/* Body scroll lock when popup is open */
body.popup-open {
    overflow: hidden;
}
