/* ApoChat call screen, 21 November 2026. Every call fills the screen like a phone call:
   incoming calls ring full screen with Tolak/Terima; video calls hide their buttons until touched.
   Hidden buttons only fade (opacity), so keyboards and screen readers still reach them. */
#callDialog.call-screen{--call-icon-mic:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='3' width='6' height='11' rx='3'/%3E%3Cpath d='M5 11a7 7 0 0 0 14 0M12 18v3M8 21h8'/%3E%3C/svg%3E");--call-icon-mic-off:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='3' width='6' height='11' rx='3'/%3E%3Cpath d='M5 11a7 7 0 0 0 14 0M12 18v3M8 21h8M3 3l18 18'/%3E%3C/svg%3E");--call-icon-speaker:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9h4l5-4v14l-5-4H4z'/%3E%3Cpath d='M16.5 8.5a5 5 0 0 1 0 7M19.2 5.8a8.8 8.8 0 0 1 0 12.4'/%3E%3C/svg%3E");--call-icon-audio:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 15v-3a8 8 0 0 1 16 0v3'/%3E%3Crect x='3' y='14' width='4.5' height='7' rx='1.6'/%3E%3Crect x='16.5' y='14' width='4.5' height='7' rx='1.6'/%3E%3C/svg%3E");--call-icon-camera:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2.5' y='6' width='13' height='12' rx='3'/%3E%3Cpath d='M15.5 10.5 21.5 7v10l-6-3.5'/%3E%3C/svg%3E");--call-icon-camera-off:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2.5' y='6' width='13' height='12' rx='3'/%3E%3Cpath d='M15.5 10.5 21.5 7v10l-6-3.5M3 3l18 18'/%3E%3C/svg%3E");--call-icon-flip:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 11a8 8 0 0 0-14.3-4.9L4 8'/%3E%3Cpath d='M4 3.5V8h4.5'/%3E%3Cpath d='M4 13a8 8 0 0 0 14.3 4.9L20 16'/%3E%3Cpath d='M20 20.5V16h-4.5'/%3E%3C/svg%3E");--call-icon-expand:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5'/%3E%3C/svg%3E");--call-icon-answer:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M5 3h4l2 5-3 2c1 3 3 5 6 6l2-3 5 2v4c-1 4-7 1-11-2S1 7 5 3Z'/%3E%3C/svg%3E");--call-icon-hangup:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg transform='rotate(135 12 12)'%3E%3Cpath fill='black' d='M5 3h4l2 5-3 2c1 3 3 5 6 6l2-3 5 2v4c-1 4-7 1-11-2S1 7 5 3Z'/%3E%3C/g%3E%3C/svg%3E")}

#callDialog.call-screen{position:fixed;inset:0;width:100%;height:100%;max-width:none;max-height:none;margin:0;padding:0;border:0;border-radius:0;box-sizing:border-box;overflow:hidden;overscroll-behavior:contain;color:#fff;text-align:center;font-family:system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;background:radial-gradient(130% 75% at 50% 0%,#5a4a8a 0%,#2c2446 48%,#17132a 100%);box-shadow:none;-webkit-user-select:none;user-select:none}
#callDialog.call-screen[open]{display:flex;flex-direction:column}
#callDialog.call-screen::backdrop{background:#17132a}

/* Media */
#callDialog.call-screen .videos{position:absolute;inset:0;display:none;margin:0;min-height:0;background:#100d1c}
#callDialog.call-screen[data-kind=video]:not([data-phase=incoming]) .videos{display:block}
#callDialog.call-screen #remoteVideo{display:block;width:100%;height:100%;max-height:none;object-fit:contain;background:#100d1c;border-radius:0}
#callDialog.call-screen #localVideo{position:absolute;z-index:4;top:calc(14px + env(safe-area-inset-top));right:calc(14px + env(safe-area-inset-right));bottom:auto;width:clamp(84px,24vw,180px);height:auto;max-height:28vh;aspect-ratio:3/4;object-fit:cover;border:1px solid #ffffff55;border-radius:16px;background:#3b304e;box-shadow:0 8px 26px #0008;transform:scaleX(-1)}
#callDialog.call-screen #localVideo[data-facing=environment]{transform:none}

/* Caller identity */
#callDialog.call-screen .call-identity{position:relative;z-index:2;flex:1 1 auto;min-height:0;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:calc(28px + env(safe-area-inset-top)) 24px 12px;transition:opacity .25s ease,transform .25s ease}
#callDialog.call-screen .eyebrow{margin:0 0 28px;color:#ecd6a4;font-size:12px;font-weight:700;line-height:1.4;letter-spacing:.14em;text-transform:uppercase}
#callDialog.call-screen .call-avatar{position:relative;display:grid;place-items:center;flex:none;width:132px;height:132px;margin:0 auto;border-radius:50%;background:linear-gradient(145deg,#8f7bcc,#534ca4);box-shadow:0 18px 48px #0007,inset 0 0 0 2px #ffffff33;color:#fff;font-size:54px;font-weight:600;line-height:1}
#callDialog.call-screen .call-avatar>span{position:relative;z-index:1}
#callDialog.call-screen #callPeer{margin:24px 0 8px;max-width:100%;color:#fff;font:600 30px/1.2 system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;overflow-wrap:anywhere}
#callDialog.call-screen #callPeer:focus{outline:none}
#callDialog.call-screen #callStatus{margin:0;color:#e4ddf0;font-size:16px;line-height:1.5}
#callDialog.call-screen .call-timer{margin:6px 0 0;color:#fff;font-size:16px;line-height:1.4;font-variant-numeric:tabular-nums;letter-spacing:.04em}
#callDialog.call-screen .audio-output-status{margin:12px 0 0;max-width:340px;color:#d2c8e4;font-size:13px;line-height:1.5}
#callDialog.call-screen .audio-output-status:empty{display:none}
#callDialog.call-screen:is([data-phase=incoming],[data-phase=outgoing]) .call-avatar::before,#callDialog.call-screen:is([data-phase=incoming],[data-phase=outgoing]) .call-avatar::after{content:"";position:absolute;inset:0;border:2px solid #cdbcf5;border-radius:50%;opacity:0;animation:apochat-call-ring 2.4s ease-out infinite}
#callDialog.call-screen:is([data-phase=incoming],[data-phase=outgoing]) .call-avatar::after{animation-delay:1.2s}
#callDialog.call-screen[data-phase=incoming] .call-avatar{width:148px;height:148px;font-size:60px}
@keyframes apochat-call-ring{0%{transform:scale(1);opacity:.75}100%{transform:scale(1.7);opacity:0}}

/* Buttons: round icon with the visible label underneath (the label is the accessible name). */
#callDialog.call-screen .call-controls{position:relative;z-index:3;flex:none;padding:16px 16px calc(18px + env(safe-area-inset-bottom));transition:opacity .25s ease,transform .25s ease}
#callDialog.call-screen .call-actions{display:flex;flex-wrap:wrap;justify-content:center;align-items:flex-start;gap:14px 10px;max-width:440px;margin:0 auto;padding:0;border-radius:0;background:none}
#callDialog.call-screen .call-note{margin:14px auto 0;max-width:520px;color:#cbc2dc;font-size:11px!important;line-height:1.5}
#callDialog.call-screen .call-control{position:relative;display:inline-flex;flex-direction:column;align-items:center;gap:8px;width:78px;min-height:0;margin:0;padding:0;border:0;border-radius:16px;background:none;color:#fff;font-family:inherit;font-size:12px;font-weight:600;line-height:1.25;text-align:center;white-space:normal;overflow-wrap:anywhere;cursor:pointer;-webkit-tap-highlight-color:transparent;touch-action:manipulation}
#callDialog.call-screen .call-control[hidden]{display:none}
#callDialog.call-screen .call-control::before{content:"";flex:none;width:58px;height:58px;border-radius:50%;background-color:#ffffff26;box-shadow:inset 0 0 0 1px #ffffff3d;transition:background-color .15s ease,transform .15s ease}
#callDialog.call-screen .call-control::after{content:"";position:absolute;top:16px;left:50%;width:26px;height:26px;margin-left:-13px;background-color:#fff;-webkit-mask:var(--call-icon) center/contain no-repeat;mask:var(--call-icon) center/contain no-repeat;pointer-events:none}
#callDialog.call-screen .call-control:hover::before{background-color:#ffffff3a}
#callDialog.call-screen .call-control:active::before{transform:scale(.94)}
#callDialog.call-screen .call-control:focus-visible{outline:3px solid #ffd27a;outline-offset:4px}
#callDialog.call-screen .call-control:disabled{opacity:.55;cursor:not-allowed}
#callDialog.call-screen [data-icon=mic]{--call-icon:var(--call-icon-mic)}
#callDialog.call-screen [data-icon=mic][data-state=off]{--call-icon:var(--call-icon-mic-off)}
#callDialog.call-screen [data-icon=speaker]{--call-icon:var(--call-icon-speaker)}
#callDialog.call-screen [data-icon=audio]{--call-icon:var(--call-icon-audio)}
#callDialog.call-screen [data-icon=camera]{--call-icon:var(--call-icon-camera)}
#callDialog.call-screen [data-icon=camera][data-state=off]{--call-icon:var(--call-icon-camera-off)}
#callDialog.call-screen [data-icon=flip]{--call-icon:var(--call-icon-flip)}
#callDialog.call-screen [data-icon=expand]{--call-icon:var(--call-icon-expand)}
#callDialog.call-screen [data-icon=hangup]{--call-icon:var(--call-icon-hangup)}
#callDialog.call-screen [data-icon=answer]{--call-icon:var(--call-icon-answer)}
/* Active toggles (speaker on, microphone or camera off) turn white like a phone dialer. */
#callDialog.call-screen .call-control:is([aria-pressed=true],[data-state=off])::before{background-color:#fff;box-shadow:none}
#callDialog.call-screen .call-control:is([aria-pressed=true],[data-state=off])::after{background-color:#2c2446}
#callDialog.call-screen .call-control.danger::before{background-color:#e0483e;box-shadow:0 8px 20px #e0483e55}
#callDialog.call-screen .call-control.danger:hover::before{background-color:#c93a31}
#callDialog.call-screen .call-control.primary::before{background-color:#2fb36b;box-shadow:0 8px 20px #2fb36b55}
#callDialog.call-screen .call-control.primary:hover::before{background-color:#26985a}

/* Incoming call: only Tolak and Terima, large and far apart. */
#callDialog.call-screen[data-phase=incoming] .call-actions{justify-content:space-between;max-width:320px;padding:0 6px}
#callDialog.call-screen[data-phase=incoming] .call-control{width:96px;font-size:14px}
#callDialog.call-screen[data-phase=incoming] .call-control::before{width:72px;height:72px}
#callDialog.call-screen[data-phase=incoming] .call-control::after{top:21px;width:30px;height:30px;margin-left:-15px}
#callDialog.call-screen[data-phase=incoming] .call-control.primary::before{animation:apochat-call-answer 1.6s ease-in-out infinite}
#callDialog.call-screen[data-phase=incoming] .call-controls{padding-bottom:calc(44px + env(safe-area-inset-bottom))}
#callDialog.call-screen[data-phase=incoming] :is(.call-note,.audio-output-status,#audioOutputOpen,#speakerToggle,#mute,#camera,#switchCamera,#fullscreenCall){display:none}
@keyframes apochat-call-answer{0%,100%{box-shadow:0 0 0 0 #2fb36b88}50%{box-shadow:0 0 0 14px #2fb36b00}}

/* Video: picture fills the screen; name on top, buttons at the bottom over soft shades. */
#callDialog.call-screen[data-kind=video]:not([data-phase=incoming]) .call-identity{position:absolute;top:0;left:0;right:0;flex:none;align-items:flex-start;justify-content:flex-start;padding:calc(16px + env(safe-area-inset-top)) calc(clamp(84px,24vw,180px) + 28px) 36px 20px;text-align:left;background:linear-gradient(#000000a0,#0000)}
#callDialog.call-screen[data-kind=video]:not([data-phase=incoming]) .eyebrow{margin:0 0 4px}
#callDialog.call-screen[data-kind=video]:not([data-phase=incoming]) #callPeer{margin:0 0 2px;font-size:22px;text-shadow:0 1px 4px #000}
#callDialog.call-screen[data-kind=video]:not([data-phase=incoming]) :is(#callStatus,.call-timer,.audio-output-status){font-size:13px;text-shadow:0 1px 3px #000}
#callDialog.call-screen[data-kind=video]:not([data-phase=incoming]) .call-avatar{display:none}
#callDialog.call-screen[data-kind=video]:not([data-phase=incoming]):not([data-remote-video]) .call-avatar{display:grid;position:absolute;top:50vh;top:50dvh;left:50%;transform:translate(-50%,-50%)}
#callDialog.call-screen[data-kind=video]:not([data-phase=incoming]) .call-controls{position:absolute;left:0;right:0;bottom:0;padding-top:44px;background:linear-gradient(#0000,#000000b8)}
#callDialog.call-screen[data-kind=video]:not([data-phase=incoming]) .call-note{display:none}
#callDialog.call-screen[data-kind=video][data-phase=active][data-controls=hidden] .call-controls{opacity:0;transform:translateY(24px);pointer-events:none}
#callDialog.call-screen[data-kind=video][data-phase=active][data-controls=hidden] .call-identity{opacity:0;transform:translateY(-16px);pointer-events:none}
/* Keyboard focus always brings the buttons back, even before the script reacts. */
#callDialog.call-screen .call-controls:has(:focus-visible){opacity:1!important;transform:none!important;pointer-events:auto!important}
#callDialog.call-screen .call-tap-hint{position:absolute;z-index:4;left:50%;bottom:calc(28px + env(safe-area-inset-bottom));margin:0;padding:8px 14px;border-radius:999px;background:#000000a8;color:#fff;font-size:13px;line-height:1.4;white-space:nowrap;opacity:0;transform:translateX(-50%);pointer-events:none;transition:opacity .3s ease}
#callDialog.call-screen[data-controls=hidden][data-hint=on] .call-tap-hint{opacity:1}

#callDialog.call-screen #playAudio{position:absolute;z-index:5;top:50%;left:50%;min-height:48px;padding:12px 20px;border:0;border-radius:999px;background:#fff;color:#2c2446;font-weight:700;box-shadow:0 10px 30px #0008;transform:translate(-50%,-50%)}
#callDialog.call-screen #playAudio[hidden]{display:none}

@media (max-width:360px){#callDialog.call-screen .call-control{width:70px;font-size:11px}#callDialog.call-screen .call-control::before{width:52px;height:52px}#callDialog.call-screen .call-control::after{top:13px}#callDialog.call-screen #callPeer{font-size:26px}}
@media (max-height:560px){#callDialog.call-screen[data-phase] .call-avatar{width:84px;height:84px;font-size:36px}#callDialog.call-screen .eyebrow{margin-bottom:12px}#callDialog.call-screen #callPeer{margin-top:12px;font-size:22px}#callDialog.call-screen .call-note{display:none}#callDialog.call-screen[data-phase=incoming] .call-controls{padding-bottom:calc(18px + env(safe-area-inset-bottom))}}
@media (prefers-reduced-motion:reduce){#callDialog.call-screen *,#callDialog.call-screen *::before,#callDialog.call-screen *::after{animation:none!important;transition:none!important}}
