/* ATP in-app calls: the call screens (AtpCallHost), the call buttons (AtpCallButtons) and the call rows of a
   conversation (AtpCallLogRow). The call surface is "night route": deep navy from the wordmark, the brand blue in the
   rings that pulse out of the avatar like a beacon, a faint dashed route line across the backdrop, and the two
   unmistakable colours of a phone call (green answer, red hang-up). Every container is fluid: the sheet fills the
   phone and takes a fraction of a desk monitor; nothing is capped at a fixed width. */

:root {
    --atp-call-night: #0B1B33;
    --atp-call-deep: #12325A;
    --atp-call-ink: #FFFFFF;
    --atp-call-ink-soft: rgba(255, 255, 255, 0.78);
    --atp-call-ink-faint: rgba(255, 255, 255, 0.6);
    --atp-call-glass: rgba(255, 255, 255, 0.12);
    --atp-call-glass-strong: rgba(255, 255, 255, 0.2);
    --atp-call-ring: rgba(125, 178, 226, 0.55);
    --atp-call-accept: #1E9E5A;
    --atp-call-accept-hover: #188A4D;
    --atp-call-decline: #D33B3B;
    --atp-call-decline-hover: #B92F2F;
    --atp-call-amber: #F2B441;
    --atp-call-z: 2000;
}

/* ------------------------------------------------------------------ overlay + sheet */

.atp-call, .atp-call *, .atp-call-pill, .atp-call-buttons, .atp-call-buttons *, .atp-call-row, .atp-call-row * { box-sizing: border-box; }

.atp-call {
    position: fixed;
    inset: 0;
    z-index: var(--atp-call-z);
    display: grid;
    place-items: center;
    font-family: var(--atp-font-sans);
    color: var(--atp-call-ink);
}

.atp-call__veil {
    position: absolute;
    inset: 0;
    background: rgba(6, 14, 28, 0.62);
    backdrop-filter: blur(8px) saturate(120%);
    -webkit-backdrop-filter: blur(8px) saturate(120%);
    animation: atp-call-fade 220ms ease-out both;
}

.atp-call__sheet {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    width: 100%;
    height: 100%;
    padding: calc(var(--atp-safe-top) + 14px) calc(var(--atp-safe-right) + 20px) calc(var(--atp-safe-bottom) + 18px) calc(var(--atp-safe-left) + 20px);
    background:
        radial-gradient(130% 70% at 50% -10%, #2A63B8 0%, rgba(31, 78, 158, 0.55) 32%, transparent 62%),
        radial-gradient(90% 60% at 50% 115%, rgba(24, 88, 152, 0.55) 0%, transparent 60%),
        linear-gradient(180deg, var(--atp-call-deep) 0%, var(--atp-call-night) 70%);
    animation: atp-call-rise 320ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* The route line: a dashed road winding behind the content, the one detail that says "logistics". */
.atp-call__sheet::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: 0.16;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 800' preserveAspectRatio='none'%3E%3Cpath d='M-20 690 C 90 640, 60 520, 170 470 S 330 400, 300 280 S 150 140, 260 60 S 400 -10, 430 -20' fill='none' stroke='%23C9D8EC' stroke-width='3' stroke-dasharray='2 14' stroke-linecap='round'/%3E%3C/svg%3E");
    background-size: 100% 100%;
    pointer-events: none;
}

.atp-call__glow {
    position: absolute;
    left: 50%;
    top: 30%;
    width: 120%;
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    z-index: -1;
    background: radial-gradient(circle, rgba(76, 147, 214, 0.28) 0%, transparent 55%);
    pointer-events: none;
}

.atp-call__sheet--missed .atp-call__glow { background: radial-gradient(circle, rgba(242, 180, 65, 0.2) 0%, transparent 55%); }
.atp-call__sheet--alert .atp-call__glow { background: radial-gradient(circle, rgba(211, 59, 59, 0.24) 0%, transparent 55%); }

.atp-call__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
}

.atp-call__order {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: var(--atp-radius-pill);
    background: var(--atp-call-glass);
    font-family: var(--atp-font-mono);
    font-size: 13px;
    letter-spacing: 0.02em;
    color: var(--atp-call-ink-soft);
}

.atp-call__min {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: var(--atp-call-glass);
    color: var(--atp-call-ink);
    cursor: pointer;
}

.atp-call__min:hover { background: var(--atp-call-glass-strong); }

/* ------------------------------------------------------------------ who */

.atp-call__who {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    padding: 12px 0 8px;
}

.atp-call__avatar {
    position: relative;
    display: grid;
    place-items: center;
    width: 132px;
    height: 132px;
    margin-bottom: 18px;
}

.atp-call__face {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 112px;
    height: 112px;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(160deg, #F4F7FB 0%, #C9D8EC 100%);
    color: var(--atp-navy);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.9), 0 18px 40px rgba(0, 0, 0, 0.35);
}

.atp-call__face img { width: 100%; height: 100%; object-fit: cover; }
.atp-call__face--dispatch { background: #FFFFFF; }
.atp-call__face--dispatch img { width: 68%; height: 68%; object-fit: contain; }

.atp-call__ring {
    position: absolute;
    inset: 10px;
    border-radius: 50%;
    border: 2px solid var(--atp-call-ring);
    opacity: 0;
}

.atp-call__avatar.is-ringing .atp-call__ring { animation: atp-call-beacon 2.4s cubic-bezier(0.2, 0.6, 0.3, 1) infinite; }
.atp-call__avatar.is-ringing .atp-call__ring--2 { animation-delay: 0.8s; }
.atp-call__avatar.is-ringing .atp-call__ring--3 { animation-delay: 1.6s; }
.atp-call__avatar.is-live .atp-call__face { animation: atp-call-breathe 3.2s ease-in-out infinite; }

.atp-call__sheet--missed .atp-call__face { box-shadow: 0 0 0 4px var(--atp-call-amber), 0 18px 40px rgba(0, 0, 0, 0.35); }
.atp-call__sheet--alert .atp-call__face { box-shadow: 0 0 0 4px var(--atp-call-decline), 0 18px 40px rgba(0, 0, 0, 0.35); }

.atp-call__name {
    margin: 0;
    font-size: clamp(26px, 2.2vw, 34px);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.01em;
    color: var(--atp-call-ink);
}

.atp-call__party {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--atp-call-ink-faint);
}

.atp-call__status {
    margin: 6px 0 0;
    font-size: 18px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    color: var(--atp-call-ink-soft);
    min-height: 1.4em;
}

.atp-call__status.is-warn { color: var(--atp-call-amber); }

.atp-call__quality {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    padding: 5px 12px;
    border-radius: var(--atp-radius-pill);
    background: var(--atp-call-glass);
    font-size: 13px;
    font-weight: 500;
    color: var(--atp-call-ink-soft);
}

.atp-call__quality--good { color: #8FE3B4; }
.atp-call__quality--fair, .atp-call__quality--muted { color: var(--atp-call-amber); }
.atp-call__quality--poor { color: #FF9C9C; }

/* No sound on a connected call: an amber card on the night surface, so it reads as "something is wrong with the
   sound" without looking like the call failed. Fluid: it takes the width of the sheet. */
.atp-call__silence {
    display: grid;
    gap: 8px;
    width: 100%;
    margin-top: 12px;
    padding: 0 4%;
}

.atp-call__silence-card {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid rgba(242, 180, 65, 0.45);
    border-radius: var(--atp-radius-lg);
    background: rgba(242, 180, 65, 0.12);
    color: var(--atp-call-ink);
    font-size: 14px;
    line-height: 1.45;
    text-align: left;
}

.atp-call__silence-card--theirs { display: flex; align-items: flex-start; gap: 8px; }
.atp-call__silence-card .atp-call-ico { flex: none; color: var(--atp-call-amber); }

.atp-call__silence-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: 600;
}

.atp-call__silence-body { margin: 0; color: var(--atp-call-ink-soft); }

.atp-call__silence-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
    gap: 8px;
    margin-top: 4px;
}

.atp-call__pillbtn--small { min-height: 44px; padding: 0 14px; font-size: 14px; }

/* ------------------------------------------------------------------ controls */

.atp-call__controls {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    justify-items: center;
    align-items: start;
    gap: 12px;
    padding: 18px 4% 6px;
}

.atp-call__controls--incoming { padding-left: 10%; padding-right: 10%; }

.atp-call__ctl {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.atp-call__ctl-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--atp-call-ink-soft);
}

.atp-call__round {
    display: inline-grid;
    place-items: center;
    width: 72px;
    height: 72px;
    border: 0;
    border-radius: 50%;
    color: #FFFFFF;
    cursor: pointer;
    transition: transform 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
    -webkit-tap-highlight-color: transparent;
}

.atp-call__round:active { transform: scale(0.94); }
.atp-call__round:focus-visible, .atp-call__min:focus-visible, .atp-call__pillbtn:focus-visible { outline: 3px solid #7DB2E2; outline-offset: 3px; }

.atp-call__round--accept { background: var(--atp-call-accept); box-shadow: 0 10px 28px rgba(30, 158, 90, 0.45); animation: atp-call-answer 1.6s ease-out infinite; }
.atp-call__round--accept:hover { background: var(--atp-call-accept-hover); }
.atp-call__round--accept .atp-call-ico { animation: atp-call-wiggle 1.6s ease-in-out infinite; }
.atp-call__round--decline { background: var(--atp-call-decline); box-shadow: 0 10px 28px rgba(211, 59, 59, 0.4); }
.atp-call__round--decline:hover { background: var(--atp-call-decline-hover); }
.atp-call__round--soft { background: var(--atp-call-glass); backdrop-filter: blur(4px); }
.atp-call__round--soft:hover { background: var(--atp-call-glass-strong); }
.atp-call__round--soft.is-on { background: #FFFFFF; color: var(--atp-navy); }

/* ------------------------------------------------------------------ ended */

.atp-call__ended {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 6px 4% 0;
    text-align: center;
}

.atp-call__ended-body {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
    color: var(--atp-call-ink-soft);
}

.atp-call__ended-body--small { font-size: 13px; color: var(--atp-call-ink-faint); }

.atp-call__ended-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
    gap: 10px;
    width: 100%;
}

.atp-call__pillbtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 52px;
    padding: 0 20px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: var(--atp-radius-pill);
    background: transparent;
    color: var(--atp-call-ink);
    font: 600 16px/1 var(--atp-font-sans);
    cursor: pointer;
}

.atp-call__pillbtn:hover { background: var(--atp-call-glass); }
.atp-call__pillbtn--primary { border-color: transparent; background: var(--atp-call-accept); }
.atp-call__pillbtn--primary:hover { background: var(--atp-call-accept-hover); }

.atp-call__hint { margin: 0; font-size: 12px; color: var(--atp-call-ink-faint); }

.atp-call__privacy {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 18px 0 0;
    font-size: 12px;
    color: var(--atp-call-ink-faint);
    text-align: center;
}

/* Desk and laptop: the call is a tall card on the dimmed page, a fraction of the screen wide (fluid, no cap). */
@media (min-width: 768px) {
    .atp-call__sheet {
        width: 40%;
        min-width: 420px;
        height: auto;
        min-height: 78vh;
        padding: 22px 28px 22px;
        border-radius: 28px;
        box-shadow: 0 40px 120px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
    }
}

@media (min-width: 1600px) {
    .atp-call__sheet { width: 32%; }
}

/* ------------------------------------------------------------------ minimised pill */

.atp-call-pill {
    position: fixed;
    z-index: var(--atp-call-z);
    /* Above the bottom tab bar, clear of the app bar's logo and bell. */
    bottom: calc(var(--atp-safe-bottom) + 84px);
    left: 50%;
    white-space: nowrap;
    max-width: calc(100% - 24px);
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 8px 0 14px;
    border: 0;
    border-radius: var(--atp-radius-pill);
    background: var(--atp-call-accept);
    color: #FFFFFF;
    font: 600 14px/1 var(--atp-font-sans);
    box-shadow: 0 10px 30px rgba(9, 40, 22, 0.35);
    cursor: pointer;
    animation: atp-call-drop 260ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.atp-call-pill.is-weak { background: #B9770E; }
.atp-call-pill__dot { width: 8px; height: 8px; border-radius: 50%; background: #FFFFFF; animation: atp-call-blink 1.2s ease-in-out infinite; }
.atp-call-pill__name { overflow: hidden; text-overflow: ellipsis; }
.atp-call-pill__time { font-variant-numeric: tabular-nums; opacity: 0.92; }
.atp-call-pill__go { padding: 8px 12px; border-radius: var(--atp-radius-pill); background: rgba(255, 255, 255, 0.18); }

/* ------------------------------------------------------------------ call buttons on the order screens */

.atp-call-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
    gap: 10px;
    width: 100%;
}

.atp-call-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 52px;
    text-align: left;
    cursor: pointer;
}

.atp-call-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.atp-call-btn--client {
    padding: 8px 14px;
    border: 1px solid var(--atp-border);
    border-radius: var(--atp-radius-btn);
    background: var(--atp-surface);
    color: var(--atp-heading-ink);
    font: 600 15px/1.2 var(--atp-font-sans);
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

.atp-call-btn--client:hover:not(:disabled) { border-color: var(--atp-success); box-shadow: 0 0 0 3px var(--atp-success-soft); }

.atp-call-btn__ico {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--atp-success);
    color: #FFFFFF;
}

.atp-call-btn__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.atp-call-btn__label { font-weight: 600; }
.atp-call-btn__sub { font-size: 12px; font-weight: 500; color: var(--atp-text-muted); }

.atp-call-btn--carrier { justify-content: flex-start; }

.atp-call-headbtn { color: var(--atp-success); }
.atp-call-headbtn:disabled { opacity: 0.5; }

/* ------------------------------------------------------------------ call rows in a conversation */

.atp-call-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 10px;
    align-self: center;
    margin: 6px auto;
    padding: 8px 14px;
    border-radius: var(--atp-radius-pill);
    background: var(--atp-surface);
    border: 1px solid var(--atp-border);
    font: 500 13px/1.3 var(--atp-font-sans);
    color: var(--atp-text);
}

.atp-call-row__ico { display: inline-grid; place-items: center; color: var(--atp-success); }
.atp-call-row--missed .atp-call-row__ico, .atp-call-row--missed .atp-call-row__text { color: var(--atp-danger); }
.atp-call-row--quiet .atp-call-row__ico { color: var(--atp-text-muted); }
.atp-call-row__time { color: var(--atp-text-muted); font-variant-numeric: tabular-nums; }

.atp-call-row__back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 0 12px;
    border: 0;
    border-radius: var(--atp-radius-pill);
    background: var(--atp-success);
    color: #FFFFFF;
    font: 600 13px/1 var(--atp-font-sans);
    cursor: pointer;
}

.atp-call-row__back:disabled { opacity: 0.55; cursor: not-allowed; }

/* ------------------------------------------------------------------ deep link waiting state */

.atp-call-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-height: 60vh;
    color: var(--atp-heading-ink);
    font: 600 16px/1.3 var(--atp-font-sans);
}

.atp-call-link__pulse {
    display: inline-grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--atp-success);
    color: #FFFFFF;
    animation: atp-call-answer 1.6s ease-out infinite;
}

/* ------------------------------------------------------------------ motion */

@keyframes atp-call-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes atp-call-rise { from { opacity: 0; transform: translateY(24px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes atp-call-drop { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes atp-call-beacon {
    0% { opacity: 0.85; transform: scale(1); }
    100% { opacity: 0; transform: scale(2.1); }
}
@keyframes atp-call-breathe {
    0%, 100% { box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.9), 0 0 0 10px rgba(30, 158, 90, 0.0), 0 18px 40px rgba(0, 0, 0, 0.35); }
    50% { box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.9), 0 0 0 14px rgba(30, 158, 90, 0.28), 0 18px 40px rgba(0, 0, 0, 0.35); }
}
@keyframes atp-call-answer {
    0% { box-shadow: 0 0 0 0 rgba(30, 158, 90, 0.55), 0 10px 28px rgba(30, 158, 90, 0.45); }
    70% { box-shadow: 0 0 0 18px rgba(30, 158, 90, 0), 0 10px 28px rgba(30, 158, 90, 0.45); }
    100% { box-shadow: 0 0 0 0 rgba(30, 158, 90, 0), 0 10px 28px rgba(30, 158, 90, 0.45); }
}
@keyframes atp-call-wiggle {
    0%, 60%, 100% { transform: rotate(0); }
    66% { transform: rotate(-14deg); }
    74% { transform: rotate(12deg); }
    82% { transform: rotate(-8deg); }
    90% { transform: rotate(4deg); }
}
@keyframes atp-call-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

@media (prefers-reduced-motion: reduce) {
    .atp-call__veil, .atp-call__sheet, .atp-call-pill,
    .atp-call__avatar.is-ringing .atp-call__ring, .atp-call__avatar.is-live .atp-call__face,
    .atp-call__round--accept, .atp-call__round--accept .atp-call-ico, .atp-call-pill__dot, .atp-call-link__pulse {
        animation: none;
    }
    .atp-call__avatar.is-ringing .atp-call__ring--1 { opacity: 0.6; transform: scale(1.25); }
}
