/* ============================================================
   ENCOMPASS GROUP — ASSESSMENT POPUP
   Self-contained. Remove the <link> to this file to disable.
   Uses the site's own theme variables, so it follows the
   light/dark toggle automatically.
   ============================================================ */

.egap-overlay {
    --egap-surface: var(--bg-surface, #1a1a3e);
    --egap-ink: var(--text-main, #f0ede8);
    --egap-muted: var(--text-muted, rgba(240, 237, 232, 0.72));
    --egap-gold: var(--accent-gold, #d4af37);
    --egap-gold-soft: var(--accent-gold-dim, rgba(212, 175, 55, 0.12));
    --egap-gold-line: var(--accent-gold-border, rgba(212, 175, 55, 0.3));
    --egap-rule: rgba(255, 255, 255, 0.09);
    --egap-hover: rgba(255, 255, 255, 0.045);
    --egap-scrim: rgba(5, 6, 20, 0.62);
    --egap-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.3);
    --egap-needle-south: #8fa3c4;
    --egap-ease: cubic-bezier(0.16, 1, 0.3, 1);

    position: fixed;
    inset: 0;
    z-index: 10050; /* above Atlas (10001–10002) and the preferences banner */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--egap-scrim);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s var(--egap-ease), visibility 0s linear 0.5s;
}

[data-theme="light"] .egap-overlay {
    --egap-rule: rgba(0, 73, 144, 0.11);
    --egap-hover: rgba(0, 73, 144, 0.035);
    --egap-scrim: rgba(0, 32, 66, 0.3);
    --egap-shadow: 0 30px 80px rgba(0, 38, 77, 0.22), 0 2px 6px rgba(0, 38, 77, 0.08);
    --egap-needle-south: #9fb3cb;
}

.egap-overlay.is-open {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.5s var(--egap-ease), visibility 0s;
}

/* While the card is open, quiet the other floating elements so nothing stacks up */
body.egap-active .atlas-widget,
body.egap-active #global-preference-banner {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.3s ease !important;
}

/* ---------- The card ---------- */
.egap-card {
    position: relative;
    width: min(468px, 100%);
    max-height: min(88vh, 720px);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--egap-surface);
    color: var(--egap-ink);
    border: 1px solid var(--egap-gold-line);
    border-radius: 18px;
    box-shadow: var(--egap-shadow);
    padding: 30px 28px 18px;
    font-family: var(--font-sans, 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif);
    transform: translateY(18px) scale(0.985);
    opacity: 0;
    transition: transform 0.7s var(--egap-ease), opacity 0.5s var(--egap-ease);
    scrollbar-width: thin;
}
.egap-card:focus { outline: none; }

/* Fine inner rule, like a printed correspondence card */
.egap-card::before {
    content: "";
    position: absolute;
    inset: 7px;
    border: 1px solid var(--egap-gold-soft);
    border-radius: 12px;
    pointer-events: none;
}

.egap-overlay.is-open .egap-card {
    transform: none;
    opacity: 1;
}

.egap-handle { display: none; }

/* ---------- Close ---------- */
.egap-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--egap-muted);
    cursor: pointer;
    transition: background-color 0.25s ease, color 0.25s ease, transform 0.4s var(--egap-ease);
    z-index: 2;
}
.egap-close:hover { background: var(--egap-hover); color: var(--egap-ink); transform: rotate(90deg); }
.egap-close svg { width: 18px; height: 18px; }

/* ---------- Header ---------- */
.egap-head {
    text-align: center;
    padding: 0 12px 18px;
}

.egap-compass {
    display: block;
    width: 50px;
    height: 50px;
    margin: 0 auto 12px;
    overflow: visible;
}
.egap-ring {
    fill: none;
    stroke: var(--egap-gold);
    stroke-width: 1.2;
    stroke-dasharray: 164;
    stroke-dashoffset: 0;
}
.egap-ticks { stroke: var(--egap-gold); stroke-width: 1.2; stroke-linecap: round; }
.egap-needle { transform-origin: 30px 30px; transform-box: view-box; }
.egap-needle-n { fill: var(--egap-gold); }
.egap-needle-s { fill: var(--egap-needle-south); }
.egap-pin { fill: var(--egap-surface); stroke: var(--egap-gold); stroke-width: 1.2; }

.egap-title {
    margin: 0;
    font-family: var(--font-serif, 'Cormorant Garamond', Georgia, serif);
    font-weight: 500;
    font-size: 31px;
    line-height: 1.08;
    letter-spacing: -0.005em;
    color: var(--egap-ink);
}
.egap-title span { display: block; }

.egap-sub {
    margin: 10px 0 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--egap-muted);
}

/* ---------- Options ---------- */
.egap-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--egap-rule);
}
.egap-list li { border-bottom: 1px solid var(--egap-rule); }

.egap-option {
    position: relative;
    display: grid;
    grid-template-columns: 42px 1fr 18px;
    gap: 14px;
    align-items: start;
    padding: 14px 10px 14px 12px;
    margin: 0 -10px;
    border-radius: 10px;
    color: inherit;
    text-decoration: none;
    transition: background-color 0.3s ease;
}
.egap-option::before {
    content: "";
    position: absolute;
    left: 0;
    top: 18px;
    bottom: 18px;
    width: 2px;
    border-radius: 2px;
    background: var(--egap-gold);
    transform: scaleY(0);
    transition: transform 0.45s var(--egap-ease);
}
.egap-option:hover,
.egap-option:focus-visible { background: var(--egap-hover); }
.egap-option:hover::before,
.egap-option:focus-visible::before { transform: scaleY(1); }

.egap-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--egap-gold-soft);
    color: var(--egap-gold);
}
.egap-icon svg { width: 21px; height: 21px; }

.egap-name {
    display: block;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--egap-ink);
    margin-top: 1px;
}
.egap-desc {
    display: block;
    margin-top: 5px;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--egap-muted);
}

.egap-go {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    color: var(--egap-muted);
    transition: transform 0.35s var(--egap-ease), color 0.25s ease;
}
.egap-option:hover .egap-go,
.egap-option:focus-visible .egap-go { color: var(--egap-gold); transform: translate(2px, -2px); }

/* ---------- Footer ---------- */
.egap-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 14px;
}
.egap-note { margin: 0; font-size: 12.5px; color: var(--egap-muted); }
.egap-continue {
    border: 0;
    background: none;
    padding: 8px 2px;
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--egap-ink);
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: var(--egap-gold-line);
    text-underline-offset: 4px;
    transition: text-decoration-color 0.25s ease;
}
.egap-continue:hover { text-decoration-color: var(--egap-gold); }

.egap-close:focus-visible,
.egap-option:focus-visible,
.egap-continue:focus-visible {
    outline: 2px solid var(--egap-gold);
    outline-offset: 2px;
}

/* ---------- Entrance choreography (first view of a visit) ---------- */
.egap-overlay.is-open .egap-title span,
.egap-overlay.is-open .egap-sub,
.egap-overlay.is-open .egap-list li,
.egap-overlay.is-open .egap-foot {
    animation: egapRise 0.7s var(--egap-ease) both;
}
.egap-overlay.is-open .egap-title span:nth-child(1) { animation-delay: 0.18s; }
.egap-overlay.is-open .egap-title span:nth-child(2) { animation-delay: 0.26s; }
.egap-overlay.is-open .egap-sub { animation-delay: 0.34s; }
.egap-overlay.is-open .egap-list li:nth-child(1) { animation-delay: 0.42s; }
.egap-overlay.is-open .egap-list li:nth-child(2) { animation-delay: 0.5s; }
.egap-overlay.is-open .egap-list li:nth-child(3) { animation-delay: 0.58s; }
.egap-overlay.is-open .egap-foot { animation-delay: 0.66s; }

.egap-overlay.is-open.is-first .egap-ring { animation: egapDraw 1.1s var(--egap-ease) both; }
.egap-overlay.is-open.is-first .egap-ticks { animation: egapFade 0.6s ease 0.5s both; }
.egap-overlay.is-open.is-first .egap-needle { animation: egapSettle 1.9s cubic-bezier(0.3, 0.7, 0.2, 1) 0.15s both; }

/* Return visits within the same session: a quicker, calmer entrance */
.egap-overlay.is-open.is-repeat .egap-title span,
.egap-overlay.is-open.is-repeat .egap-sub,
.egap-overlay.is-open.is-repeat .egap-list li,
.egap-overlay.is-open.is-repeat .egap-foot {
    animation-duration: 0.45s;
    animation-delay: 0.05s;
}

@keyframes egapRise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}
@keyframes egapFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes egapDraw { from { stroke-dashoffset: 164; } to { stroke-dashoffset: 0; } }
@keyframes egapSettle {
    0%   { transform: rotate(-120deg); opacity: 0; }
    12%  { opacity: 1; }
    40%  { transform: rotate(32deg); }
    58%  { transform: rotate(-14deg); }
    74%  { transform: rotate(6deg); }
    88%  { transform: rotate(-2deg); }
    100% { transform: rotate(0deg); opacity: 1; }
}

/* ---------- Phones: becomes a bottom sheet ---------- */
@media (max-width: 560px) {
    .egap-overlay { align-items: flex-end; padding: 0; }
    .egap-card {
        width: 100%;
        max-height: 86vh;
        max-height: 86dvh;
        border-radius: 22px 22px 0 0;
        border-bottom: 0;
        padding: 10px 20px calc(14px + env(safe-area-inset-bottom, 0px));
        transform: translateY(100%);
        transition: transform 0.6s var(--egap-ease), opacity 0.3s ease;
    }
    .egap-card::before { display: none; }
    .egap-handle {
        display: block;
        width: 40px;
        height: 4px;
        margin: 2px auto 12px;
        border-radius: 4px;
        background: var(--egap-rule);
    }
    .egap-close { top: 10px; right: 10px; }
    .egap-head { padding: 0 8px 16px; }
    .egap-compass { width: 38px; height: 38px; margin-bottom: 8px; }
    .egap-title { font-size: 24px; }
    .egap-sub { font-size: 13.5px; margin-top: 8px; }
    .egap-option { grid-template-columns: 38px 1fr 16px; gap: 12px; padding: 14px 8px 14px 10px; margin: 0 -8px; }
    .egap-icon { width: 38px; height: 38px; border-radius: 10px; }
    .egap-icon svg { width: 19px; height: 19px; }
    /* Keep the sheet light on phones: Brian's full wording stays in the page, shown in two lines */
    .egap-desc {
        font-size: 13px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    .egap-head { padding-bottom: 12px; }
    .egap-foot { padding-top: 12px; }
}

@media (max-height: 640px) and (min-width: 561px) {
    .egap-compass { width: 44px; height: 44px; margin-bottom: 8px; }
    .egap-head { padding-bottom: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    .egap-overlay, .egap-card, .egap-option, .egap-go, .egap-close,
    .egap-option::before { transition-duration: 0.01ms !important; }
    .egap-overlay * { animation: none !important; }
    .egap-card { transform: none !important; }
}
