/* HDM Exit-Intent Survey
   Self-contained, scoped under .hdm-exit-survey to avoid theme bleed.
   Brand: primary #3367EF, accent #3FB450, neutrals 0/696969/E1E1E1, font Sen. */

.hdm-exit-survey {
    --hdm-es-primary: #3367EF;
    --hdm-es-primary-dark: #2552d4;
    --hdm-es-primary-soft: rgba(51, 103, 239, 0.08);
    --hdm-es-accent: #3FB450;
    --hdm-es-ink: #0B1220;
    --hdm-es-muted: #5B5B5B;
    --hdm-es-soft: #696969;
    --hdm-es-line: #E5E7EB;
    --hdm-es-line-strong: #D1D5DB;
    --hdm-es-bg: #FFFFFF;
    --hdm-es-radius: 18px;
    --hdm-es-radius-sm: 12px;
    --hdm-es-shadow: 0 30px 80px rgba(11, 18, 32, 0.32), 0 8px 24px rgba(11, 18, 32, 0.12);
    --hdm-es-font: 'Sen', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    position: fixed;
    inset: 0;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    font-family: var(--hdm-es-font);
    color: var(--hdm-es-ink);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.hdm-exit-survey.is-open {
    display: flex;
}

.hdm-exit-survey__backdrop {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 30%, rgba(11, 18, 32, 0.55), rgba(11, 18, 32, 0.78));
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 240ms ease;
    /* now a real <button> spanning the overlay so click-to-close is reliable */
    border: 0;
    padding: 0;
    margin: 0;
    cursor: pointer;
    appearance: none;
}

.hdm-exit-survey__backdrop:focus-visible {
    outline: none;
}

/* Wrapper that holds the close button (above) + the panel (below).
   Sits above the backdrop so the close button receives clicks first. */
.hdm-exit-survey__shell {
    position: relative;
    width: 100%;
    max-width: 540px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    pointer-events: none; /* let clicks pass through gaps to the backdrop */
}

.hdm-exit-survey__shell > * {
    pointer-events: auto; /* re-enable inside actual children */
}

.hdm-exit-survey.is-open .hdm-exit-survey__backdrop {
    opacity: 1;
}

.hdm-exit-survey__panel {
    position: relative;
    width: 100%;
    background: var(--hdm-es-bg);
    border-radius: var(--hdm-es-radius);
    box-shadow: var(--hdm-es-shadow);
    overflow: hidden;
    transform: translateY(18px) scale(0.97);
    opacity: 0;
    transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1), opacity 240ms ease;
    max-height: calc(100vh - 100px); /* leave room above for close button + visible overlay */
    display: flex;
    flex-direction: column;
}

.hdm-exit-survey.is-open .hdm-exit-survey__panel {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Close button — sits OUTSIDE the panel, over the dark overlay,
   so it's unmistakable. Larger and high-contrast for older audiences. */
.hdm-exit-survey__close {
    align-self: flex-end;
    margin-bottom: 14px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 0;
    background: #fff;
    color: var(--hdm-es-ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.30), 0 2px 6px rgba(0, 0, 0, 0.18);
    z-index: 3;
    flex-shrink: 0;
}

.hdm-exit-survey__close:hover,
.hdm-exit-survey__close:focus-visible {
    transform: scale(1.08) rotate(90deg);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.36), 0 3px 10px rgba(0, 0, 0, 0.22);
    outline: none;
    background: #fff;
}

.hdm-exit-survey__close:active {
    transform: scale(0.96) rotate(90deg);
}

.hdm-exit-survey__steps {
    position: relative;
    overflow-y: auto;
}

.hdm-exit-survey__step {
    display: none;
    padding: 36px 36px 28px;
    animation: hdmExitSurveyFade 320ms ease both;
}

.hdm-exit-survey__step.is-active {
    display: block;
}

@keyframes hdmExitSurveyFade {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.hdm-exit-survey__eyebrow {
    display: inline-block;
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--hdm-es-primary);
    background: var(--hdm-es-primary-soft);
    padding: 6px 10px;
    border-radius: 999px;
    margin-bottom: 14px;
}

.hdm-exit-survey__title {
    margin: 0 0 8px;
    font-size: 26px;
    line-height: 1.2;
    font-weight: 800;
    color: var(--hdm-es-ink);
    letter-spacing: -0.01em;
}

.hdm-exit-survey__lede {
    margin: 0 0 22px;
    font-size: 15px;
    line-height: 1.5;
    color: var(--hdm-es-muted);
}

/* ---------------------- Reason cards ---------------------- */

.hdm-exit-survey__reasons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 6px;
}

.hdm-exit-survey__reason {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    text-align: left;
    padding: 14px 14px 14px 14px;
    border: 1.5px solid var(--hdm-es-line);
    background: #fff;
    border-radius: var(--hdm-es-radius-sm);
    cursor: pointer;
    font-family: inherit;
    color: var(--hdm-es-ink);
    transition: border-color 160ms ease, background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
    min-height: 68px;
}

.hdm-exit-survey__reason:hover {
    border-color: var(--hdm-es-line-strong);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(11, 18, 32, 0.06);
}

.hdm-exit-survey__reason:focus-visible {
    outline: none;
    border-color: var(--hdm-es-primary);
    box-shadow: 0 0 0 3px rgba(51, 103, 239, 0.18);
}

.hdm-exit-survey__reason.is-selected {
    border-color: var(--hdm-es-primary);
    background: var(--hdm-es-primary-soft);
}

.hdm-exit-survey__reason.is-selected .hdm-exit-survey__reason-icon {
    color: var(--hdm-es-primary);
}

.hdm-exit-survey__reason--full {
    grid-column: 1 / -1;
}

.hdm-exit-survey__reason-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--hdm-es-primary-soft);
    color: var(--hdm-es-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.hdm-exit-survey__reason-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.hdm-exit-survey__reason-title {
    font-size: 14.5px;
    font-weight: 700;
    line-height: 1.3;
}

.hdm-exit-survey__reason-sub {
    font-size: 12.5px;
    color: var(--hdm-es-soft);
    line-height: 1.35;
}

/* ---------------------- "Other" textarea ---------------------- */

.hdm-exit-survey__other-wrap {
    margin-top: 14px;
    animation: hdmExitSurveyFade 240ms ease both;
}

.hdm-exit-survey__label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--hdm-es-ink);
    margin-bottom: 6px;
}

.hdm-exit-survey__textarea,
.hdm-exit-survey__input {
    width: 100%;
    border: 1.5px solid var(--hdm-es-line);
    border-radius: var(--hdm-es-radius-sm);
    padding: 12px 14px;
    font: inherit;
    font-size: 15px;
    color: var(--hdm-es-ink);
    background: #fff;
    transition: border-color 160ms ease, box-shadow 160ms ease;
    resize: vertical;
    box-sizing: border-box;
}

.hdm-exit-survey__textarea:focus,
.hdm-exit-survey__input:focus {
    outline: none;
    border-color: var(--hdm-es-primary);
    box-shadow: 0 0 0 3px rgba(51, 103, 239, 0.16);
}

.hdm-exit-survey__textarea::placeholder,
.hdm-exit-survey__input::placeholder {
    color: #9CA3AF;
}

/* ---------------------- Contact (step 2) ---------------------- */

.hdm-exit-survey__contact {
    position: relative;
}

.hdm-exit-survey__tabs {
    display: inline-flex;
    background: #F3F4F6;
    border-radius: 999px;
    padding: 4px;
    margin-bottom: 14px;
}

.hdm-exit-survey__tab {
    border: 0;
    background: transparent;
    color: var(--hdm-es-soft);
    font: inherit;
    font-size: 13.5px;
    font-weight: 700;
    padding: 8px 16px;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.hdm-exit-survey__tab.is-active {
    background: #fff;
    color: var(--hdm-es-ink);
    box-shadow: 0 1px 3px rgba(11, 18, 32, 0.10), 0 0 0 1px rgba(11, 18, 32, 0.04);
}

.hdm-exit-survey__tab:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(51, 103, 239, 0.22);
}

.hdm-exit-survey__field {
    position: relative;
}

.hdm-exit-survey__error {
    display: block;
    margin-top: 8px;
    font-size: 13px;
    color: #DC2626;
    font-weight: 600;
}

.hdm-exit-survey__fineprint {
    margin: 12px 0 0;
    font-size: 12.5px;
    color: var(--hdm-es-soft);
    line-height: 1.5;
}

/* ---------------------- Footer / buttons ---------------------- */

.hdm-exit-survey__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--hdm-es-line);
}

.hdm-exit-survey__footer--centered {
    justify-content: center;
    border-top: 0;
}

/* Prominent secondary "skip / close" button — bordered, easy to read. */
.hdm-exit-survey__skip {
    border: 1.5px solid var(--hdm-es-line-strong);
    background: #fff;
    color: var(--hdm-es-ink);
    font: inherit;
    font-size: 14.5px;
    font-weight: 700;
    padding: 11px 18px;
    border-radius: var(--hdm-es-radius-sm);
    cursor: pointer;
    transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 120ms ease;
}

.hdm-exit-survey__skip:hover {
    background: #F3F4F6;
    border-color: #9CA3AF;
    color: var(--hdm-es-ink);
    text-decoration: none;
}

.hdm-exit-survey__skip:focus-visible {
    outline: none;
    border-color: var(--hdm-es-primary);
    box-shadow: 0 0 0 3px rgba(51, 103, 239, 0.18);
}

.hdm-exit-survey__skip:active {
    transform: translateY(1px);
}

.hdm-exit-survey__primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 0;
    background: var(--hdm-es-primary);
    color: #fff;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    padding: 12px 22px;
    border-radius: var(--hdm-es-radius-sm);
    cursor: pointer;
    transition: background 160ms ease, transform 120ms ease, box-shadow 160ms ease;
    box-shadow: 0 6px 16px rgba(51, 103, 239, 0.28);
}

.hdm-exit-survey__primary:hover:not([disabled]) {
    background: var(--hdm-es-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(51, 103, 239, 0.34);
}

.hdm-exit-survey__primary:active:not([disabled]) {
    transform: translateY(0);
}

.hdm-exit-survey__primary[disabled] {
    background: #B7C3E5;
    box-shadow: none;
    cursor: not-allowed;
}

.hdm-exit-survey__primary.is-loading {
    color: transparent;
    pointer-events: none;
    position: relative;
}

.hdm-exit-survey__primary.is-loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    animation: hdmExitSurveySpin 700ms linear infinite;
}

@keyframes hdmExitSurveySpin {
    to { transform: rotate(360deg); }
}

/* ---------------------- Thank-you step ---------------------- */

.hdm-exit-survey__step--thanks {
    text-align: center;
    padding: 44px 36px 32px;
}

.hdm-exit-survey__check {
    color: var(--hdm-es-accent);
    margin: 0 auto 14px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(63, 180, 80, 0.10);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    animation: hdmExitSurveyPop 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes hdmExitSurveyPop {
    0%   { transform: scale(0.6); opacity: 0; }
    60%  { transform: scale(1.06); opacity: 1; }
    100% { transform: scale(1); }
}

.hdm-exit-survey__step--thanks .hdm-exit-survey__title {
    font-size: 22px;
}

/* Body lock when modal open */

body.hdm-exit-survey-locked {
    overflow: hidden !important;
}

/* ---------------------- Responsive ---------------------- */

@media (max-width: 600px) {
    /* Center the modal with visible black overlay on every side
       so the surrounding dark area is obviously tappable to close. */
    .hdm-exit-survey {
        padding: 16px;
        align-items: center;
    }

    .hdm-exit-survey__shell {
        max-width: 100%;
        /* keep panel comfortably inset: 56px above for the close button,
           plus padding above & below — total ~120px reserved off the viewport. */
        max-height: calc(100vh - 32px);
    }

    .hdm-exit-survey__close {
        width: 44px;
        height: 44px;
        margin-bottom: 12px;
    }

    .hdm-exit-survey__panel {
        max-width: 100%;
        border-radius: var(--hdm-es-radius);
        /* room for: parent 16px padding × 2 + close button 44px + 12px gap = ~88px */
        max-height: calc(100vh - 100px);
        transform: translateY(20px) scale(0.97);
    }

    .hdm-exit-survey__step {
        padding: 24px 20px 18px;
    }

    .hdm-exit-survey__step--thanks {
        padding: 32px 20px 24px;
    }

    .hdm-exit-survey__title {
        font-size: 21px;
    }

    .hdm-exit-survey__lede {
        font-size: 14.5px;
        margin-bottom: 18px;
    }

    .hdm-exit-survey__reasons {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .hdm-exit-survey__reason {
        min-height: auto;
        padding: 12px;
    }

    .hdm-exit-survey__footer {
        flex-direction: row;
        gap: 10px;
        margin-top: 18px;
        padding-top: 14px;
    }

    .hdm-exit-survey__skip,
    .hdm-exit-survey__primary {
        flex: 1 1 auto;
        padding: 11px 14px;
        font-size: 14.5px;
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hdm-exit-survey,
    .hdm-exit-survey__backdrop,
    .hdm-exit-survey__panel,
    .hdm-exit-survey__step,
    .hdm-exit-survey__primary,
    .hdm-exit-survey__close,
    .hdm-exit-survey__check {
        transition: none !important;
        animation: none !important;
    }
}
