/* ============================================================
   Talk Tools — Tool-Call Overlay System
   Slides contextual content (logos, badges, CTAs) onto the
   Talk page when the AI voice agent triggers a tool call.
   Depends on custom properties defined in talk.css.
   ============================================================ */

/* ----------------------------------------------------------
   1. Keyframe Animations
   ---------------------------------------------------------- */

@keyframes slide-in-right {
    0% {
        opacity: 0;
        transform: translateX(100%) scale(0.96);
    }
    60% {
        opacity: 1;
        transform: translateX(-2%) scale(1.005);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes slide-out-right {
    0% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateX(100%) scale(0.96);
    }
}

@keyframes overlay-item-enter {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(8px);
    }
    60% {
        opacity: 1;
        transform: scale(1.04) translateY(-2px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes overlay-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

@keyframes overlay-glow-pulse {
    0%, 100% {
        box-shadow:
            0 0 20px rgba(79, 143, 255, 0.08),
            0 8px 32px rgba(0, 0, 0, 0.3);
    }
    50% {
        box-shadow:
            0 0 30px rgba(79, 143, 255, 0.14),
            0 8px 40px rgba(0, 0, 0, 0.35);
    }
}


/* ----------------------------------------------------------
   2. .talk-overlay — Full container
   ---------------------------------------------------------- */

.talk-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 20;

    display: flex;
    align-items: center;
    justify-content: flex-end;

    width: 100%;
    max-width: 420px;
    padding: 24px 18px 24px 0;

    pointer-events: none;
    opacity: 0;
    transform: translateX(100%);
    transition:
        opacity 0.35s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.talk-overlay.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
    animation: slide-in-right 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.talk-overlay.exiting {
    animation: slide-out-right 0.35s cubic-bezier(0.55, 0, 1, 0.45) forwards;
    pointer-events: none;
}


/* ----------------------------------------------------------
   3. .talk-overlay-card — Glassmorphism card
   ---------------------------------------------------------- */

.talk-overlay-card {
    position: relative;
    width: 100%;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    overflow-x: hidden;

    padding: 28px 32px;
    border-radius: 20px;

    background:
        linear-gradient(
            135deg,
            rgba(15, 15, 45, 0.82) 0%,
            rgba(10, 10, 35, 0.78) 50%,
            rgba(20, 16, 50, 0.80) 100%
        );
    backdrop-filter: blur(22px) saturate(1.3);
    -webkit-backdrop-filter: blur(22px) saturate(1.3);

    border: 1px solid var(--talk-glass-border);
    box-shadow:
        0 0 0 1px rgba(79, 143, 255, 0.06),
        0 4px 24px rgba(0, 0, 0, 0.35),
        0 8px 48px rgba(79, 143, 255, 0.07),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);

    animation: overlay-glow-pulse 4s ease-in-out infinite;

    /* custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(79, 143, 255, 0.25) transparent;
}

.talk-overlay-card::-webkit-scrollbar {
    width: 5px;
}

.talk-overlay-card::-webkit-scrollbar-track {
    background: transparent;
}

.talk-overlay-card::-webkit-scrollbar-thumb {
    background: rgba(79, 143, 255, 0.25);
    border-radius: 10px;
}

.talk-overlay-card::-webkit-scrollbar-thumb:hover {
    background: rgba(79, 143, 255, 0.4);
}

/* subtle shimmer accent line along the top */
.talk-overlay-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20px;
    right: 20px;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(79, 143, 255, 0.5) 30%,
        rgba(160, 120, 255, 0.5) 70%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: overlay-shimmer 3s linear infinite;
    border-radius: 1px;
}


/* ----------------------------------------------------------
   4. .talk-overlay-header — Card header
   ---------------------------------------------------------- */

.talk-overlay-header {
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    position: relative;
}

.talk-overlay-header h3,
.talk-overlay-header .talk-overlay-title {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--talk-text-bright);
    margin: 0 0 4px 0;
    line-height: 1.3;
}

.talk-overlay-header p,
.talk-overlay-header .talk-overlay-subtitle {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--talk-text);
    margin: 0;
    line-height: 1.5;
}


/* ----------------------------------------------------------
   5. .talk-overlay-close — Close button (X)
   ---------------------------------------------------------- */

.talk-overlay-close {
    position: absolute;
    top: 24px;
    right: 24px;
    z-index: 2;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--talk-glass-border);
    border-radius: 50%;

    background: var(--talk-glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);

    color: var(--talk-text);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;

    transition:
        background var(--talk-transition),
        color var(--talk-transition),
        border-color var(--talk-transition),
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.talk-overlay-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--talk-text-bright);
    border-color: rgba(255, 255, 255, 0.22);
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 0 12px rgba(79, 143, 255, 0.15);
}

.talk-overlay-close:active {
    transform: scale(0.95) rotate(90deg);
}


/* ----------------------------------------------------------
   6. .talk-overlay-grid — Logo / Badge grid
   ---------------------------------------------------------- */

.talk-overlay-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.talk-overlay-grid.badges {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}


/* ----------------------------------------------------------
   7. .talk-overlay-item — Individual logo / badge card
   ---------------------------------------------------------- */

.talk-overlay-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;

    padding: 18px 12px;
    border-radius: 14px;

    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);

    cursor: default;
    transition:
        background var(--talk-transition),
        border-color var(--talk-transition),
        transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.25s ease;

    /* staggered entrance — JS or nth-child override */
    opacity: 0;
    animation: overlay-item-enter 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Staggered entrance delays via nth-child */
.talk-overlay-item:nth-child(1)  { animation-delay: 0.08s;  }
.talk-overlay-item:nth-child(2)  { animation-delay: 0.18s;  }
.talk-overlay-item:nth-child(3)  { animation-delay: 0.28s;  }
.talk-overlay-item:nth-child(4)  { animation-delay: 0.38s;  }
.talk-overlay-item:nth-child(5)  { animation-delay: 0.48s;  }
.talk-overlay-item:nth-child(6)  { animation-delay: 0.58s;  }
.talk-overlay-item:nth-child(7)  { animation-delay: 0.68s;  }
.talk-overlay-item:nth-child(8)  { animation-delay: 0.78s;  }
.talk-overlay-item:nth-child(9)  { animation-delay: 0.88s;  }
.talk-overlay-item:nth-child(10) { animation-delay: 0.98s;  }
.talk-overlay-item:nth-child(11) { animation-delay: 1.08s;  }
.talk-overlay-item:nth-child(12) { animation-delay: 1.18s;  }

.talk-overlay-item:hover {
    background: rgba(79, 143, 255, 0.08);
    border-color: rgba(79, 143, 255, 0.22);
    transform: translateY(-2px) scale(1.03);
    box-shadow:
        0 4px 20px rgba(79, 143, 255, 0.12),
        0 0 0 1px rgba(79, 143, 255, 0.08);
}


/* ----------------------------------------------------------
   8. .talk-overlay-item img — Logo images
   ---------------------------------------------------------- */

.talk-overlay-item img,
.talk-overlay-item svg {
    max-height: 48px;
    max-width: 100%;
    width: auto;
    object-fit: contain;
    filter: brightness(0.92) contrast(1.05);
    transition: filter var(--talk-transition);
}

.talk-overlay-item:hover img,
.talk-overlay-item:hover svg {
    filter: brightness(1.1) contrast(1.05);
}

.talk-overlay-item .talk-overlay-label {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--talk-text);
    text-align: center;
    line-height: 1.3;
    letter-spacing: 0.01em;
    transition: color var(--talk-transition);
}

.talk-overlay-item:hover .talk-overlay-label {
    color: var(--talk-text-bright);
}

/* Item label and description (used by JS tool implementations) */
.talk-overlay-item-label {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--talk-text-bright);
    text-align: center;
    line-height: 1.3;
    letter-spacing: 0.01em;
}

.talk-overlay-item-desc {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--talk-text);
    text-align: center;
    line-height: 1.3;
    letter-spacing: 0.01em;
}

/* Highlighted item (used by department solutions) */
.talk-overlay-item.highlighted {
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.25);
    box-shadow:
        0 0 16px rgba(99, 102, 241, 0.12),
        inset 0 0 0 1px rgba(99, 102, 241, 0.08);
}


/* ----------------------------------------------------------
   9. .talk-overlay-cta — Call-to-action button
   ---------------------------------------------------------- */

.talk-overlay-cta {
    display: block;
    width: 100%;
    padding: 14px 24px;
    margin-top: 8px;
    border: none;
    border-radius: 12px;

    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #060649;
    text-align: center;
    text-decoration: none;

    background: #fff;
    background-size: 200% 200%;
    cursor: pointer;
    position: relative;
    overflow: hidden;

    box-shadow:
        0 2px 16px rgba(255, 255, 255, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.1);

    transition:
        transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.25s ease,
        background-position 0.6s ease;
}

.talk-overlay-cta::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.12) 0%,
        transparent 50%
    );
    opacity: 0;
    transition: opacity 0.25s ease;
}

.talk-overlay-cta:hover {
    transform: translateY(-1px) scale(1.015);
    background-position: 100% 100%;
    box-shadow:
        0 4px 24px rgba(255, 255, 255, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.15);
}

.talk-overlay-cta:hover::before {
    opacity: 1;
}

.talk-overlay-cta:active {
    transform: translateY(0) scale(0.98);
}


/* ----------------------------------------------------------
   10. Utility: overlay backdrop (optional dim)
   ---------------------------------------------------------- */

.talk-overlay-backdrop {
    position: fixed;
    inset: 0;
    z-index: 19;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

.talk-overlay-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}


/* ----------------------------------------------------------
   11. Responsive — Mobile (≤ 640px)
   Bottom sheet instead of right panel
   ---------------------------------------------------------- */

@media (max-width: 640px) {
    .talk-overlay {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        max-width: 100%;
        width: 100%;
        padding: 0;
        align-items: flex-end;
        transform: translateY(100%);
    }

    .talk-overlay.active {
        transform: translateY(0);
        animation: slide-in-bottom 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    }

    .talk-overlay.exiting {
        animation: slide-out-bottom 0.3s cubic-bezier(0.55, 0, 1, 0.45) forwards;
    }

    .talk-overlay-card {
        border-radius: 20px 20px 0 0;
        padding: 22px 20px 28px;
        max-height: 75vh;

        /* pill handle for dragging */
        &::after {
            content: '';
            position: absolute;
            top: 8px;
            left: 50%;
            transform: translateX(-50%);
            width: 36px;
            height: 4px;
            border-radius: 2px;
            background: rgba(255, 255, 255, 0.18);
        }
    }

    .talk-overlay-header h3,
    .talk-overlay-header .talk-overlay-title {
        font-size: 1.1rem;
    }

    .talk-overlay-header p,
    .talk-overlay-header .talk-overlay-subtitle {
        font-size: 0.8rem;
    }

    .talk-overlay-grid {
        gap: 12px;
    }

    .talk-overlay-grid.badges {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .talk-overlay-item {
        padding: 14px 10px;
        border-radius: 12px;
    }

    .talk-overlay-item img,
    .talk-overlay-item svg {
        max-height: 36px;
    }

    .talk-overlay-item .talk-overlay-label {
        font-size: 0.72rem;
    }

    .talk-overlay-cta {
        padding: 12px 20px;
        font-size: 0.88rem;
        border-radius: 10px;
    }

    .talk-overlay-close {
        top: 18px;
        right: 18px;
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
}

/* Mobile-specific keyframes */
@keyframes slide-in-bottom {
    0% {
        opacity: 0;
        transform: translateY(100%);
    }
    60% {
        opacity: 1;
        transform: translateY(-2%);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-out-bottom {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(100%);
    }
}


/* ----------------------------------------------------------
   12. Reduced-motion preference
   ---------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .talk-overlay,
    .talk-overlay.active,
    .talk-overlay.exiting,
    .talk-overlay-item,
    .talk-overlay-cta,
    .talk-overlay-close {
        animation: none !important;
        transition-duration: 0.01s !important;
    }

    .talk-overlay-card {
        animation: none;
    }

    .talk-overlay-card::before {
        animation: none;
    }
}
