/* ========================================================
   ConnexaAI Demo Page — Styles & Animations
   ======================================================== */

/* ---- Easing Tokens ---- */
:root {
    --ease-in-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-expo: cubic-bezier(0.7, 0, 0.84, 0);
    --accent: #506ef7;
    --bg: #0d1117;
    --surface: #161b22;
    --border-clr: #30363d;
    --muted: #8b949e;
}

/* ---- Global Progress Bar ---- */
#demo-progress-bar {
    position: fixed;
    top: 64px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--border-clr);
    z-index: 40;
    opacity: 0;
    transition: opacity 0.4s var(--ease-in-out-expo);
}

#demo-progress-bar.visible {
    opacity: 1;
}

#demo-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width 0.6s var(--ease-in-out-expo);
    box-shadow: 0 0 12px rgba(80, 110, 247, 0.35);
}

/* ---- Prompt Selector ---- */
#demo-entry {
    transition: opacity 0.5s var(--ease-out-expo), transform 0.5s var(--ease-out-expo);
}

#demo-entry.exiting {
    opacity: 0;
    transform: scale(0.96);
    pointer-events: none;
}

.demo-prompt-input {
    cursor: pointer;
    caret-color: transparent;
}

.demo-dropdown {
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity 0.3s var(--ease-in-out-expo), transform 0.3s var(--ease-in-out-expo);
}

.demo-dropdown.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.demo-dropdown-item {
    transition: background 0.15s ease, border-color 0.15s ease;
}

.demo-dropdown-item:hover {
    background: #1a1a1a;
    border-color: rgba(80, 110, 247, 0.25);
}

/* ---- Loading Container ---- */
#demo-loading {
    display: none;
    opacity: 0;
    transition: opacity 0.6s var(--ease-in-out-expo);
}

#demo-loading.active {
    display: block;
}

#demo-loading.visible {
    opacity: 1;
}

.step-indicator {
    transition: opacity 0.3s ease;
}

/* ---- Step 1: Understanding ---- */
.token-line {
    opacity: 0;
    transform: translateY(8px);
    animation: tokenFadeIn 0.4s var(--ease-in-out-expo) forwards;
}

@keyframes tokenFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--accent);
    margin-left: 4px;
    animation: cursorBlink 0.8s steps(2) infinite;
    vertical-align: text-bottom;
}

@keyframes cursorBlink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* ---- Step 2: Searching Sources ---- */
.source-counter {
    font-variant-numeric: tabular-nums;
}

.source-scroll-container {
    position: relative;
    height: 200px;
    overflow: hidden;
}

.source-scroll-container::before,
.source-scroll-container::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 48px;
    z-index: 2;
    pointer-events: none;
}

.source-scroll-container::before {
    top: 0;
    background: linear-gradient(to bottom, var(--bg), transparent);
}

.source-scroll-container::after {
    bottom: 0;
    background: linear-gradient(to top, var(--bg), transparent);
}

.source-scroll-inner {
    animation: sourceScroll 4s linear infinite;
}

@keyframes sourceScroll {
    0% {
        transform: translateY(0);
    }

    100% {
        transform: translateY(-50%);
    }
}

/* ---- Step 3: Analyzing Matches ---- */
.provider-tile {
    transition: opacity 0.5s var(--ease-in-out-expo), transform 0.5s var(--ease-in-out-expo), border-color 0.3s ease;
}

.provider-tile.eliminated {
    opacity: 0;
    transform: scale(0.85);
    pointer-events: none;
}

.provider-tile.finalist {
    border-color: rgba(80, 110, 247, 0.5);
}

.provider-tile.winner {
    border-color: var(--accent);
    box-shadow: 0 0 16px rgba(80, 110, 247, 0.15);
}

/* ---- Step 4: Scoring ---- */
.score-bar-track {
    background: var(--border-clr);
    height: 6px;
    position: relative;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 1s var(--ease-in-out-expo);
}

.composite-score {
    font-variant-numeric: tabular-nums;
}

/* ---- Step 5: Generating Report ---- */
.report-line {
    opacity: 0;
    transform: translateX(-12px);
    animation: reportLineIn 0.35s var(--ease-in-out-expo) forwards;
}

@keyframes reportLineIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ---- Results View ---- */
#demo-results {
    display: none;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.7s var(--ease-in-out-expo), transform 0.7s var(--ease-in-out-expo);
}

#demo-results.active {
    display: block;
}

#demo-results.visible {
    opacity: 1;
    transform: translateY(0);
}

.result-card {
    border: 1px solid var(--border-clr);
    background: var(--surface);
    transition: border-color 0.3s ease;
}

.result-card:hover {
    border-color: rgba(80, 110, 247, 0.25);
}

.result-score-bar-track {
    background: var(--border-clr);
    height: 8px;
    overflow: hidden;
}

.result-score-bar-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 1s var(--ease-in-out-expo);
}

.rank-badge {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--accent);
    color: var(--accent);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 14px;
    font-weight: 500;
    flex-shrink: 0;
}

/* ---- Expandable Section ---- */
.expandable-trigger {
    cursor: pointer;
    transition: color 0.2s ease;
}

.expandable-trigger:hover {
    color: #fff;
}

.expandable-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s var(--ease-in-out-expo);
}

.expandable-content.open {
    max-height: 600px;
}

.expandable-chevron {
    transition: transform 0.25s ease;
}

.expandable-content.open~.expandable-trigger .expandable-chevron,
.expandable-trigger.open .expandable-chevron {
    transform: rotate(180deg);
}

/* ---- Step Content Transitions ---- */
.step-content {
    display: none;
    opacity: 0;
    transition: opacity 0.5s var(--ease-in-out-expo);
}

.step-content.active {
    display: block;
}

.step-content.visible {
    opacity: 1;
}

/* ---- Mobile Responsiveness ---- */
@media (max-width: 768px) {
    .source-scroll-container {
        height: 140px;
    }

    .provider-tiles-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}