/* Flow demos — hero-style preview + terminal agent session */

.flow-demo {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 48px;
}

/* ---- Agent: interactive chat session ---- */

.flow-demo--agent .term-session {
  width: 100%;
}

.term-window {
  border: 1px solid var(--border);
  background: #070708;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  height: min(520px, 70vh);
}

.term-titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline);
  background: var(--panel);
  flex-shrink: 0;
}

.term-dot {
  width: 8px;
  height: 8px;
  background: var(--page-library);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--page-library) 22%, transparent);
}

.term-title {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--dim);
}

.term-mcp-badge {
  padding: 3px 8px;
  border: 1px solid color-mix(in srgb, var(--page-library) 40%, var(--border));
  background: color-mix(in srgb, var(--page-library) 10%, var(--void));
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--page-library);
}

.term-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 16px 10px 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--page-library) 45%, transparent) transparent;
}

.term-scroll::-webkit-scrollbar {
  width: 8px;
}

.term-scroll::-webkit-scrollbar-track {
  background: transparent;
  margin: 6px 0;
}

.term-scroll::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--page-library) 38%, #2a2a2e);
  border: 2px solid #070708;
  border-radius: 999px;
  background-clip: padding-box;
}

.term-scroll::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--page-library) 58%, #3a3a40);
  border: 2px solid #070708;
  background-clip: padding-box;
}

.term-turn,
.term-mcp,
.term-ref-card,
.term-taste,
.term-output {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 280ms ease, transform 280ms ease;
}

.term-turn[hidden],
.term-mcp[hidden],
.term-ref-card[hidden],
.term-taste[hidden],
.term-output[hidden] {
  display: none !important;
}

.term-turn.is-visible,
.term-mcp.is-visible,
.term-ref-card.is-visible,
.term-taste.is-visible,
.term-output.is-visible {
  opacity: 1;
  transform: none;
}

.term-turn {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 92%;
}

.term-turn--user {
  align-self: flex-end;
  align-items: flex-end;
}

.term-turn--agent {
  align-self: flex-start;
}

.term-role {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
}

.term-turn--user .term-role {
  color: var(--ink);
}

.term-turn--agent .term-role {
  color: var(--page-library);
}

.term-text {
  margin: 0;
  font-size: var(--fs-body);
  font-weight: 500;
  line-height: 1.55;
  color: var(--ink);
}

.term-turn--user .term-text {
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--page-library) 8%, var(--panel));
  border-color: color-mix(in srgb, var(--page-library) 28%, var(--hairline));
}

.term-turn--agent .term-text {
  padding: 2px 0;
}

.term-mcp {
  align-self: stretch;
  margin-left: 0;
  border: 1px solid color-mix(in srgb, var(--page-library) 35%, var(--hairline));
  background: color-mix(in srgb, var(--page-library) 6%, #070708);
  overflow: hidden;
}

.term-mcp-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--hairline);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--page-library);
}

.term-mcp-spin {
  width: 8px;
  height: 8px;
  border: 1.5px solid color-mix(in srgb, var(--page-library) 25%, transparent);
  border-top-color: var(--page-library);
  border-radius: 50%;
  flex-shrink: 0;
  opacity: 0;
}

.term-mcp.is-running .term-mcp-spin {
  opacity: 1;
  animation: term-spin 0.7s linear infinite;
}

.term-mcp.is-done .term-mcp-spin {
  opacity: 0;
}

.term-mcp-status {
  margin-left: auto;
  font-weight: 500;
  letter-spacing: 0.04em;
  font-size: 9px;
  text-transform: uppercase;
  color: var(--faint);
}

.term-mcp.is-running .term-mcp-status {
  color: var(--page-library);
}

.term-mcp.is-done .term-mcp-status {
  color: var(--green);
}

.term-mcp.is-running .term-mcp-status::before {
  content: "running";
}

.term-mcp.is-done .term-mcp-status::before {
  content: "done";
}

.term-mcp-icon {
  opacity: 0.7;
}

.term-mcp-body {
  margin: 0;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--code-str);
  white-space: pre-wrap;
}

.term-mcp-result {
  padding: 8px 10px;
  border-top: 1px solid var(--hairline);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--dim);
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  padding-top: 0;
  padding-bottom: 0;
  border-top-width: 0;
  transition: max-height 280ms ease, opacity 280ms ease, padding 280ms ease;
}

.term-mcp.is-done .term-mcp-result {
  max-height: 80px;
  opacity: 1;
  padding-top: 8px;
  padding-bottom: 8px;
  border-top-width: 1px;
}

@keyframes term-spin {
  to { transform: rotate(360deg); }
}

.term-ref-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: var(--panel);
}

.term-ref-thumb {
  width: 48px;
  height: 36px;
  flex-shrink: 0;
  border: 1px solid var(--hairline);
  background: linear-gradient(145deg, #141416, #0a0a0b);
  position: relative;
}

.term-ref-thumb--dark::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 22%;
  bottom: 0;
  background: #101012;
  border-right: 1px solid #29292c;
}

.term-ref-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.term-ref-meta strong {
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--ink);
}

.term-ref-meta span {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--faint);
}

.term-ref-pill {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--page-library);
  padding: 3px 6px;
  border: 1px solid color-mix(in srgb, var(--page-library) 35%, var(--border));
}

.term-taste {
  margin-left: 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--page-insights) 35%, var(--hairline));
  background: color-mix(in srgb, var(--page-insights) 8%, #070708);
}

.term-taste-head {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--page-insights);
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}

.term-taste-line {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.55;
  color: var(--dim);
}

.term-taste-line + .term-taste-line {
  margin-top: 6px;
}

.term-taste-line code {
  color: var(--page-insights);
  font-weight: 600;
}

.term-output {
  margin-left: 0;
  padding: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
}

.term-output-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 8px;
}

.term-output-ui {
  aspect-ratio: 16 / 9;
  max-height: 140px;
  background: #f5f5f7;
  border: 1px solid #e4e4e9;
  position: relative;
  overflow: hidden;
}

.term-output-ui::before {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 18%;
  height: 8px;
  background: #1b1e24;
  box-shadow: 0 16px 0 #0048ff, 0 32px 0 #e4e4e9;
}

.term-output-ui::after {
  content: "";
  position: absolute;
  left: 8%;
  width: 28%;
  bottom: 12%;
  height: 6px;
  background: #0048ff;
}

.term-typing {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.term-typing[hidden] {
  display: none !important;
}

.term-typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 16px;
}

.term-typing-dots i {
  width: 5px;
  height: 5px;
  background: var(--page-library);
  opacity: 0.35;
  animation: term-dot 1s ease infinite;
}

.term-typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.term-typing-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes term-dot {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

.term-compose {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--hairline);
  background: var(--panel);
  flex-shrink: 0;
  min-height: 48px;
}

.term-compose-prompt {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--page-library);
  flex-shrink: 0;
}

.term-compose-live {
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

.term-compose-live:not(:empty) + .term-compose-placeholder {
  display: none;
}

.term-compose-placeholder {
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--faint);
}

.term-compose-placeholder[hidden] {
  display: none !important;
}

.term-compose-send {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--faint);
  opacity: 0;
  transition: opacity 160ms ease;
}

.term-compose.is-sending .term-compose-send {
  opacity: 1;
  color: var(--page-library);
}

.term-compose.is-sending .term-compose-live::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 1.1em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--page-library);
  animation: term-caret 0.8s step-end infinite;
}

@keyframes term-caret {
  50% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .term-turn,
  .term-mcp,
  .term-ref-card,
  .term-taste,
  .term-output {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .term-mcp-spin,
  .term-typing-dots i,
  .term-compose.is-sending .term-compose-live::after {
    animation: none !important;
  }

  .term-scroll {
    scroll-behavior: auto;
  }
}
