/*
 * Exit-Intent Demo Popup
 * -----------------------------------------------------------------------------
 * Modal that embeds the Google Calendar appointment scheduler. Shown when a
 * visitor switches tabs or tries to leave the site.
 *
 * Responsive strategy
 * -----------------------------------------------------------------------------
 *  - Uses `dvh` (dynamic viewport height) with `vh` fallback so iOS Safari's
 *    collapsing browser chrome doesn't clip the modal.
 *  - Fluid typography via `clamp()` — scales smoothly between 320 px and
 *    1440 px without stair-stepping at breakpoints.
 *  - iOS safe-area insets respected on notched devices.
 *  - Touch targets are >= 44 × 44 px on all viewports (WCAG 2.5.5 / Apple HIG).
 *  - Dedicated short-viewport rule handles landscape phones (< 500 px tall).
 */

.wk-exit-intent-popup[hidden] {
    display: none !important;
}

.wk-exit-intent-popup {
    position: fixed;
    inset: 0;
    z-index: 999998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
             max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    color-scheme: light;
    -webkit-text-size-adjust: 100%;
            text-size-adjust: 100%;
}

.wk-exit-intent-popup.is-active {
    opacity: 1;
    visibility: visible;
}

.wk-exit-intent-popup__backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.75);
    -webkit-backdrop-filter: blur(2px);
            backdrop-filter: blur(2px);
}

.wk-exit-intent-popup__dialog {
    position: relative;
    background: #ffffff;
    border-radius: 8px;
    width: 100%;
    max-width: 1100px;
    /* dvh keeps the modal inside the visible viewport on iOS even when the
       address bar slides away; the plain vh value is the fallback. */
    height: 90vh;
    height: 90dvh;
    max-height: 800px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior: contain;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3);
    padding: clamp(20px, 2.5vw, 32px);
    transform: translateY(20px);
    transition: transform 0.3s ease;
    outline: none;
}

.wk-exit-intent-popup.is-active .wk-exit-intent-popup__dialog {
    transform: translateY(0);
}

.wk-exit-intent-popup__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    border: none;
    background: #f1f1f1;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    font-weight: 700;
    color: #333333;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    transition: background-color 0.2s ease;
    z-index: 10;
    -webkit-tap-highlight-color: transparent;
}

.wk-exit-intent-popup__close:hover,
.wk-exit-intent-popup__close:focus-visible {
    background: #e0e0e0;
    outline: none;
}

.wk-exit-intent-popup__close:focus-visible {
    box-shadow: 0 0 0 3px rgba(108, 43, 217, 0.35);
}

.wk-exit-intent-popup__header {
    text-align: center;
    /* Reserve horizontal room so the close button never overlaps long titles. */
    padding-inline: 56px;
    margin-bottom: clamp(12px, 2vw, 24px);
    flex-shrink: 0;
}

.wk-exit-intent-popup__title {
    margin: 0 0 6px;
    font-size: clamp(20px, 1.25rem + 1vw, 28px);
    font-weight: 600;
    color: #333333;
    line-height: 1.25;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.wk-exit-intent-popup__subtitle {
    margin: 0;
    font-size: clamp(14px, 0.875rem + 0.4vw, 18px);
    color: #666666;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.wk-exit-intent-popup__body {
    flex: 1 1 auto;
    position: relative;
    width: 100%;
    overflow: hidden;
    display: flex;
    /* Guarantee a usable iframe height even when the viewport is short;
       falls back to flex sizing on normal screens. */
    min-height: 320px;
}

.wk-exit-intent-popup__scheduler {
    position: relative;
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
}

.wk-exit-intent-popup__scheduler iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: #ffffff;
}

.wk-exit-intent-popup__loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 5;
    pointer-events: none;
}

.wk-exit-intent-popup__spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 15px;
    border: 4px solid rgba(0, 123, 255, 0.3);
    border-radius: 50%;
    border-top-color: #007bff;
    animation: wk-exit-intent-spin 1s ease-in-out infinite;
}

.wk-exit-intent-popup__loader-text {
    color: #666666;
    font-size: 14px;
    font-weight: 500;
}

.wk-exit-intent-popup__scheduler.is-loaded .wk-exit-intent-popup__loader {
    display: none;
}

@keyframes wk-exit-intent-spin {
    to { transform: rotate(360deg); }
}

body.wk-exit-intent-open {
    overflow: hidden;
}

/* -----------------------------------------------------------------------------
 * Tablet (≤ 992 px)
 * Slightly taller dialog, tighter padding, no hard cap on height.
 * -------------------------------------------------------------------------- */
@media (max-width: 992px) {
    .wk-exit-intent-popup {
        padding: 16px;
        padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
                 max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    }
    .wk-exit-intent-popup__dialog {
        height: 95vh;
        height: 95dvh;
        max-height: none;
    }
}

/* -----------------------------------------------------------------------------
 * Mobile portrait (≤ 576 px)
 * Full-screen modal so the scheduler iframe gets every available pixel.
 * -------------------------------------------------------------------------- */
@media (max-width: 576px) {
    .wk-exit-intent-popup {
        /* Drop all outer padding on mobile so the dialog truly fills the
           screen, but still respect notch / home-bar safe areas. */
        padding: env(safe-area-inset-top) env(safe-area-inset-right)
                 env(safe-area-inset-bottom) env(safe-area-inset-left);
    }
    .wk-exit-intent-popup__dialog {
        width: 100%;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
        padding: 16px 14px 14px;
    }
    .wk-exit-intent-popup__header {
        padding-inline: 48px;
        margin-bottom: 10px;
    }
    .wk-exit-intent-popup__title {
        margin-bottom: 2px;
    }
    .wk-exit-intent-popup__close {
        top: 8px;
        right: 8px;
    }
    .wk-exit-intent-popup__body {
        min-height: 280px;
    }
}

/* -----------------------------------------------------------------------------
 * Landscape phones / very short viewports (≤ 500 px tall)
 * Hide the subtitle and shrink the header so the iframe stays usable.
 * -------------------------------------------------------------------------- */
@media (max-height: 500px) {
    .wk-exit-intent-popup__dialog {
        padding: 12px;
    }
    .wk-exit-intent-popup__header {
        margin-bottom: 8px;
        padding-inline: 48px;
    }
    .wk-exit-intent-popup__title {
        font-size: 16px;
        margin-bottom: 0;
    }
    .wk-exit-intent-popup__subtitle {
        display: none;
    }
    .wk-exit-intent-popup__body {
        min-height: 0;
    }
}

/* -----------------------------------------------------------------------------
 * High-density / large desktop — lean into the extra space.
 * -------------------------------------------------------------------------- */
@media (min-width: 1440px) {
    .wk-exit-intent-popup__dialog {
        max-height: 860px;
    }
}

/* -----------------------------------------------------------------------------
 * Accessibility / user preferences
 * -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .wk-exit-intent-popup,
    .wk-exit-intent-popup__dialog {
        transition: none !important;
    }
    .wk-exit-intent-popup__dialog {
        transform: none !important;
    }
    .wk-exit-intent-popup__spinner {
        animation: none !important;
    }
}
