/*
|--------------------------------------------------------------------------
| Modal Overlay
|--------------------------------------------------------------------------
*/

.cf-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;

    display: flex;
    justify-content: center;
    align-items: center;

    padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
    box-sizing: border-box;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;

    background: rgba(16, 42, 54, 0.8);
    backdrop-filter: blur(4px);

    opacity: 0;
    visibility: hidden;

    transition: opacity .3s ease,
                visibility .3s ease;
}

.cf-modal-overlay.cf-visible {
    opacity: 1;
    visibility: visible;
}

/*
|--------------------------------------------------------------------------
| Prevent Page Scroll
|--------------------------------------------------------------------------
*/

body.cf-modal-open {
    overflow: hidden;
}

/*
|--------------------------------------------------------------------------
| Modal Window
|--------------------------------------------------------------------------
*/

.cf-modal {
    width: min(100%, 580px);
    max-height: calc(100vh - 2rem);
    max-height: calc(100dvh - 2rem);
    min-height: 0;
    margin: auto;
    box-sizing: border-box;

    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;

    background: var(--white, #ffffff);

    border-radius: var(--border-radius, 12px);

    box-shadow: var(--shadow-lg);

    transform: translateY(20px);
    transition: transform .3s ease;
}

.cf-visible .cf-modal {
    transform: translateY(0);
}

/*
|--------------------------------------------------------------------------
| Header
|--------------------------------------------------------------------------
*/

.cf-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 1.25rem 1.5rem;

    background: var(--primary, #102A36);

    color: var(--white, #ffffff);

    border-radius:
        var(--border-radius, 12px)
        var(--border-radius, 12px)
        0
        0;
}

.cf-modal-brand {
    display: flex;
    align-items: center;
    gap: .75rem;

    font-family: var(--font-heading);
    font-weight: 600;
}

.cf-modal-brand img {
    width: 32px;
    height: 32px;

    border-radius: 50%;

    object-fit: cover;
}

/*
|--------------------------------------------------------------------------
| Close Button
|--------------------------------------------------------------------------
*/

.cf-close {
    width: 40px;
    height: 40px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: rgba(255,255,255,.1);
    border: none;

    border-radius: 50%;

    color: #fff;

    font-size: 1.4rem;
    font-weight: 700;

    cursor: pointer;

    transition: var(--transition);
}

.cf-close:hover {
    background: rgba(255,255,255,.2);
    color: var(--accent);
}

/*
|--------------------------------------------------------------------------
| Body
|--------------------------------------------------------------------------
*/

.cf-modal-body {
    padding: 2rem;
    box-sizing: border-box;
}

/*
|--------------------------------------------------------------------------
| Form
|--------------------------------------------------------------------------
*/

.cf-field {
    margin-bottom: 1.25rem;
}

.cf-field label {
    display: block;

    margin-bottom: .35rem;

    font-weight: 600;

    color: var(--primary, #102A36);
}

.cf-field input,
.cf-field select,
.cf-field textarea {
    width: 100%;

    padding: .85rem 1rem;

    border: 1px solid rgba(0,0,0,.12);

    border-radius: var(--border-radius, 12px);

    font-family: var(--font-body);

    font-size: 1rem;

    background: var(--white);

    color: var(--text);

    transition: var(--transition);
}

.cf-field textarea {
    min-height: 120px;
    resize: vertical;
}

.cf-field input:focus,
.cf-field select:focus,
.cf-field textarea:focus {
    outline: none;

    border-color: var(--secondary);

    box-shadow:
        0 0 0 3px rgba(32,191,201,.15);
}

/*
|--------------------------------------------------------------------------
| Submit Button
|--------------------------------------------------------------------------
*/

.cf-modal .btn,
.cf-modal button[type="submit"] {
    width: auto;
    min-width: 220px;
}

/*
|--------------------------------------------------------------------------
| Validation Errors
|--------------------------------------------------------------------------
*/

.cf-errors {
    margin-bottom: 1.5rem;

    padding: 1rem;

    border-left: 4px solid #d63638;

    background: #fff2f2;

    border-radius: 6px;
}

.cf-errors p {
    margin: 0 0 .5rem;
    color: #b42318;
}

.cf-errors p:last-child {
    margin-bottom: 0;
}

/*
|--------------------------------------------------------------------------
| Honeypot
|--------------------------------------------------------------------------
*/

.cf-honeypot {
    position: absolute;
    left: -9999px;
    opacity: 0;
}

/*
|--------------------------------------------------------------------------
| Scrollbar
|--------------------------------------------------------------------------
*/

.cf-modal::-webkit-scrollbar {
    width: 4px;
}

.cf-modal::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,.2);
    border-radius: 100px;
}

/*
|--------------------------------------------------------------------------
| Mobile
|--------------------------------------------------------------------------
*/

@media (max-width: 768px) {

    .cf-modal-overlay {
        align-items: flex-start;
        padding: max(.75rem, env(safe-area-inset-top)) .75rem max(.75rem, env(safe-area-inset-bottom));
    }

    .cf-modal {
        width: 100%;
        max-height: calc(100vh - 1.5rem);
        max-height: calc(100dvh - 1.5rem);
        margin: auto 0;
    }

    .cf-modal-header {
        padding: 1rem;
    }

    .cf-modal-body {
        padding: 1.25rem;
    }

    .cf-modal-brand span {
        font-size: .95rem;
    }
}