/* ============================================================================
   DipSkip — "Watch a strategy trade itself" live demo card
   ----------------------------------------------------------------------------
   An animated showcase: a DipScript runs in a mini editor (coloured exactly
   like the in-app Monaco editor) while a price chart streams left-to-right and
   the engine drops real buy/sell markers (the same arrowUp "B" / arrowDown "S"
   the DipSkip charts use) and books a running P&L.

   Desktop layout first. Tokens mirror the app:
     editor  bg #0d1117 · fg #c9d1d9 · gutter #6e7681 · active #161b22
     syntax  keyword #d9b00d · cond/op #077ba6 · var #ba065d · ticker #13d4aa
             amount #e36505 · @-price #1fa30d · usd #0d6e0d · comment #008000
     chart   bg #0d1117 · grid #21262d · price line #58a6ff
             buy #2e7d32 · sell #c62828 · peak #FF9800
   ========================================================================== */
.live-demo {
    position: relative;
    padding: 5.5rem 0 5rem;
    background:
        radial-gradient(120% 80% at 50% -10%, rgba(99, 102, 241, 0.10), transparent 60%),
        var(--background);
    overflow: hidden;
}

.live-demo .section-header { margin-bottom: 2.5rem; }

.ld-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--primary-light);
    margin-bottom: 0.9rem;
}
.ld-eyebrow .ld-live-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #2e7d32;
    box-shadow: 0 0 0 0 rgba(46, 125, 50, 0.6);
    animation: ldPulse 1.8s infinite;
}
@keyframes ldPulse {
    0%   { box-shadow: 0 0 0 0 rgba(46, 125, 50, 0.55); }
    70%  { box-shadow: 0 0 0 7px rgba(46, 125, 50, 0); }
    100% { box-shadow: 0 0 0 0 rgba(46, 125, 50, 0); }
}

/* --- Stage: editor + chart side by side ---------------------------------- */
.ld-stage {
    display: grid;
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.18fr);
    gap: 1.5rem;
    align-items: stretch;
    max-width: 1180px;
    margin: 0 auto;
    /* glassy card frame with a subtle brand-gradient border */
    padding: 1.5rem;
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.55), rgba(15, 23, 42, 0.55));
    border: 1px solid rgba(148, 163, 184, 0.16);
    box-shadow: 0 40px 80px -40px rgba(0, 0, 0, 0.8),
                0 0 0 1px rgba(99, 102, 241, 0.05);
}

.ld-window {
    border: 1px solid var(--ld-border, #30363d);
    border-radius: 14px;
    background: #0d1117;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.9);
}

/* window title bar (shared by editor + chart) */
.ld-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 14px;
    background: #161b22;
    border-bottom: 1px solid #21262d;
    flex-shrink: 0;
}
.ld-dot { width: 11px; height: 11px; border-radius: 50%; }
.ld-dot.red    { background: #ff5f56; }
.ld-dot.yellow { background: #ffbd2e; }
.ld-dot.green  { background: #27c93f; }
.ld-filename {
    margin-left: 8px;
    font-family: 'JetBrains Mono', 'SF Mono', Monaco, monospace;
    font-size: 0.8rem;
    color: #8b949e;
}
.ld-runpill {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #3fb950;
    background: rgba(63, 185, 80, 0.12);
    border: 1px solid rgba(63, 185, 80, 0.25);
    padding: 3px 9px;
    border-radius: 999px;
}
.ld-runpill .fa-circle { font-size: 0.45rem; animation: ldBlink 1.4s infinite; }
@keyframes ldBlink { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ============================ EDITOR ===================================== */
.ld-editor .ld-code {
    position: relative;
    padding: 14px 0;
    font-family: 'JetBrains Mono', 'SF Mono', Monaco, 'Roboto Mono', monospace;
    font-size: 12.5px;
    line-height: 26px;
    color: #c9d1d9;
    flex: 1;
    overflow: hidden;
    counter-reset: none;
}
.ld-line {
    position: relative;
    height: 26px;
    display: flex;
    align-items: center;
    white-space: pre;
    z-index: 1;
}
.ld-line .ln {
    width: 38px;
    flex-shrink: 0;
    text-align: right;
    padding-right: 14px;
    color: #6e7681;
    user-select: none;
    font-variant-numeric: tabular-nums;
}
.ld-line .lc { padding-right: 14px; }

/* moving active-rule highlight */
.ld-hl {
    position: absolute;
    left: 0; right: 0;
    top: 0;
    height: 52px;             /* two lines; JS positions it */
    border-left: 2px solid var(--primary-light);
    background: linear-gradient(90deg, rgba(139, 92, 246, 0.14), rgba(139, 92, 246, 0.02) 70%, transparent);
    opacity: 0;
    transform: translateY(0);
    transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, height 0.3s ease;
    z-index: 0;
    pointer-events: none;
}
.ld-hl.show { opacity: 1; }
.ld-hl.fire {
    background: linear-gradient(90deg, rgba(46, 125, 50, 0.28), rgba(46, 125, 50, 0.04) 70%, transparent);
    border-left-color: #3fb950;
}
.ld-hl.fire.sell {
    background: linear-gradient(90deg, rgba(198, 40, 40, 0.26), rgba(198, 40, 40, 0.04) 70%, transparent);
    border-left-color: #ff7b72;
}

/* DipScript syntax tokens — exact app colours */
.ld-code .k   { color: #d9b00d; }   /* keyword / command */
.ld-code .o   { color: #077ba6; }   /* condition / operator */
.ld-code .v   { color: #ba065d; }   /* $variable */
.ld-code .tk  { color: #13d4aa; }   /* ticker */
.ld-code .am  { color: #e36505; }   /* amount (ALL/MAX) */
.ld-code .at  { color: #1fa30d; }   /* @ */
.ld-code .usd { color: #2ea043; }   /* USD (brightened from #0d6e0d for dark bg) */
.ld-code .c   { color: #008000; font-style: italic; }  /* comment */
.ld-code .n   { color: #c9d1d9; }   /* number (default fg) */

/* ============================ CHART ===================================== */
.ld-chart { min-width: 0; }
.ld-chart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 12px 16px;
    border-bottom: 1px solid #21262d;
    background: #0d1117;
    flex-wrap: wrap;
}
.ld-quote { display: flex; align-items: baseline; gap: 10px; }
.ld-sym {
    font-weight: 800;
    font-size: 1rem;
    color: #f0f6fc;
    letter-spacing: 0.02em;
}
.ld-price {
    font-family: 'JetBrains Mono', Monaco, monospace;
    font-size: 1.05rem;
    font-weight: 700;
    color: #58a6ff;
    font-variant-numeric: tabular-nums;
}
.ld-chg {
    font-size: 0.82rem;
    font-weight: 600;
    color: #3fb950;
    font-variant-numeric: tabular-nums;
}
.ld-chg.down { color: #ff7b72; }

.ld-pos { display: flex; align-items: center; gap: 12px; }
.ld-pos-chip {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 4px 10px;
    border-radius: 6px;
    color: #8b949e;
    background: rgba(139, 148, 158, 0.12);
    border: 1px solid rgba(139, 148, 158, 0.25);
    transition: all 0.3s ease;
}
.ld-pos-chip.long {
    color: #3fb950;
    background: rgba(46, 125, 50, 0.14);
    border-color: rgba(46, 125, 50, 0.4);
}
.ld-pnl {
    font-family: 'JetBrains Mono', Monaco, monospace;
    font-size: 1.1rem;
    font-weight: 800;
    color: #3fb950;
    font-variant-numeric: tabular-nums;
    transition: transform 0.2s ease;
}
.ld-pnl.bump { transform: scale(1.12); }

/* the svg canvas */
.ld-canvas-wrap { position: relative; background: #0d1117; flex: 1; }
.ld-svg { display: block; width: 100%; height: auto; }

/* marker pop animation handled via inline opacity/transform from JS,
   but give them a transition */
.ld-marker { transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); transform-box: fill-box; transform-origin: center; }

/* floating order toast over the chart */
.ld-toast {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translate(-50%, -8px);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', Monaco, monospace;
    color: #fff;
    background: rgba(13, 17, 23, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.8);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 4;
    white-space: nowrap;
}
.ld-toast.show { opacity: 1; transform: translate(-50%, 0); }
.ld-toast .ld-toast-ic { font-size: 0.85rem; }
.ld-toast.buy  { border-color: rgba(46, 125, 50, 0.6); }
.ld-toast.buy  .ld-toast-ic { color: #3fb950; }
.ld-toast.sell { border-color: rgba(198, 40, 40, 0.6); }
.ld-toast.sell .ld-toast-ic { color: #ff7b72; }

.ld-disclaimer {
    text-align: center;
    margin: 1.6rem auto 0;
    max-width: 720px;
    font-size: 0.78rem;
    font-style: italic;
    color: var(--text-muted);
    opacity: 0.75;
}

/* ============================================================================
   RESPONSIVE
   ========================================================================== */
/* Tablet & down — stack the editor above the chart */
@media (max-width: 1024px) {
    .live-demo { padding: 4rem 0 3.5rem; }
    .ld-stage {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem;
        border-radius: 18px;
    }
}

/* Phone — compact chrome + soft-wrapped code */
@media (max-width: 560px) {
    .live-demo { padding: 3rem 0 2.5rem; }
    .live-demo .section-header { margin-bottom: 1.6rem; }
    .ld-stage { padding: 10px; gap: 12px; border-radius: 16px; }

    .ld-bar { height: 36px; padding: 0 12px; gap: 7px; }
    .ld-dot { width: 10px; height: 10px; }
    .ld-filename { font-size: 0.72rem; margin-left: 6px; }
    .ld-runpill { font-size: 0.66rem; padding: 2px 8px; }

    /* editor: smaller text, and let long DipScript lines soft-wrap with a
       hanging indent so nothing is ever cut off on a narrow screen */
    .ld-editor .ld-code { font-size: 11.5px; line-height: 22px; padding: 10px 0; }
    .ld-line { height: auto; min-height: 22px; align-items: flex-start; }
    .ld-line .ln {
        width: 30px;
        padding-right: 10px;
        line-height: 22px;
    }
    .ld-line .lc {
        flex: 1;
        min-width: 0;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
        padding-left: 14px;
        text-indent: -14px;
        padding-right: 10px;
    }

    /* chart header tightens */
    .ld-chart-head { padding: 10px 12px; gap: 6px 10px; }
    .ld-sym { font-size: 0.9rem; }
    .ld-price { font-size: 0.98rem; }
    .ld-chg { font-size: 0.76rem; }
    .ld-pos { gap: 8px; }
    .ld-pos-chip { font-size: 0.64rem; padding: 3px 8px; }
    .ld-pnl { font-size: 1rem; }

    .ld-toast { font-size: 0.7rem; padding: 7px 11px; top: 10px; gap: 6px; }
    .ld-disclaimer { font-size: 0.72rem; margin-top: 1.2rem; }
}
