/*
 * Phase 13 Plan 13-05 — Contact Exchange UI styles.
 * External CSS (not inline) — required for honeypot bot-evasion (Pitfall 3).
 *
 * Patterns: Sticky CTA mobile + Inline CTA desktop + Modal/Bottom-sheet + Honeypot.
 */

/* ========== Honeypot — invisible to humans, present to bots (Pitfall 3) ========== */
.ce-honeypot {
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ========== CTA — desktop centered inline (>=992px) ========== */
.contact-exchange-cta {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100%;
    margin: 16px auto 0 auto;
    padding: 0;
}
.ce-cta-close {
    display: none !important;
}
.ce-cta-button {
    display: block !important;
    width: 100% !important;
    max-width: 280px;
    min-height: 44px;
    text-align: center !important;
    padding: 10px 16px !important;
    font-weight: 500;
}

@media (max-width: 991px) {
    /* Mobile sticky-bottom — Pattern 1 */
    .contact-exchange-cta {
        position: fixed !important;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100% !important;
        margin: 0 !important;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom)) 16px !important;
        background: var(--bs-body-bg, #ffffff);
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
        z-index: 1030;
    }
    .contact-exchange-cta.ce-cta-hidden {
        display: none !important;
    }
    .ce-cta-button {
        width: 100% !important;
        max-width: none !important;
        text-align: center !important;
    }
    /* Body offset — prevents CTA covering content */
    body.has-contact-exchange-cta {
        padding-bottom: calc(80px + env(safe-area-inset-bottom));
    }
}

/* ========== Modal / Bottom Sheet ========== */
.ce-modal {
    position: fixed;
    inset: 0;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1050;
    display: none;
}
.ce-modal.is-open {
    display: block;
}
.ce-modal__backdrop {
    position: absolute;
    inset: 0;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}
.ce-modal__sheet {
    position: absolute;
    background: var(--bs-body-bg, #ffffff);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.ce-modal__handle {
    width: 36px;
    height: 4px;
    background: var(--bs-gray-300, #dee2e6);
    border-radius: 2px;
    margin: 8px auto 12px auto;
}
.ce-modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: 0;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    color: var(--bs-text-muted, #6c757d);
    cursor: pointer;
    z-index: 1;
}
.ce-modal__content {
    padding: 24px 20px;
}
.ce-modal__title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 8px 0;
    line-height: 1.25;
}
.ce-modal__subtitle {
    font-size: 0.9375rem;
    margin: 0 0 24px 0;
}

/* Mobile bottom-sheet (max-width 991px) */
@media (max-width: 991px) {
    .ce-modal__sheet {
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 90vh;  /* iOS <15.4 fallback */
        max-height: 90dvh; /* iOS 15.4+, Chrome 108+ — adapts to chrome */
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
        transition: transform 0.3s ease-out;
    }
    .ce-modal.is-open .ce-modal__sheet {
        transform: translateY(0);
    }
}

/* Desktop centered modal (min-width 992px) */
@media (min-width: 992px) {
    .ce-modal__sheet {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        max-width: 440px;
        width: 90%;
        max-height: 90vh;
        border-radius: 8px;
        transition: opacity 0.2s ease-out;
    }
    .ce-modal {
        opacity: 0;
        transition: opacity 0.2s ease-out;
    }
    .ce-modal.is-open {
        opacity: 1;
    }
    .ce-modal__handle {
        display: none;
    }
}

/* ========== Success state (replaces form innerHTML on AJAX success) ========== */
.ce-success {
    text-align: center;
    padding: 48px 24px;
}
.ce-success__icon {
    font-size: 48px;
    color: var(--bs-primary, #007bff);
    margin-bottom: 16px;
}
.ce-success__heading {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0 0 16px 0;
    line-height: 1.2;
}
.ce-success__body {
    color: var(--bs-text-muted, #6c757d);
    max-width: 320px;
    margin: 0 auto 24px auto;
    line-height: 1.5;
}

/* ========== Error friendly alert inside form ========== */
.ce-form__error-banner {
    margin-bottom: 16px;
}
