/* The kai terminal, in kai's Kassandra Dark colors (kai/cli/src/term.rs
   roles), the same in both site themes. */

.term {
  display: flex; flex-direction: column;
  min-width: 0;
  container-type: inline-size;
  border-radius: var(--radius-card);
  background: var(--term-bg);
  color: var(--term-text);
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.6;
  overflow: hidden;
  cursor: text;
}
.term-bar {
  display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 14px; flex: none;
  background: var(--term-bar);
  border-bottom: 1px solid #2a282a;
}
.term-bar span { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.25); }
.term-bar span:nth-child(1) { background: #FF5F57; }
.term-bar span:nth-child(2) { background: #FEBC2E; }
.term-bar span:nth-child(3) { background: #28C840; }
.term-bar em { margin: 0 auto; padding-right: 52px; font-style: normal; color: var(--term-faint); font-size: 12px; }
/* The scene kai opens on, Kassandra in glyphs (blocks/glyphs.rs GlyphArt):
   it fills the window under the banner until the session starts, then
   fades away, so the session's text never sits on glyphs. */
.term-main { position: relative; isolation: isolate; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.term-scene { position: absolute; inset: calc(32px + 4em) 0 8px; z-index: -1; pointer-events: none; transition: opacity 900ms var(--ease); }
.term-main.quiet .term-scene { opacity: 0; }
/* A terminal has a fixed number of columns: the text scales so 74 of them
   always fit, and lines never wrap mid-word. */
.term-body {
  flex: 1; min-height: 0;
  font-size: clamp(9.5px, calc((100cqi - 40px) / 44.4), 13.5px);
  padding: 24px 20px 8px;
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin; scrollbar-color: #3F3C3F transparent;
  /* What scrolls up out of the window fades under its bar. */
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 26px);
  mask-image: linear-gradient(to bottom, transparent, #000 26px);
}
/* The banner: kai's name, model and folder. */
.term-banner { margin-bottom: 0.8em; }
/* Its focus ring sits inside it: the window clips anything outside. */
.term-body:focus-visible { outline-offset: -2px; border-radius: 0; }
/* A line that wraps carries on under its text (--hang columns in), past
   its indent and mark (terminal.rs `hang`). */
.tl { white-space: pre; overflow: hidden; min-height: 1.6em; padding-left: calc(var(--hang, 0) * 1ch); text-indent: calc(var(--hang, 0) * -1ch); }
/* A phone-sized terminal wraps its lines instead of shrinking them. */
@container (max-width: 520px) {
  .term-body { font-size: 11.5px; padding: 14px 14px 6px; }
  .tl { white-space: pre-wrap; overflow-wrap: anywhere; }
  .term-input { padding-left: 14px; }
  /* The requests scroll sideways, fading at the edge so the cut reads as
     more to see. */
  .term-try {
    padding: 4px 28px 10px 14px;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 64px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 64px), transparent);
  }
}
.t-text { color: var(--term-text); }
.t-muted { color: var(--term-muted); }
.t-faint { color: var(--term-faint); }
.t-primary { color: var(--term-primary); }
.t-accent { color: var(--term-accent); }
.t-success { color: var(--term-success); }
.t-warning { color: var(--term-warning); }
.t-danger { color: var(--term-danger); }
.t-b { font-weight: 700; }
.t-i { font-style: italic; }

/* The input, under a rule as kai draws it, with its send button (a stop
   button while it works). */
.term-input {
  display: flex; align-items: center; gap: 12px; flex: none;
  /* The send button sits as far from the right edge as from the top and
     bottom. */
  padding: 12px 12px 12px 20px;
  border-top: 1px solid #2A282A;
  background: var(--term-bar);
  transition: border-color 150ms var(--ease);
}
.term-input:focus-within { border-top-color: color-mix(in srgb, var(--term-primary) 55%, #2A282A); }
.term-prompt { color: var(--term-primary); font-weight: 700; }
.term-input input {
  flex: 1; min-width: 0; padding: 6px 0;
  border: 0; outline: 0; background: transparent;
  color: var(--term-text); font: inherit;
  caret-color: var(--term-primary);
}
.term-input input::placeholder { color: var(--term-faint); }
.term-send {
  flex: none; display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--term-primary); color: var(--kblack);
  transition: background-color 150ms var(--ease), color 150ms var(--ease), box-shadow 150ms var(--ease), transform 150ms var(--ease);
}
.term-send:hover:not(:disabled) { transform: scale(1.06); }
.term-send:disabled { background: #2A282A; color: var(--term-faint); cursor: default; }
.term-send .ico { width: 16px; height: 16px; transform: rotate(-90deg); }
.term-send .square { display: none; width: 10px; height: 10px; border-radius: 2px; background: currentColor; }
.term-send.stop { background: transparent; color: var(--term-text); box-shadow: inset 0 0 0 1.5px var(--term-muted); }
.term-send.stop .ico { display: none; }
.term-send.stop .square { display: block; }
/* A phone zooms into a field whose text is under 16px. */
@media (pointer: coarse) { .term-input input { font-size: 16px; } }
/* Requests to try in one tap, over the input, lined up with the session's
   text. One that's been asked goes; undo comes once there's something to
   undo. */
.term-try { display: flex; gap: 8px; flex: none; padding: 4px 20px 12px; overflow-x: auto; scrollbar-width: none; transition: opacity 200ms var(--ease); }
.term-try::-webkit-scrollbar { display: none; }
.term-try.empty { display: none; }
.term-try.busy { opacity: 0.45; }
.term-try button {
  flex: none; padding: 6px 12px; border-radius: 999px;
  box-shadow: inset 0 0 0 1px #3A373A;
  color: var(--term-muted); font-family: var(--font-mono); font-size: 12px; white-space: nowrap;
  animation: chip-in 320ms var(--ease) backwards;
  transition: color 150ms var(--ease), box-shadow 150ms var(--ease), background-color 150ms var(--ease);
}
.term-try button:hover:not(:disabled), .term-try button:focus-visible { color: var(--term-text); box-shadow: inset 0 0 0 1px var(--term-primary); background: color-mix(in srgb, var(--klavender) 8%, transparent); }
.term-try button:disabled { cursor: default; }
@keyframes chip-in { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { .term-try button { animation: none; } }


@media (max-width: 640px) {
  .term { font-size: 12px; }
  .kai .term { height: 460px; }
  .term-bar em { padding-right: 0; }
}
