/* ==========================================================================
   1:1 CALLS — voice and video overlay, incoming ring
   ========================================================================== */

body.ak-in-call { overflow: hidden; }

.ak-call {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: calc(18px + env(safe-area-inset-top, 0px)) 18px calc(26px + env(safe-area-inset-bottom, 0px));
    color: #fff;
    background:
        radial-gradient(120% 80% at 50% 0%, rgba(59, 130, 246, .3) 0%, rgba(59, 130, 246, 0) 60%),
        linear-gradient(170deg, #0B1533 0%, #050B18 62%, #03060F 100%);
    opacity: 0;
    transform: scale(1.02);
    transition: opacity .3s ease, transform .34s cubic-bezier(.2, .85, .25, 1);
}

.ak-call[hidden] { display: none; }
.ak-call.is-in { opacity: 1; transform: none; }

.ak-call-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        linear-gradient(to right, rgba(147, 197, 253, .05) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(147, 197, 253, .05) 1px, transparent 1px);
    background-size: 48px 48px;
    -webkit-mask-image: radial-gradient(70% 60% at 50% 42%, #000 0%, transparent 76%);
    mask-image: radial-gradient(70% 60% at 50% 42%, #000 0%, transparent 76%);
}

.ak-call-orb {
    position: absolute;
    z-index: 0;
    left: 50%;
    top: 46%;
    translate: -50% -50%;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    pointer-events: none;
    border: 1px solid rgba(147, 197, 253, .16);
    animation: akOrbPulse 3.2s ease-in-out infinite;
}

.ak-call-orb::before,
.ak-call-orb::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(147, 197, 253, .12);
}

.ak-call-orb::before { inset: 34px; }
.ak-call-orb::after { inset: 70px; border-color: rgba(147, 197, 253, .09); }

@keyframes akOrbPulse {
    0%, 100% { transform: scale(1); opacity: .9; }
    50% { transform: scale(1.06); opacity: .5; }
}

.ak-call-remote {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #050B18;
    display: none;
}

.ak-call.is-video .ak-call-remote { display: block; }

.ak-call-local {
    position: absolute;
    z-index: 4;
    right: 14px;
    bottom: calc(120px + env(safe-area-inset-bottom, 0px));
    width: 96px;
    height: 128px;
    border-radius: 16px;
    object-fit: cover;
    background: #0B1533;
    border: 1px solid rgba(255, 255, 255, .2);
    box-shadow: 0 16px 34px -18px rgba(0, 0, 0, .9);
    display: none;
    transition: opacity .2s;
}

.ak-call.is-video .ak-call-local { display: block; }

.ak-call-top {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.ak-call-state {
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .02em;
    color: #BFDBFE;
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(147, 197, 253, .2);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
}

.ak-call-timer {
    font-size: 13px;
    font-weight: 800;
    color: rgba(255, 255, 255, .88);
    font-variant-numeric: tabular-nums;
    text-shadow: 0 2px 10px rgba(0, 0, 0, .5);
}

.ak-call-mid {
    position: relative;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 11px;
    text-align: center;
    margin-top: auto;
    margin-bottom: auto;
}

.ak-call-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 30px;
    font-weight: 800;
    color: #fff;
    background-color: #0B1533;
    background-size: cover;
    background-position: center;
    background-image: linear-gradient(140deg, #0B1533 0%, #1E3A8A 55%, #2563EB 100%);
    box-shadow:
        0 0 0 5px rgba(147, 197, 253, .14),
        0 26px 56px -26px rgba(29, 78, 216, .9),
        inset 0 1px 0 rgba(255, 255, 255, .22);
    animation: akAvatarFloat 4s ease-in-out infinite;
}

@keyframes akAvatarFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.ak-call-name {
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -.032em;
    color: #fff;
    text-shadow: 0 6px 22px rgba(0, 0, 0, .5);
}

.ak-call-actions {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.ak-call-btn {
    width: 56px;
    height: 56px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .3);
    background: rgba(255, 255, 255, .2);
    color: #fff;
    cursor: pointer;
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    box-shadow: 0 14px 30px -18px rgba(0, 0, 0, .9), inset 0 1px 0 rgba(255, 255, 255, .18);
    transition: transform .18s, background .18s;
}

.ak-call-btn svg { width: 23px; height: 23px; }
.ak-call-btn:hover { background: rgba(255, 255, 255, .3); transform: translateY(-2px); }
.ak-call-btn:active { transform: scale(.94); }
.ak-call-btn.is-off { background: rgba(255, 255, 255, .9); color: #0B1533; }
.ak-call-btn:focus-visible { outline: 2px solid #93C5FD; outline-offset: 3px; }

.ak-call-btn.ak-call-end {
    width: 62px;
    height: 62px;
    color: #fff;
    border-color: transparent;
    background: linear-gradient(140deg, #DC2626 0%, #B91C1C 100%);
    box-shadow: 0 18px 34px -16px rgba(220, 38, 38, .85), inset 0 1px 0 rgba(255, 255, 255, .28);
}

.ak-call-btn.ak-call-end:hover {
    background: linear-gradient(140deg, #EF4444 0%, #DC2626 100%);
    box-shadow: 0 20px 38px -16px rgba(220, 38, 38, .95);
}

.ak-call.is-video .ak-call-top {
    padding: 8px 12px;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(5, 11, 24, .6), rgba(5, 11, 24, .18));
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
}

.ak-call.is-video .ak-call-avatar { display: none; }

.ak-call.is-video .ak-call-actions {
    padding: 10px 14px;
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(5, 11, 24, .42), rgba(5, 11, 24, .68));
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    width: max-content;
    margin: 0 auto;
}

/* ------------------------------------------------------ incoming overlay */
.ak-call-in {
    position: fixed;
    inset: 0;
    z-index: 310;
    display: grid;
    place-items: center;
    padding: 22px;
    background: rgba(3, 8, 20, .55);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity .26s ease;
}

.ak-call-in.is-in { opacity: 1; }

.ak-call-in-card {
    width: min(320px, 100%);
    padding: 26px 22px 22px;
    border-radius: 26px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    background:
        radial-gradient(320px 180px at 82% -8%, rgba(147, 197, 253, .3) 0%, rgba(147, 197, 253, 0) 62%),
        linear-gradient(168deg, rgba(18, 31, 56, .97) 0%, rgba(6, 12, 26, .96) 100%);
    border: 1px solid rgba(147, 197, 253, .18);
    box-shadow: 0 34px 70px -30px rgba(0, 0, 0, .95), inset 0 1px 0 rgba(255, 255, 255, .1);
    -webkit-backdrop-filter: blur(28px) saturate(150%);
    backdrop-filter: blur(28px) saturate(150%);
    transform: translateY(14px) scale(.97);
    transition: transform .3s cubic-bezier(.2, .85, .25, 1);
}

.ak-call-in.is-in .ak-call-in-card { transform: none; }

.ak-call-in-kicker {
    font-size: 8px;
    font-weight: 800;
    letter-spacing: .15em;
    text-transform: uppercase;
    color: #93C5FD;
}

.ak-call-in-avatar {
    width: 72px;
    height: 72px;
    margin: 8px 0 4px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    overflow: hidden;
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    background-image: linear-gradient(140deg, #0B1533 0%, #1E3A8A 55%, #2563EB 100%);
    box-shadow:
        0 0 0 5px rgba(147, 197, 253, .14),
        0 20px 42px -22px rgba(29, 78, 216, .9),
        inset 0 1px 0 rgba(255, 255, 255, .22);
    animation: akAvatarFloat 3.6s ease-in-out infinite;
}

.ak-call-in-avatar img,
.ak-call-in-avatar span {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: grid;
    place-items: center;
}

.ak-call-in-name {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -.03em;
    color: #fff;
}

.ak-call-in-sub { font-size: 10px; color: #8FA6C6; margin-bottom: 10px; }

.ak-call-in-btns {
    display: flex;
    align-items: center;
    gap: 26px;
    margin-top: 6px;
}

.ak-call-in-decline,
.ak-call-in-accept {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    border: 0;
    transition: transform .18s, box-shadow .18s, background .18s;
}

.ak-call-in-decline {
    color: #fff;
    background: linear-gradient(140deg, #DC2626 0%, #B91C1C 100%);
    box-shadow: 0 16px 32px -16px rgba(220, 38, 38, .9), inset 0 1px 0 rgba(255, 255, 255, .26);
}

.ak-call-in-accept {
    color: #fff;
    background:
        radial-gradient(120px 70px at 80% 0%, rgba(147, 197, 253, .3) 0%, rgba(147, 197, 253, 0) 62%),
        linear-gradient(140deg, #1D4ED8 0%, #3B82F6 100%);
    box-shadow: 0 16px 32px -16px rgba(29, 78, 216, .85), inset 0 1px 0 rgba(255, 255, 255, .26);
    animation: akRingPulse 1.8s ease-in-out infinite;
}

.ak-call-in-decline svg,
.ak-call-in-accept svg { width: 23px; height: 23px; }

.ak-call-in-decline:hover,
.ak-call-in-accept:hover { transform: translateY(-2px); }
.ak-call-in-decline:active,
.ak-call-in-accept:active { transform: scale(.94); }
.ak-call-in-decline:focus-visible,
.ak-call-in-accept:focus-visible { outline: 2px solid #93C5FD; outline-offset: 3px; }

@keyframes akRingPulse {
    0%, 100% { box-shadow: 0 16px 32px -16px rgba(29, 78, 216, .85), 0 0 0 0 rgba(37, 99, 235, .32); }
    50% { box-shadow: 0 16px 32px -16px rgba(29, 78, 216, .85), 0 0 0 10px rgba(37, 99, 235, 0); }
}

/* call buttons inside a conversation header */
.eco-call-actions {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
}

.eco-call-btn {
    width: 34px;
    height: 34px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 11px;
    border: 1px solid rgba(147, 197, 253, .16);
    background: rgba(255, 255, 255, .06);
    color: #BFDBFE;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background .18s, color .18s, transform .18s, border-color .18s;
}

.eco-call-btn svg { width: 17px; height: 17px; }

.eco-call-btn:hover {
    background: rgba(147, 197, 253, .18);
    border-color: rgba(147, 197, 253, .32);
    color: #fff;
    transform: translateY(-1px);
}

.eco-call-btn:active { transform: scale(.94); }
.eco-call-btn:focus-visible { outline: 2px solid #93C5FD; outline-offset: 2px; }

.eco-call-btn.eco-call-video {
    color: #fff;
    border-color: transparent;
    background:
        radial-gradient(110px 60px at 80% 0%, rgba(147, 197, 253, .4) 0%, rgba(147, 197, 253, 0) 62%),
        linear-gradient(135deg, #1E3A8A 0%, #1D4ED8 50%, #3B82F6 100%);
    box-shadow: 0 10px 22px -14px rgba(29, 78, 216, .9), inset 0 1px 0 rgba(255, 255, 255, .28);
}

@media (max-width: 760px) {
    .ak-call { padding: calc(14px + env(safe-area-inset-top,0px)) 14px calc(20px + env(safe-area-inset-bottom,0px)); }
    .ak-call-avatar { width: 84px; height: 84px; font-size: 26px; }
    .ak-call-name { font-size: 19px; }
    .ak-call-btn { width: 52px; height: 52px; }
    .ak-call-btn.ak-call-end { width: 58px; height: 58px; }
    .ak-call-actions { gap: 16px; }
    .ak-call-local { width: 78px; height: 104px; right: 12px; }
    .ak-call-in-card { padding: 22px 18px 18px; }
    .eco-call-btn { width: 32px; height: 32px; border-radius: 10px; }
}

@media (max-width: 360px) {
    .ak-call-actions { gap: 11px; }
    .ak-call-btn { width: 48px; height: 48px; }
    .ak-call-btn.ak-call-end { width: 54px; height: 54px; }
    .ak-call-in-btns { gap: 20px; }
    .ak-call-in-decline, .ak-call-in-accept { width: 52px; height: 52px; }
}

@media (prefers-reduced-motion: reduce) {
    .ak-call, .ak-call-in, .ak-call-in-card, .ak-call-btn,
    .ak-call-in-decline, .ak-call-in-accept, .eco-call-btn { transition: none !important; }
    .ak-call-orb, .ak-call-avatar, .ak-call-in-avatar, .ak-call-in-accept { animation: none !important; }
    .ak-call-btn:hover, .ak-call-in-decline:hover,
    .ak-call-in-accept:hover, .eco-call-btn:hover { transform: none !important; }
}
/* ------------------------------------------------------------------ toast */
.ak-call-toast {
    position: fixed;
    z-index: 330;
    left: 50%;
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    translate: -50% 0;
    width: max-content;
    max-width: min(400px, calc(100% - 32px));
    padding: 11px 16px;
    border-radius: 14px;
    font-size: 11.5px;
    line-height: 1.5;
    font-weight: 600;
    text-align: center;
    color: #fff;
    background: linear-gradient(150deg, rgba(24, 39, 70, .97), rgba(9, 17, 33, .96));
    border: 1px solid rgba(147, 197, 253, .22);
    box-shadow: 0 20px 44px -22px rgba(0, 0, 0, .95), inset 0 1px 0 rgba(255, 255, 255, .1);
    -webkit-backdrop-filter: blur(22px) saturate(150%);
    backdrop-filter: blur(22px) saturate(150%);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity .24s ease, transform .26s cubic-bezier(.2, .85, .25, 1);
    pointer-events: none;
}

.ak-call-toast[hidden] { display: none; }
.ak-call-toast.is-in { opacity: 1; transform: none; }

@media (max-width: 760px) {
    .ak-call-toast { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); font-size: 11px; }
}
