/* "Experience a call" demo: a modern phone playing the recorded check-in, with a live waveform,
   captions, and a family update card that fills in as the call goes. Rendered by call-demo.js into
   [data-call-demo]; plain classes so it works on any page without a Tailwind rebuild. */

.ev-cd {
    --cd-e: cubic-bezier(0.16, 1, 0.3, 1);
    --cd-base: cubic-bezier(0.22, 1, 0.36, 1);
    --cd-lvl: 0;
    container-type: inline-size;
}
.ev-cd-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

/* Soft halo behind the phone; it breathes with the voice while the call is live */
.ev-cd-halo {
    position: absolute; left: 50%; top: 50%;
    width: 420px; height: 420px; margin: -210px 0 0 -210px;
    border-radius: 9999px;
    background: #2A9D8F;
    opacity: 0.22;
    filter: blur(80px);
    transform: scale(calc(0.9 + var(--cd-lvl) * 0.25));
    transition: opacity 0.6s var(--cd-base);
    will-change: transform;
    pointer-events: none;
}
.ev-cd.is-live .ev-cd-halo { opacity: 0.34; }

/* ---------- Phone ---------- */
.ev-cd-phone {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    width: 296px; height: 608px;
    padding: 10px;
    border-radius: 54px;
    background: #0d1b21;
    box-shadow: inset 0 0 0 2px #2f4650, 0 0 0 1px rgba(255, 255, 255, 0.06), 0 40px 80px -20px rgba(0, 0, 0, 0.55);
}
/* Side buttons */
.ev-cd-phone::before,
.ev-cd-phone::after { content: ""; position: absolute; width: 3px; border-radius: 2px; background: #2f4650; }
.ev-cd-phone::before { left: -3px; top: 132px; height: 56px; box-shadow: 0 72px 0 #2f4650; }
.ev-cd-phone::after { right: -3px; top: 168px; height: 88px; }

.ev-cd-screen {
    position: relative;
    height: 100%;
    border-radius: 44px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    color: #F8F9FA;
    background: radial-gradient(120% 60% at 50% 0%, rgba(42, 157, 143, 0.38), transparent 70%), #10262e;
}
.ev-cd-status {
    display: flex; align-items: center; justify-content: space-between;
    height: 48px; padding: 0 28px; flex-shrink: 0;
    font-size: 0.875rem; font-weight: 600;
}
.ev-cd-status-icons { display: flex; gap: 6px; font-size: 0.75rem; }

/* Dynamic island: shows a green dot and the timer while the call is live */
.ev-cd-island {
    position: absolute; top: 11px; left: 50%;
    width: 96px; height: 28px; margin-left: -48px; padding: 0 12px;
    border-radius: 9999px;
    background: #000;
    display: flex; align-items: center; justify-content: space-between;
    font-size: 0.75rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.ev-cd-island > * { opacity: 0; transition: opacity 0.3s var(--cd-base); }
.ev-cd.is-live .ev-cd-island > * { opacity: 1; transition-delay: 0.2s; }
.ev-cd-island-dot { width: 8px; height: 8px; border-radius: 9999px; background: #34d399; }
.ev-cd-island-time { color: #34d399; }

/* Caller: big ringing avatar while idle, compact once answered */
.ev-cd-caller { text-align: center; padding: 16px 24px 0; flex-shrink: 0; }
.ev-cd-avatar {
    position: relative;
    width: 72px; height: 72px; margin: 0 auto 12px;
    border-radius: 9999px;
    background: #2A9D8F; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.875rem;
    transition: width 0.6s var(--cd-e), height 0.6s var(--cd-e), font-size 0.6s var(--cd-e), margin 0.6s var(--cd-e);
}
.ev-cd-avatar::before,
.ev-cd-avatar::after { content: ""; position: absolute; inset: 0; border-radius: 9999px; border: 2px solid rgba(42, 157, 143, 0.7); opacity: 0; }
.ev-cd.is-idle .ev-cd-avatar::before,
.ev-cd.is-idle .ev-cd-avatar::after { animation: ev-cd-ring 2.4s var(--cd-base) infinite; }
.ev-cd.is-idle .ev-cd-avatar::after { animation-delay: 1.2s; }
@keyframes ev-cd-ring {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.9); opacity: 0; }
}
.ev-cd.is-live .ev-cd-avatar,
.ev-cd.is-ended .ev-cd-avatar { width: 48px; height: 48px; font-size: 1.25rem; margin-bottom: 8px; }
.ev-cd-name { font-size: 1.5rem; line-height: 2rem; font-weight: 600; }
.ev-cd-sub { font-size: 0.875rem; line-height: 1.25rem; color: rgba(248, 249, 250, 0.7); font-variant-numeric: tabular-nums; }

/* Waveform: teal while Evelyn talks, orange while Ms. Walker does */
.ev-cd-wave {
    display: flex; align-items: center; justify-content: center; gap: 3px;
    height: 40px; margin: 16px 24px 4px; flex-shrink: 0;
    color: #5fd0c2;
    opacity: 0;
    transition: opacity 0.4s var(--cd-base), color 0.4s var(--cd-base);
}
.ev-cd.is-live .ev-cd-wave { opacity: 1; }
.ev-cd-wave.is-them { color: #F4A261; }
.ev-cd-wave span { width: 4px; height: 40px; border-radius: 9999px; background: currentColor; transform: scaleY(var(--h, 0.1)); will-change: transform; }
.ev-cd-speaking { text-align: center; font-size: 0.75rem; line-height: 1rem; font-weight: 600; color: rgba(248, 249, 250, 0.7); min-height: 1rem; flex-shrink: 0; }

/* Captions */
.ev-cd-captions {
    flex: 1; min-height: 0;
    overflow-y: auto; scrollbar-width: none;
    padding: 12px 16px 8px;
    display: flex; flex-direction: column; gap: 8px;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 40px);
    mask-image: linear-gradient(to bottom, transparent 0, #000 40px);
}
.ev-cd-captions::-webkit-scrollbar { display: none; }
.ev-cd-captions::before { content: ""; margin-top: auto; }
.ev-cd-line { max-width: 85%; padding: 8px 12px; border-radius: 18px; font-size: 0.875rem; line-height: 1.25rem; animation: ev-cd-in 0.6s var(--cd-e) both; }
.ev-cd-line.is-ai { align-self: flex-start; background: rgba(248, 249, 250, 0.12); border-bottom-left-radius: 6px; }
.ev-cd-line.is-them { align-self: flex-end; background: #2A9D8F; border-bottom-right-radius: 6px; }
@keyframes ev-cd-in {
    from { opacity: 0; transform: translateY(10px); filter: blur(4px); }
    to { opacity: 1; transform: none; filter: none; }
}
.ev-cd-hint { margin: auto 24px; text-align: center; font-size: 0.875rem; line-height: 1.25rem; color: rgba(248, 249, 250, 0.7); }

/* Controls */
.ev-cd-controls { display: flex; justify-content: center; gap: 40px; padding: 16px 0 32px; flex-shrink: 0; }
.ev-cd-ctl {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    font-family: inherit; font-size: 0.75rem; line-height: 1rem;
    color: rgba(248, 249, 250, 0.8);
    background: none; border: 0; cursor: pointer;
}
.ev-cd-ctl[hidden] { display: none; }
.ev-cd-btn {
    width: 64px; height: 64px;
    border-radius: 9999px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; color: #fff;
    background: rgba(248, 249, 250, 0.16);
    transition: transform 0.3s var(--cd-base), background-color 0.3s var(--cd-base);
}
.ev-cd-ctl:hover .ev-cd-btn { transform: translateY(-1px); }
.ev-cd-ctl:active .ev-cd-btn { transform: scale(0.96); }
.ev-cd-ctl:focus-visible { outline: none; }
.ev-cd-ctl:focus-visible .ev-cd-btn { outline: 3px solid #E9C46A; outline-offset: 3px; }
.ev-cd-ctl.is-on .ev-cd-btn { background: #F8F9FA; color: #10262e; }
.ev-cd-btn.is-answer { background: #22c55e; }
.ev-cd.is-idle .ev-cd-btn.is-answer { animation: ev-cd-nudge 2.4s var(--cd-base) infinite; }
@keyframes ev-cd-nudge {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
    50% { box-shadow: 0 0 0 14px rgba(34, 197, 94, 0); }
}
.ev-cd-btn.is-end { background: #ef4444; }

/* ---------- Family update card ---------- */
.ev-cd-card {
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    width: 100%; max-width: 296px;
    padding: 20px;
    border-radius: 24px;
    background: #F8F9FA; color: #264653;
    box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.5);
}
.ev-cd-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.ev-cd-card-title { font-weight: 700; font-size: 1rem; line-height: 1.5rem; }
.ev-cd-card-sub { font-size: 0.75rem; line-height: 1rem; color: #6b7280; margin-bottom: 12px; }
.ev-cd-live { display: inline-flex; align-items: center; gap: 6px; font-size: 0.75rem; line-height: 1rem; font-weight: 600; color: #6b7280; }
.ev-cd-live::before { content: ""; width: 8px; height: 8px; border-radius: 9999px; background: #cbd5e1; }
.ev-cd.is-live .ev-cd-live { color: #238277; }
.ev-cd.is-live .ev-cd-live::before { background: #22c55e; animation: ev-cd-blink 1.6s var(--cd-base) infinite; }
@keyframes ev-cd-blink { 50% { opacity: 0.3; } }

.ev-cd-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ev-cd-row { position: relative; display: flex; align-items: center; gap: 12px; min-height: 40px; }
.ev-cd-ico {
    width: 32px; height: 32px; flex-shrink: 0;
    border-radius: 9999px;
    background: #e6f4f2; color: #238277;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.875rem;
    transition: background-color 0.4s var(--cd-base), color 0.4s var(--cd-base);
}
.ev-cd-row.is-flag .ev-cd-ico { background: #fdeee4; color: #c2410c; }
.ev-cd-txt { min-width: 0; font-size: 0.875rem; line-height: 1.25rem; }
.ev-cd-txt b { display: block; font-size: 0.75rem; line-height: 1rem; font-weight: 600; color: #6b7280; }
/* Rows wait as skeleton lines until the call reaches them */
.ev-cd-row .ev-cd-ico,
.ev-cd-row .ev-cd-txt { opacity: 0; transform: translateY(6px); }
.ev-cd-row::after {
    content: ""; position: absolute; left: 0; top: 50%;
    width: 70%; height: 10px; margin-top: -5px;
    border-radius: 9999px;
    background: #e5e7eb;
    transition: opacity 0.3s var(--cd-base);
}
.ev-cd-row.is-in::after { opacity: 0; }
.ev-cd-row.is-in .ev-cd-ico,
.ev-cd-row.is-in .ev-cd-txt { opacity: 1; transform: none; transition: transform 0.6s var(--cd-e), opacity 0.4s var(--cd-base); }
.ev-cd-row.is-in .ev-cd-txt { transition-delay: 0.08s; }

.ev-cd-foot {
    display: flex; align-items: center; gap: 8px;
    margin-top: 16px; padding-top: 12px;
    border-top: 1px solid #e5e7eb;
    font-size: 0.75rem; line-height: 1rem; color: #6b7280;
}
.ev-cd.is-sent .ev-cd-foot { color: #238277; font-weight: 600; }

/* Phone and card side by side when the demo's own column fits both (296 + 272 - 40 = 528px),
   scaled down a little in narrower columns such as a 1024px laptop's */
@container (min-width: 464px) {
    .ev-cd-stage { flex-direction: row; justify-content: center; gap: 0; }
    .ev-cd-card { margin-left: -40px; margin-top: 96px; width: 272px; }
    .ev-cd-halo { left: 40%; }
}
@container (min-width: 464px) and (max-width: 527.98px) {
    .ev-cd-stage { zoom: 0.86; }
}

/* Phones: the floating chat button steps aside while the demo is behind it */
@media (max-width: 600px) {
    #ev-open { transition: opacity 0.3s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s; }
    .ev-cd-under-chat #ev-open { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.3s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s 0.3s; }
}

@media (prefers-reduced-motion: reduce) {
    .ev-cd *, .ev-cd *::before, .ev-cd *::after { animation: none !important; transition: none !important; }
    .ev-cd-halo { transform: none; }
}
