/* ============================================================================
   "Use it in your favourite AI" demo section.
   Auto-playing (gif-like) mock AI chats that reproduce four real Grok-connector
   demos of CoinLobster: a user question, a "Used CoinLobster connector" tool
   call, then a formatted assistant reply. Each has a one-line description and
   the section ends in a Connect CTA. Shared across the landing page, /connect
   and /grok.

   Built on the site-wide terminal tokens (--tt-*), so it inherits the brand
   blue surface, orange accent and mint/red numbers.
   ========================================================================== */

.aid {
    position: relative;
    max-width: 1160px;
    margin: 0 auto;
    padding: clamp(44px, 7vw, 84px) 20px clamp(40px, 6vw, 72px);
}
/* A designed backdrop so the section reads as a lit moment, not cards on flat
   blue: a warm glow above the grid, a cool one below it. */
.aid::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(60% 42% at 50% 6%, rgba(238,90,44,0.13), transparent 62%),
        radial-gradient(55% 45% at 80% 98%, rgba(47,177,230,0.09), transparent 60%);
    pointer-events: none;
    z-index: 0;
}
.aid > * { position: relative; z-index: 1; }

.aid-head {
    text-align: center;
    max-width: 660px;
    margin: 0 auto clamp(30px, 4vw, 48px);
}
.aid-h2 {
    font-family: var(--tt-display, 'Bricolage Grotesque', system-ui, sans-serif);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.04;
    font-size: clamp(1.8rem, 4.4vw, 2.8rem);
    color: var(--tt-text, #FFF6EA);
    margin: 0 0 13px;
    text-wrap: balance;
}
.aid-sub {
    font-size: clamp(0.96rem, 1.6vw, 1.08rem);
    line-height: 1.5;
    color: var(--tt-text-muted, #A9C2D6);
    margin: 0;
    text-wrap: balance;
}

/* Two columns when there is room, one when there is not. auto-fit + minmax
   responds to the ACTUAL width the grid is given, not the viewport, so the
   section drops to one column inside the narrower /connect and /grok columns
   even on a wide screen. min(100%, 430px) keeps one column from overflowing. */
.aid-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 430px), 1fr));
    gap: clamp(18px, 2.4vw, 28px);
    /* stretch (the grid default) so cells in a row share the tallest height;
       combined with the flex-grow below, the two windows in a row are exactly
       the same size and their captions line up. */
}

.aid-cell { display: flex; flex-direction: column; }
/* The chat panel grows to fill the equalized cell, so a shorter reply keeps
   the window the same size as its neighbour with room at the bottom, rather
   than leaving a ragged edge. */
.aid-win { flex: 1 1 auto; }

/* ---- the chat window ---- */
.aid-win {
    position: relative;
    background: var(--tt-panel-grad, linear-gradient(160deg, #103756 0%, #0D3152 100%));
    border: 1px solid var(--tt-border, rgba(255,246,234,0.12));
    border-radius: 16px;
    box-shadow: var(--tt-shadow, 0 8px 24px rgba(0,0,0,0.32)), 0 1px 0 rgba(255,255,255,0.04) inset;
    overflow: hidden;
    isolation: isolate;
}

/* window top bar: the assistant identity + the connected data source */
.aid-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 15px;
    border-bottom: 1px solid var(--tt-border-soft, rgba(255,246,234,0.07));
    background: rgba(255,246,234,0.02);
}
.aid-who {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--tt-text-muted, #A9C2D6);
}
.aid-who-av {
    width: 19px; height: 19px; border-radius: 6px;
    display: grid; place-items: center;
    background: linear-gradient(150deg, #2FB1E6, #1E6FB0);
    color: #EAF7FF; font-size: 0.72rem;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.25);
}
.aid-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--tt-accent-text, #FF8A5C);
    background: rgba(238,90,44,0.12);
    border: 1px solid rgba(238,90,44,0.30);
    border-radius: 999px;
    padding: 3px 9px 3px 8px;
    white-space: nowrap;
}
.aid-chip-live {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--tt-up, #37D98A);
    box-shadow: 0 0 0 0 rgba(55,217,138,0.5);
    animation: aid-live 2.4s var(--tt-ease-out, ease) infinite;
}

/* the conversation body */
.aid-body { padding: 15px 16px 17px; }

/* ---- user question, a right-aligned chat bubble ---- */
.aid-u {
    max-width: 88%;
    margin-left: auto;
    margin-bottom: 13px;
    background: rgba(238,90,44,0.13);
    border: 1px solid rgba(238,90,44,0.24);
    border-radius: 13px 13px 4px 13px;
    padding: 9px 13px;
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--tt-text, #FFF6EA);
}
.aid-caret {
    display: inline-block;
    width: 2px; height: 1.05em;
    transform: translateY(2px);
    margin-left: 1px;
    background: var(--tt-accent, #EE5A2C);
    animation: aid-blink 1s steps(1) infinite;
}

/* ---- the "Used CoinLobster connector" tool call ---- */
.aid-tool {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 12px;
    padding: 4px 10px 4px 8px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--tt-text-muted, #A9C2D6);
    background: rgba(255,246,234,0.04);
    border: 1px solid var(--tt-border-soft, rgba(255,246,234,0.07));
    border-radius: 999px;
}
.aid-tool i { font-size: 0.8rem; color: var(--tt-accent-text, #FF8A5C); }
.aid-tool-dots { display: inline-flex; gap: 3px; margin-left: 1px; }
.aid-tool-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--tt-accent, #EE5A2C); animation: aid-pulse 1.1s var(--tt-ease-out, ease) infinite; }
.aid-tool-dots i:nth-child(2) { animation-delay: 0.16s; }
.aid-tool-dots i:nth-child(3) { animation-delay: 0.32s; }

/* ---- the assistant reply, formatted like an AI's markdown ---- */
.aid-a { font-size: 0.86rem; line-height: 1.5; color: var(--tt-text, #FFF6EA); }
.aid-lead { margin: 0 0 12px; color: var(--tt-text, #FFF6EA); }
.aid-lead b { font-weight: 700; }
.aid-sec { margin: 0 0 11px; }
.aid-sec:last-child { margin-bottom: 0; }
.aid-h {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--tt-text, #FFF6EA);
    margin: 0 0 6px;
    letter-spacing: 0.005em;
}
.aid-b { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.aid-b li {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    padding-left: 15px;
    font-size: 0.83rem;
    color: var(--tt-text-muted, #A9C2D6);
}
.aid-b li::before {
    content: "";
    position: absolute;
    left: 3px; top: 0.62em;
    width: 4px; height: 4px; border-radius: 50%;
    background: var(--tt-text-dim, #6E8CA3);
}
.aid-k { color: var(--tt-text, #FFF6EA); font-weight: 600; flex: 0 1 auto; }
.aid-k .aid-sub-note { color: var(--tt-text-muted, #A9C2D6); font-weight: 500; }
.aid-v {
    font-family: var(--tt-mono, 'JetBrains Mono', ui-monospace, monospace);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    flex: 0 0 auto;
    white-space: nowrap;
    letter-spacing: -0.01em;
}
.aid-v .aid-sub-note { font-family: var(--tt-sans, inherit); font-weight: 500; color: var(--tt-text-muted, #A9C2D6); }
.aid-up { color: var(--tt-up, #37D98A); }
.aid-down { color: var(--tt-down-text, #FF7E8E); }
.aid-neutral { color: var(--tt-text, #FFF6EA); }
.aid-addr { color: var(--tt-wallet, #A78BFA); font-family: var(--tt-mono, monospace); font-weight: 700; }
.aid-tag-row { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 15px; position: relative; }
.aid-tag-row::before { content: ""; position: absolute; left: 3px; top: 0.5em; width: 4px; height: 4px; border-radius: 50%; background: var(--tt-text-dim, #6E8CA3); }
.aid-tag {
    font-family: var(--tt-mono, monospace);
    font-size: 0.74rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--tt-down-soft, rgba(250,87,114,0.13));
    border: 1px solid rgba(250,87,114,0.28);
    color: var(--tt-down-text, #FF7E8E);
}
.aid-foot-line { margin: 11px 0 0; font-size: 0.76rem; color: var(--tt-text-dim, #6E8CA3); font-style: italic; }

/* ---- the per-window caption ---- */
.aid-cap { padding: 15px 4px 2px; }
.aid-cap-t { font-size: 1.04rem; font-weight: 700; letter-spacing: -0.01em; color: var(--tt-text, #FFF6EA); margin: 0 0 4px; }
.aid-cap-d { font-size: 0.87rem; line-height: 1.45; color: var(--tt-text-muted, #A9C2D6); margin: 0; text-wrap: pretty; }

/* ---- footer CTA ---- */
.aid-foot { text-align: center; margin-top: clamp(32px, 4.5vw, 52px); }
.aid-cta {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #1A0C06;
    background: var(--tt-accent, #EE5A2C);
    border: 1px solid rgba(0,0,0,0.15);
    border-radius: 12px;
    padding: 14px 26px;
    text-decoration: none;
    box-shadow: 0 10px 24px rgba(238,90,44,0.30), inset 0 1px 0 rgba(255,255,255,0.22);
    transition: transform 0.18s var(--tt-ease-out, ease), box-shadow 0.18s var(--tt-ease-out, ease);
}
.aid-cta i { font-size: 1.15rem; transition: transform 0.18s var(--tt-ease-out, ease); }
.aid-cta:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(238,90,44,0.38), inset 0 1px 0 rgba(255,255,255,0.22); }
.aid-cta:hover i { transform: translateX(3px); }
.aid-cta:focus-visible { outline: 3px solid var(--tt-sky, #2FB1E6); outline-offset: 3px; }
.aid-foot-note { margin: 12px 0 0; font-size: 0.83rem; color: var(--tt-text-muted, #A9C2D6); }

/* ---- staggered reveal: the reply arrives after the tool call ----
   Guarded by .aid-js so no-JS and SEO get the full transcript statically. */
.aid-js .aid-tool { opacity: 0; }
.aid-js .aid-win.is-working .aid-tool,
.aid-js .aid-win.is-answering .aid-tool { opacity: 1; transition: opacity 0.3s var(--tt-ease-out, ease); }
.aid-js .aid-win.is-answering .aid-tool-dots { display: none; }

.aid-js .aid-lead, .aid-js .aid-sec {
    opacity: 0;
    transform: translateY(7px);
    filter: blur(3px);
}
.aid-js .aid-win.is-answering .aid-lead,
.aid-js .aid-win.is-answering .aid-sec {
    opacity: 1;
    transform: none;
    filter: none;
    transition: opacity 0.5s var(--tt-ease-out, cubic-bezier(0.22,1,0.36,1)),
                transform 0.5s var(--tt-ease-out, cubic-bezier(0.22,1,0.36,1)),
                filter 0.5s var(--tt-ease-out, cubic-bezier(0.22,1,0.36,1));
    transition-delay: calc(var(--i, 0) * 95ms);
}

/* ---- keyframes ---- */
@keyframes aid-blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }
@keyframes aid-pulse { 0%, 100% { opacity: 0.35; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1); } }
@keyframes aid-live { 0% { box-shadow: 0 0 0 0 rgba(55,217,138,0.5); } 70% { box-shadow: 0 0 0 6px rgba(55,217,138,0); } 100% { box-shadow: 0 0 0 0 rgba(55,217,138,0); } }

/* ---- reduced motion: show the finished transcript, no typing, no loop ---- */
@media (prefers-reduced-motion: reduce) {
    .aid-caret { display: none; }
    .aid-chip-live { animation: none; }
    .aid-tool-dots { display: none; }
    .aid-tool { opacity: 1 !important; }
    .aid-lead, .aid-sec {
        opacity: 1 !important;
        transform: none !important;
        filter: none !important;
        transition: none !important;
    }
    .aid-cta, .aid-cta i { transition: none; }
}
