/* ============================================================
   ARIA STREAMING UI — streaming.css
   Add to index.html: <link rel="stylesheet" href="style/streaming.css">
   ============================================================ */

/* ── Live reasoning panel (during <think> streaming) ──────── */
.thinkLivePanel {
  margin: 4px 12px 2px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg-inset);
  overflow: hidden;
  transition: opacity 0.3s;
}
.thinkLiveDone {
  opacity: 0.6;
}

.thinkLiveHeader {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-family: var(--font-sans);
  font-size: 8.5px;
  letter-spacing: 0.02em;
  color: var(--border);
  background: var(--bg-inset);
  user-select: none;
}
.thinkLiveDone .thinkLiveHeader {
  color: #333;
}

.thinkLiveDot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bg-card);
  flex-shrink: 0;
  transition: background 0.3s;
}
.thinkLiveDot.pulse {
  background: var(--accent);
  animation: thinkDotPulse 1s ease-in-out infinite;
}
.thinkLiveDot.done {
  background: var(--success);
  animation: none;
}
@keyframes thinkDotPulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    transform: scale(0.7);
  }
}

.thinkLiveSteps {
  display: flex;
  flex-direction: column;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.thinkLiveStep {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 5px 14px;
  border-top: 1px solid var(--bg);
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.2s, transform 0.2s;
}
.thinkLiveStepIn {
  opacity: 1 !important;
  transform: translateY(0) !important;
}

.thinkStepLabel {
  font-family: var(--font-sans);
  font-size: 7px;
  letter-spacing: 0.02em;
  color: var(--border);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 80px;
}
.thinkStepText {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--border);
  line-height: 1.5;
}

/* ── Sub-agent / tool step pill track ─────────────────────── */
.clawLiveStepBar {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 4px 12px;
}

.clawStepPill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--text-3);
  border-radius: 0 2px 2px 0;
  opacity: 0;
  transform: translateX(-5px);
  transition: opacity 0.18s, transform 0.18s;
}
.clawStepIn {
  opacity: 1 !important;
  transform: translateX(0) !important;
}
.clawStepDone {
  border-left-color: var(--success);
  color: var(--success-text);
}

.clawStepIcon {
  font-size: 12px;
  flex-shrink: 0;
}
.clawStepText {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.clawStepLink {
  flex: 1;
  color: var(--accent-text);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.clawStepLink:hover {
  text-decoration: underline;
  color: var(--accent-text);
}

/* ── Streaming answer body (blinking cursor while live) ────── */
.streamBody::after {
  content: "▋";
  color: var(--accent-text);
  animation: streamCursor 0.65s step-end infinite;
  font-size: 0.85em;
  margin-left: 1px;
}
@keyframes streamCursor {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* ── Final thinkBlock dropdown (rendered by renderMarkdown) ── */
.thinkBlock {
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg-inset);
  overflow: hidden;
}
.thinkBlock summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  user-select: none;
  font-family: var(--font-sans);
  font-size: 8.5px;
  letter-spacing: 0.02em;
  color: var(--border);
  background: var(--bg-inset);
  list-style: none;
  transition: background 0.15s, color 0.15s;
}
.thinkBlock summary:hover {
  background: var(--bg-inset);
  color: var(--accent-text);
}
.thinkBlock summary::-webkit-details-marker {
  display: none;
}
.thinkBlock[open] summary {
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
}
.thinkBlock summary::before {
  content: "◈";
  font-size: 10px;
  color: var(--border);
  flex-shrink: 0;
}
.thinkBlock[open] summary::before {
  color: var(--accent-text);
}

.thinkContent {
  padding: 10px 14px;
  font-family: var(--font-sans);
  font-size: 10.5px;
  color: var(--border);
  line-height: 1.65;
  white-space: pre-wrap;
  max-height: 340px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  word-break: break-word;
}
.thinkContent::-webkit-scrollbar {
  width: 3px;
}
.thinkContent::-webkit-scrollbar-thumb {
  background: var(--border);
}

/* ── Mark 1.5 streaming upgrades ───────────────────────────── */

/* Inline stream cursor span (used during token streaming) */
.streamCursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--red-core, var(--accent));
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: streamCursorBlink 0.6s step-end infinite;
}
@keyframes streamCursorBlink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* Thin indeterminate progress bar across top of think panel while reasoning */
.thinkLivePanel:not(.thinkLiveDone)::before {
  content: "";
  display: block;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--red-core, var(--accent)) 40%,
    var(--accent-text) 60%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: thinkProgressBar 1.4s linear infinite;
}
@keyframes thinkProgressBar {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* thinkLiveLabel class to target the text separately from the dot */
.thinkLiveLabel {
  color: var(--border);
  font-family: var(--font-sans);
  font-size: 8.5px;
  letter-spacing: 0.02em;
}
.thinkLiveDone .thinkLiveLabel {
  color: var(--success-text);
}

/* ── Mark 1.6 — live think text stream ─────────────────────── */

/* Scrollable raw thinking text — shows tokens arriving in real-time */
.thinkRawScroll {
  max-height: 120px;
  overflow-y: auto;
  padding: 6px 10px;
  margin: 4px 0;
  font-family: var(--font-mono, var(--font-mono-stack));
  font-size: 10px;
  color: rgba(255, 32, 64, 0.5);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  border-left: 1px solid rgba(255, 32, 64, 0.15);
  background: color-mix(in srgb, var(--bg-inset) 20%, transparent);
  transition: max-height 0.3s ease, opacity 0.3s;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 32, 64, 0.2) transparent;
}
.thinkRawScroll::-webkit-scrollbar {
  width: 3px;
}
.thinkRawScroll::-webkit-scrollbar-thumb {
  background: rgba(255, 32, 64, 0.2);
}

/* Thought count badge in the header */
.thinkLiveCount {
  font-family: var(--font-mono, monospace);
  font-size: 9px;
  color: rgba(255, 32, 64, 0.6);
  margin-left: auto;
  padding-left: 8px;
}

/* → thought pills (replaces [STEP N] pills) */
.thinkLiveStep {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 8px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.75);
  border-left: 1px solid rgba(255, 32, 64, 0.2);
  margin: 2px 0;
  line-height: 1.4;
}
.thinkArrow {
  color: var(--red-core, var(--accent-text));
  font-size: 11px;
  flex-shrink: 0;
  opacity: 0.8;
}
.thinkStepText {
  flex: 1;
  font-family: var(--font-mono, monospace);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thinkLiveStepIn {
  animation: thinkStepSlide 0.2s ease-out;
}
@keyframes thinkStepSlide {
  from {
    opacity: 0;
    transform: translateX(-6px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
