/* ============================================================
   HERO CLI — interactive context-graph console (synorb.com hero)
   Monochrome, inherits site tokens (--bg / --text / --line / fonts).
   Container sizing comes from index.html .hero-cli responsive rules;
   this styles the internal frame to fill that box.
   ============================================================ */

.hero-cli {
  --hcli-radius: 12px;
  --hcli-pad: clamp(0.9rem, 1.4vw, 1.25rem);
  --hcli-line: var(--line, rgba(0, 0, 0, 0.08));
  --hcli-line-strong: var(--line-strong, rgba(0, 0, 0, 0.12));
  pointer-events: auto;
}

.hcli-frame {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 360px;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--hcli-line-strong);
  border-radius: var(--hcli-radius);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--text);
  position: relative;
  transform-origin: 50% 42%;
}

.hcli-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14), 0 18px 45px rgba(0, 0, 0, 0.055);
}

[data-theme="dark"] .hcli-frame::before {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16), 0 18px 45px rgba(0, 0, 0, 0.32);
}

.hero-cli.animate .hcli-frame {
  animation: hcli-frame-wake 1.05s var(--ease-out-gentle, cubic-bezier(0.22, 0.61, 0.36, 1)) 0.78s both;
}

.hero-cli.animate .hcli-frame::before {
  animation: hcli-focus-glint 1.45s var(--ease-out-gentle, cubic-bezier(0.22, 0.61, 0.36, 1)) 1.02s both;
}

.hero-cli.animate .hcli-bar,
.hero-cli.animate .hcli-body,
.hero-cli.animate .hcli-input {
  animation: hcli-panel-settle 0.58s var(--ease-out-gentle, cubic-bezier(0.22, 0.61, 0.36, 1)) both;
}

.hero-cli.animate .hcli-bar { animation-delay: 1.02s; }
.hero-cli.animate .hcli-body { animation-delay: 1.1s; }
.hero-cli.animate .hcli-input { animation-delay: 1.18s; }

/* ---- title bar ---- */
.hcli-bar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: 0 0 auto;
  padding: 0.7rem var(--hcli-pad);
  border-bottom: 1px solid var(--hcli-line);
  background: var(--bg-subtle, #f0f0f0);
}

.hcli-dots {
  display: inline-flex;
  gap: 0.4rem;
}

.hcli-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--text);
  opacity: 0.2;
}

.hcli-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-left: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hcli-status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.625rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.hcli-status .hcli-led {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
}

.hcli-status.is-live {
  color: var(--text-secondary);
}

/* ---- transcript body ---- */
.hcli-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--hcli-pad);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--hcli-line-strong) transparent;
}

.hcli-body::-webkit-scrollbar {
  width: 7px;
}

.hcli-body::-webkit-scrollbar-thumb {
  background: var(--hcli-line-strong);
  border-radius: 99px;
}

.hcli-row {
  opacity: 0;
  transform: translateY(4px);
  animation: hcli-rise 0.34s var(--ease-out-gentle, cubic-bezier(0.22, 0.61, 0.36, 1)) forwards;
}

@keyframes hcli-rise {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes hcli-frame-wake {
  0% { transform: translateY(8px) scale(0.986); }
  62% { transform: translateY(-1px) scale(1.002); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes hcli-focus-glint {
  0% { opacity: 0; }
  26% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes hcli-panel-settle {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* user prompt line */
.hcli-prompt {
  color: var(--text);
}

.hcli-prompt .hcli-caret-mark {
  color: var(--text-tertiary);
  margin-right: 0.4rem;
}

/* agent text */
.hcli-say {
  color: var(--text-secondary);
}

.hcli-say,
.hcli-answer-text,
.hcli-answer-desc {
  overflow-wrap: anywhere;
}

.hcli-answer-row {
  margin-top: 0.15rem;
}

.hcli-answer {
  max-width: 100%;
  color: var(--text-secondary);
}

.hcli-answer-text {
  white-space: pre-wrap;
  line-height: 1.55;
}

.hcli-answer-lead {
  color: var(--text-secondary);
  line-height: 1.55;
}

.hcli-answer-kicker {
  margin-top: 0.45rem;
  color: var(--text);
  font-size: 0.72rem;
  line-height: 1.45;
}

.hcli-answer-list {
  display: grid;
  gap: 0;
  margin-top: 0.45rem;
  border-top: 1px solid var(--hcli-line);
}

.hcli-answer-item {
  display: grid;
  grid-template-columns: 1.25rem minmax(0, 1fr);
  gap: 0.55rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--hcli-line);
}

.hcli-answer-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.05rem;
  height: 1.05rem;
  border: 1px solid var(--hcli-line-strong);
  border-radius: 99px;
  color: var(--text-tertiary);
  font-size: 0.58rem;
  line-height: 1;
  margin-top: 0.08rem;
}

.hcli-answer-copy {
  min-width: 0;
}

.hcli-answer-name {
  color: var(--text);
  font-size: 0.75rem;
  line-height: 1.35;
}

.hcli-answer-desc {
  margin-top: 0.18rem;
  color: var(--text-secondary);
  font-size: 0.6875rem;
  line-height: 1.48;
}
/* tool activity chip */
.hcli-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  align-self: flex-start;
  max-width: 100%;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--hcli-line);
  border-radius: 99px;
  font-size: 0.6875rem;
  color: var(--text-secondary);
  background: var(--bg-subtle, #f0f0f0);
}

.hcli-chip .hcli-spin {
  width: 0.6rem;
  height: 0.6rem;
  border: 1.5px solid var(--text-tertiary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: hcli-spin 0.7s linear infinite;
  flex: 0 0 auto;
}

.hcli-chip.is-done .hcli-spin {
  border: none;
  width: auto;
  height: auto;
  animation: none;
}

.hcli-chip.is-zero { color: var(--text-tertiary); }

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

/* result list of streams */
.hcli-results {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-left: 0.85rem;
  border-left: 1px solid var(--hcli-line-strong);
}

.hcli-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.18rem 0.75rem;
}

.hcli-result-name {
  min-width: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

.hcli-result-meta {
  color: var(--text-tertiary);
  font-size: 0.6875rem;
  white-space: nowrap;
}

.hcli-result-detail {
  grid-column: 1 / -1;
  color: var(--text-tertiary);
  font-size: 0.65625rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

/* inline gate / suggestion card */
.hcli-card {
  border: 1px solid var(--hcli-line-strong);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.hcli-body.is-connect-mode {
  gap: 0.65rem;
}

.hcli-body.is-connect-mode .hcli-say {
  max-width: 95%;
}

.hcli-connect-card {
  margin-top: clamp(1.25rem, 5vh, 3.25rem);
  animation: hcli-connect-settle 0.48s var(--ease-out-gentle, cubic-bezier(0.22, 0.61, 0.36, 1)) both;
}

.hcli-card-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
}

.hcli-card-sub {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.hcli-card-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ---- provider chips + key input (connect step) ---- */
.hcli-providers {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.hcli-chip-btn {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  padding: 0.4rem 0.7rem;
  min-height: 2rem;
  border: 1px solid var(--hcli-line-strong);
  border-radius: 99px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.18s var(--ease-out-smooth, ease), border-color 0.18s var(--ease-out-smooth, ease), background 0.18s var(--ease-out-smooth, ease);
}

.hcli-chip-btn:hover { color: var(--text); border-color: var(--text-tertiary); }

.hcli-chip-btn.is-active {
  color: var(--bg);
  background: var(--text);
  border-color: var(--text);
}

.hcli-field {
  display: flex;
  gap: 0.4rem;
  width: 100%;
}

.hcli-field input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  min-height: 2.4rem;
  padding: 0 0.7rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--hcli-line-strong);
  border-radius: 6px;
  transition: border-color 0.18s var(--ease-out-smooth, ease);
}

.hcli-field input::placeholder { color: var(--text-tertiary); }
.hcli-field input:focus { outline: none; border-color: var(--text); }

.hcli-btn {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  min-height: 2.4rem;
  padding: 0 0.95rem;
  background: var(--text);
  color: var(--bg);
  border: 1px solid var(--text);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.18s var(--ease-out-smooth, ease), transform 0.18s var(--ease-out-smooth, ease);
}

.hcli-btn:hover { opacity: 0.85; transform: translateY(-1px); }
.hcli-btn:disabled { opacity: 0.4; cursor: default; transform: none; }

.hcli-btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--hcli-line-strong);
}
.hcli-btn-ghost:hover { color: var(--text); opacity: 1; }

.hcli-note {
  font-size: 0.625rem;
  color: var(--text-tertiary);
  line-height: 1.5;
}
.hcli-note a { color: var(--text-secondary); border-bottom: 1px solid var(--hcli-line-strong); }
.hcli-note a:hover { color: var(--text); }

.hcli-error { color: var(--text); }
.hcli-error::before { content: "! "; color: var(--text-tertiary); }

@keyframes hcli-connect-settle {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- input bar ---- */
.hcli-input {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.5rem;
  padding: 0.7rem var(--hcli-pad);
  border-top: 1px solid var(--hcli-line);
  background: var(--bg-subtle, #f0f0f0);
}

.hcli-input-caret {
  align-self: start;
  color: var(--text-tertiary);
  font-size: 0.875rem;
  line-height: 1.45;
  padding: 0.2rem 0;
}

.hcli-input textarea {
  width: 100%;
  min-width: 0;
  max-height: calc((1.45em * 3) + 0.4rem);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.45;
  background: transparent;
  color: var(--text);
  border: none;
  border-radius: 0;
  padding: 0.2rem 0;
  resize: none;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.hcli-input textarea::placeholder { color: var(--text-tertiary); }
.hcli-input textarea:focus { outline: none; }
.hcli-input textarea:disabled { color: var(--text-tertiary); }

.hcli-try {
  flex: 0 0 auto;
  align-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  padding: 0 0.72rem;
  border: 1px solid var(--text);
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: opacity 0.18s var(--ease-out-smooth, ease), transform 0.18s var(--ease-out-smooth, ease);
}
.hcli-try:hover { opacity: 0.85; transform: translateY(-1px); }

.hcli-send {
  flex: 0 0 auto;
  align-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  border: 1px solid var(--hcli-line-strong);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9rem;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.hcli-send:hover { color: var(--text); border-color: var(--text-tertiary); }

/* accessibility: visible focus */
.hcli-frame :focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.hero-cli-noscript {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

/* ---- mobile tuning ---- */
@media (max-width: 720px) {
  .hcli-frame { height: 100%; min-height: 0; max-height: 100%; font-size: 0.8125rem; }
  .hcli-providers {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.4rem;
  }
  /* bigger tap targets on touch */
  .hcli-chip-btn {
    width: 100%;
    min-width: 0;
    min-height: 2.75rem;
    padding: 0.55rem 0.2rem;
    text-align: center;
  }
  .hcli-result {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.18rem;
  }
  .hcli-result-meta { white-space: normal; }
  .hcli-btn, .hcli-field input { min-height: 2.75rem; }
  .hcli-field input { font-size: 16px; }
  .hcli-send { width: 2.75rem; height: 2.75rem; }
  .hcli-body.is-connect-mode { gap: 0.55rem; }
  .hcli-body.is-connect-mode .hcli-say { max-width: none; }
  .hcli-connect-card { margin-top: 0.75rem; }
  .hcli-input textarea { font-size: 16px; max-height: calc((1.45em * 4) + 0.4rem); } /* prevent iOS zoom on focus */
  .hcli-try { min-height: 2.75rem; padding: 0 0.68rem; font-size: 0.6875rem; }
}

@media (min-width: 1180px) {
  .hcli-frame { font-size: 0.84rem; }
}

/* respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .hcli-row { opacity: 1; transform: none; animation: none; }
  .hcli-spin { animation: none; }
  .hcli-frame::before { display: none; }
  .hero-cli.animate .hcli-frame,
  .hero-cli.animate .hcli-frame::before,
  .hero-cli.animate .hcli-bar,
  .hero-cli.animate .hcli-body,
  .hero-cli.animate .hcli-input,
  .hcli-connect-card {
    animation: none;
  }
}
