/* ============================================================
   Video Call Module — MAX Messenger Style
   ============================================================ */

/* ── Video Call Screen (fullscreen overlay) ──────────────── */
.videoCallScreen {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 9999;
    display: flex;
    flex-direction: column;
}

.videoCallScreen.hidden { display: none; }

/* Remote "video" — static portrait as background */
.remoteVideo {
    position: absolute;
    inset: -20px; /* Extra space for zoom/shake */
    background-color: #0a0a0a;
    background-size: cover;
    background-position: center 15%;
    will-change: transform;
    animation: vc-kenburns 20s ease-in-out infinite alternate;
}

/* Gradient overlays for readability */
.remoteVideo::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom,
        rgba(0,0,0,0.5) 0%,
        transparent 20%,
        transparent 55%,
        rgba(0,0,0,0.7) 100%
    );
    pointer-events: none;
    z-index: 1;
}

/* Lipsync overlay — semi-transparent dark ellipse near mouth area */
.vc-lip-overlay {
    position: absolute;
    width: 16%;
    height: 6%;
    background: radial-gradient(ellipse, rgba(0,0,0,0.65) 0%, transparent 70%);
    border-radius: 50%;
    transform: translateX(-50%) scaleY(0.2);
    opacity: 0;
    transition: transform 0.08s ease-out, opacity 0.08s ease-out;
    z-index: 2;
    pointer-events: none;
    filter: blur(4px);
}

/* Self camera window */
.selfVideo {
    position: absolute;
    top: auto;
    bottom: 160px;
    right: 16px;
    width: 112px;
    height: 158px;
    border-radius: 14px;
    border: 2px solid rgba(255,255,255,0.15);
    object-fit: cover;
    z-index: 10;
    background: #1a1a1a;
}

/* ── Top info bar ───────────────────────────────────────── */
.vc-top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: max(16px, env(safe-area-inset-top, 16px)) 20px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 20;
    background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent);
}

.vc-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
}

.vc-status {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.5);
    flex: 1;
}

.vc-status.active {
    color: #4cd964;
}

.vc-timer {
    font-family: 'SF Mono', 'Monaco', monospace;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.6);
    font-variant-numeric: tabular-nums;
}

/* ── Bottom controls ────────────────────────────────────── */
.videoControls {
    position: absolute;
    bottom: max(24px, env(safe-area-inset-bottom, 24px));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    z-index: 20;
}

.videoCtrl {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.15);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.videoCtrl:active { transform: scale(0.92); }
.videoCtrl.recording {
    background: rgba(76, 217, 100, 0.35);
    border: 2px solid #4cd964;
    animation: vc-mic-pulse 1.2s infinite;
}

@keyframes vc-mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(76, 217, 100, 0.4); }
    50% { box-shadow: 0 0 16px 4px rgba(76, 217, 100, 0.2); }
}

.videoCtrl.end {
    background: linear-gradient(135deg, #FF3B30, #FF5F56);
    width: 64px;
    height: 64px;
}

/* ── Chat bubbles during call ───────────────────────────── */
.vc-chat-bubbles {
    position: absolute;
    bottom: 120px;
    left: 12px;
    right: 70px;
    max-height: 35vh;
    overflow-y: auto;
    display: none;
    flex-direction: column;
    gap: 6px;
    z-index: 15;
    pointer-events: none;
    -webkit-overflow-scrolling: touch;
}

.vc-chat-bubbles.visible { display: flex; }

.vc-msg {
    padding: 8px 14px;
    border-radius: 16px;
    font-size: 0.8rem;
    line-height: 1.4;
    max-width: 80%;
    word-wrap: break-word;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: vc-bubble-in 0.3s ease-out;
    pointer-events: auto;
}

@keyframes vc-bubble-in {
    from { opacity: 0; transform: translateY(8px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.vc-msg.user {
    align-self: flex-end;
    background: rgba(42, 123, 222, 0.7);
    border-bottom-right-radius: 4px;
}

.vc-msg.bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.15);
    border-bottom-left-radius: 4px;
}

.vc-msg-label {
    font-size: 0.6rem;
    color: rgba(255,255,255,0.5);
    margin-bottom: 2px;
    font-weight: 600;
}

/* ── Input bar during call ──────────────────────────────── */
.vc-input-bar {
    position: absolute;
    bottom: 100px;
    left: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 20;
}

.vc-input-bar.hidden { display: none; }

.vc-text-input {
    flex: 1;
    padding: 10px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: #fff;
    font-size: 0.9rem;
    outline: none;
}

.vc-text-input:focus { border-color: rgba(255,255,255,0.35); }
.vc-text-input::placeholder { color: rgba(255,255,255,0.4); }

.vc-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #007AFF;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.vc-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Mobile adjustments ─────────────────────────────────── */
@media (max-width: 600px) {
    .selfVideo {
        width: 100px;
        height: 140px;
        bottom: 140px;
        right: 12px;
    }
    .videoCtrl { width: 52px; height: 52px; }
    .videoCtrl.end { width: 60px; height: 60px; }
    .vc-chat-bubbles { right: 128px; bottom: 140px; max-height: 30vh; }
    .vc-input-bar { bottom: 110px; }
}

/* ── Ken Burns + Handheld Shake Animations ────────────────── */

/* Slow zoom/pan — simulates someone holding a phone */
@keyframes vc-kenburns {
    0% {
        transform: scale3d(1.08, 1.08, 1) translate3d(0, 0, 0);
    }
    25% {
        transform: scale3d(1.12, 1.12, 1) translate3d(-8px, -4px, 0);
    }
    50% {
        transform: scale3d(1.10, 1.10, 1) translate3d(6px, -6px, 0);
    }
    75% {
        transform: scale3d(1.14, 1.14, 1) translate3d(-4px, 8px, 0);
    }
    100% {
        transform: scale3d(1.08, 1.08, 1) translate3d(4px, 2px, 0);
    }
}
