/* ============================================================
   Throughline AI — shared DEMO skin
   Loads on top of ../styles.css (reuses palette + fonts).
   Gives the demos a coherent "product chrome" that's clearly
   distinct from the marketing site — and clearly a demo.
   ============================================================ */

.demo-body {
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--paper);
}

/* ---------- top bar ---------- */
.demo-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 56px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  flex: 0 0 auto;
}
.demo-back {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.demo-back .dot { color: var(--accent); }
.demo-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
}
.demo-title::before { content: "·"; margin-right: 0.7rem; color: var(--line); }
.demo-badge {
  margin-left: auto;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--warm);
  border: 1px solid color-mix(in srgb, var(--warm) 45%, var(--line));
  background: color-mix(in srgb, var(--warm) 8%, transparent);
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- app shell ---------- */
.demo-app {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 0;
}

/* ---------- sources sidebar ---------- */
.demo-sources {
  border-right: 1px solid var(--line);
  background: var(--paper-2);
  padding: 1.2rem 1.1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.demo-aside-head {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  margin: 0 0 0.9rem;
}
.source-list { list-style: none; margin: 0; padding: 0; }
.source {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.65rem;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease;
}
.source .dot-live {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  margin-top: 0.42rem;
  flex: 0 0 auto;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent);
}
.source-name { font-weight: 600; font-size: 0.92rem; line-height: 1.3; }
.source-meta { font-size: 0.78rem; color: var(--muted); }
.source.active {
  background: #fffdf8;
  border-color: var(--accent);
}
.source.active .dot-live { animation: pulse 1s ease infinite; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
  70%  { box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent); }
}
.demo-aside-note {
  margin-top: auto;
  padding-top: 1.2rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}

/* ---------- chat column ---------- */
.demo-chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.demo-stream {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1.6rem clamp(1rem, 4vw, 2.4rem);
  scroll-behavior: smooth;
}
.stream-inner { max-width: 720px; margin: 0 auto; }

/* messages */
.msg { margin-bottom: 1.4rem; animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble {
  background: var(--accent);
  color: #fff;
  padding: 0.7rem 1rem;
  border-radius: 14px 14px 4px 14px;
  max-width: 80%;
  font-size: 0.98rem;
}
.msg.bot .who {
  font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--accent); font-weight: 700; margin-bottom: 0.45rem;
}
.bot-answer { font-size: 1.04rem; line-height: 1.6; }
.bot-answer strong { font-family: var(--serif); font-weight: 600; }

/* word-reveal */
.rw { opacity: 0; animation: rw .26s ease forwards; }
@keyframes rw { to { opacity: 1; } }

/* citation chip */
sup.cite {
  cursor: pointer;
  font-size: 0.66em;
  font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 4px;
  padding: 0.05em 0.32em;
  margin: 0 0.06em;
  vertical-align: super;
  line-height: 1;
}
sup.cite:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }

/* searching indicator */
.searching {
  display: inline-flex; align-items: center; gap: 0.55rem;
  color: var(--muted); font-size: 0.95rem;
}
.searching .dots { display: inline-flex; gap: 4px; }
.searching .dots i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--muted);
  animation: blink 1.1s infinite both;
}
.searching .dots i:nth-child(2) { animation-delay: .18s; }
.searching .dots i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* sources-used block */
.sources-used {
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
  opacity: 0;
  animation: rw .4s ease forwards;
}
.sources-used h4 {
  font-family: var(--sans);
  font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; margin: 0 0 0.7rem;
}
.src-card {
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.6rem;
  font-size: 0.9rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.1rem 0.7rem;
}
.src-card .n {
  grid-row: span 2;
  font-weight: 700; color: var(--accent);
  font-size: 0.8rem;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 5px;
  width: 1.5rem; height: 1.5rem;
  display: flex; align-items: center; justify-content: center;
}
.src-card .src-loc { font-weight: 600; font-size: 0.82rem; }
.src-card .src-loc .sec { color: var(--muted); font-weight: 400; }
.src-card .src-text { color: var(--muted); line-height: 1.45; }
.src-card.flash { animation: flash 1.1s ease; }
@keyframes flash {
  0%, 100% { border-color: var(--line); }
  30% { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, #fffdf8); }
}

/* ---------- compose ---------- */
.demo-compose {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  padding: 0.9rem clamp(1rem, 4vw, 2.4rem) 1.1rem;
  background: var(--paper);
}
.compose-inner { max-width: 720px; margin: 0 auto; }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.7rem; }
.chip {
  font-size: 0.85rem;
  color: var(--ink);
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
#askForm { display: flex; gap: 0.6rem; }
#askInput {
  flex: 1 1 auto;
  font-family: var(--sans); font-size: 1rem;
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fffdf8; color: var(--ink);
}
#askInput:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
#askForm button {
  font-family: var(--sans); font-weight: 600; font-size: 0.98rem;
  padding: 0.7rem 1.3rem;
  background: var(--accent); color: #fff;
  border: 1px solid transparent; border-radius: 8px; cursor: pointer;
}
#askForm button:hover { background: var(--accent-ink); }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .demo-app { grid-template-columns: 1fr; }
  .demo-sources {
    border-right: 0; border-bottom: 1px solid var(--line);
    max-height: 132px; flex-direction: row; flex-wrap: nowrap;
    overflow-x: auto; gap: 0.6rem; align-items: stretch;
  }
  .demo-aside-head, .demo-aside-note { display: none; }
  .source-list { display: flex; gap: 0.5rem; }
  .source { white-space: nowrap; }
  .demo-title { display: none; }
}
