/* =============================================================================
   panel-thoughtline.css — the look of the status line.
   =============================================================================

   React Bits' ThoughtLine.css, ported. Three deliberate departures from it,
   each because this panel has already settled the question it was answering.

   1. NO COLOUR IS NAMED. The source ships `--tl-color: currentColor` and
      mixes the shimmer with `color-mix(in srgb, var(--tl-color) 50%,
      transparent)`. Every colour in this product is `rgba(var(--x-rgb), a)` so
      that a theme is one block of triplets and nothing else — test-theme.js
      greps the sheets for dark-palette literals, and a `color-mix` on
      `currentColor` is a value the light theme cannot reach even though it
      contains no literal. So the shimmer is the bone triplet at two alphas
      and the ink ladder (`--t-meta`, `--t-faint`) does the rest.

   2. THE TYPE IS THE PANEL'S, NOT THE COMPONENT'S. The source is
      `font-weight: 500` at 16px scaling everything in em. The status line
      this replaces is `400 10px/1 var(--mono)`, uppercase, .14em tracked —
      and that register is what makes the engine's own speech read as
      different in kind from the answer below it. Taking the component's type
      would have made the line the largest thing in the bubble.

   3. IT WRAPS. The source is `white-space: nowrap` with `width: max-content`
      on the head and the step list, which is right on a page and wrong in a
      360px side panel where a step label is `Searching: <the actual query>`.
      The line ellipsizes (the existing `.status-text` rule, kept) and the
      trace wraps, because a clipped query is the one thing the trace cannot
      afford — seeing the exact string that fired is its whole purpose.

   WHAT IS KEPT VERBATIM: the two eases, the `inline-grid` label stack with
   both lines in one cell, the blur-through-the-seam crossfade, the
   `background-clip: text` shimmer, the `0fr -> 1fr` fold, and the
   `@starting-style` entry on a step.
   ============================================================================= */

.thought-line {
  --tl-ease-out: var(--ease-out);
  --tl-ease-in-out: var(--ease-in-out);
  --tl-settle: 350ms;
  --tl-blur: 2px;
  --tl-shimmer: 1.8s;
  /* The trough of the glyph's breath. 1 is no breath, which is the default
     while the glyph is the orb — see the note at the foot of
     panel-thoughtline.js. */
  --tl-trough: 1;

  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  /* .chat-searched's own bottom margin: this sits exactly where the resolved
     action rows and the search note used to, and the prose below it must not
     move depending on which of them is showing. */
  margin-bottom: 10px;
}
/* THE GAP IS TO THE PROSE, SO WITH NO PROSE THERE IS NO GAP. While the turn
   is thinking the answer box is empty and `.chat-prose:empty` is
   `display: none`, so that 10px was the only thing under the row: 26px of
   space above the caption (the bubble's 14 plus the head's 12) against 36
   below it, which reads as a line sitting high in an over-tall box. The line
   itself does not move when the first token lands — the margin grows
   downward, under the row — so the rule above still holds: the prose starts
   in the same place whichever of these was showing before it. */
.thought-line:has(+ .chat-prose:empty) { margin-bottom: 0; }
/* The same state before the prose node exists at all: the line is built and
   mounted first, and a browser without `:has()` falls back to this. */
.thought-line:last-child { margin-bottom: 0; }
/* The live bubble keeps a hidden `.atl-end` anchor after the line, so the line
   is never :last-child there and the 10px (plus the bubble's padding) sat
   under it: a box longer below the caption than above. */
.thought-line:has(+ .atl-end:last-child) { margin-bottom: 0; }

/* The line. `.chat-thinking`'s four declarations, restated rather than shared:
   that selector is a flex ROW whose children are the dot and the text, and
   this one is a column with a fold under it. */
.tl-head {
  display: flex; align-items: center; gap: 10px;
  min-width: 0; max-width: 100%;
  margin: 0; padding: 12px 2px;
  border: 0; background: none; text-align: left;
  font: 400 var(--fs-xs)/1 var(--mono); letter-spacing: .14em; text-transform: uppercase;
  color: var(--t-meta);
  /* The orb is 20px against a 10px caption: reserve its height so the row
     does not reflow the frame the engine mounts into, or reflow the other way
     on a build where it never loads. */
  min-height: 20px;
  cursor: default;
  outline: none;
}
.tl-head[data-toggle=""] { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tl-head[data-toggle=""]:hover { color: var(--t-secondary); }
.tl-head:focus-visible { box-shadow: var(--lit-rim); border-radius: var(--r-ctl); }

/* The mark. `.pulse-dot` carries its own 7px disc and pulse from panel.html,
   and `.px-orbed` replaces both the moment orb.js mounts a canvas into it —
   so the dot is the fallback and nothing here restates either. */
.tl-glyph { flex: none; }
.thought-line[data-working] .tl-glyph[data-breathe] {
  animation: tl-breathe 1.6s var(--tl-ease-in-out) infinite;
}
@keyframes tl-breathe {
  0%, 100% { opacity: var(--tl-trough); }
  50%      { opacity: 1; }
}

/* ---- the two lines, in one cell ------------------------------------------
   Both labels occupy grid-area 1/1, so the stack is as wide as the wider of
   them and the crossfade reflows nothing. It is also why the timer has to be
   translated back to the active label's edge — see placeTimer. */
.tl-label { display: inline-grid; min-width: 0; }
.tl-text {
  grid-area: 1 / 1;
  min-width: 0;
  /* The line ellipsizes: a long query must push nothing. This is the existing
     `.status-text` rule and the reason the component's `width: max-content`
     is gone. */
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  opacity: 0;
  filter: blur(var(--tl-blur));
  /* ONE LINE, NOT THREE (R5, 2026-10-29). The faded label stayed in the text
     a reader copies: "Thinking / Thought for 5.5s › / Thought for 5.5
     seconds". Once its fade is over it is hidden outright, which takes it out
     of a selection and of innerText. */
  visibility: hidden;
  transition:
    opacity var(--tl-settle) var(--tl-ease-out),
    filter  var(--tl-settle) var(--tl-ease-out),
    visibility 0s linear var(--tl-settle);
}
.thought-line[data-working] .tl-text--work,
.thought-line:not([data-working]) .tl-text--done {
  opacity: 1;
  filter: blur(0);
  visibility: visible;
  transition-delay: 0s;
}
/* The settled line is quieter than the working one: it is a thing that
   happened, and it sits above an answer that is now the thing to read.
   Quieter by a rung on the text ladder, not by opacity on top of one: the
   old .75 over --t-meta measured 2.7:1 (audit F-018). */
.thought-line:not([data-working]) .tl-text--done { color: var(--t-faint); }

/* ---- the shimmer --------------------------------------------------------
   A band of ink sweeps the working label. The gradient is clipped to the
   glyphs, so the text itself is transparent and the band is what you read —
   which is also why it is switched off rather than dimmed under reduced
   motion: there is no static frame of this that is legible. */
/* THE CLAMP IS ON THIS, NOT ONLY ON THE LINE. `text-overflow` applies to a
   block container's own inline content, and this is an `inline-block` child —
   so `.tl-text`'s ellipsis cannot reach it and a long "Searching: <query>"
   would hard-clip mid-word instead. It stays inline-block because the
   shimmer's `background-size: 250%` is resolved against this box. */
.tl-breath {
  display: inline-block;
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  /* The gradient is clipped to the glyphs, so the box must not sit on the
     text's descenders — without this the sweep is cut off under a `g`. */
  vertical-align: bottom;
}
.thought-line[data-working] .tl-breath[data-shimmer] {
  background: linear-gradient(
    100deg,
    rgba(var(--bone-rgb), .34) 30%,
    rgba(var(--bone-rgb), .78) 50%,
    rgba(var(--bone-rgb), .34) 70%
  );
  background-size: 250% 100%;
  background-position: 125% 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  animation: tl-shimmer var(--tl-shimmer) linear infinite;
}
@keyframes tl-shimmer { to { background-position: -125% 0; } }

/* ---- the caption changing ----------------------------------------------
   Every new caption, real or drifted, rises into place through a short blur,
   so a change reads as the line moving on rather than as a flicker. */
.thought-line[data-working] .tl-text--work[data-swap] {
  animation: tl-swap var(--dur-3, 260ms) var(--tl-ease-out);
}
@keyframes tl-swap {
  from { opacity: 0; transform: translateY(4px); filter: blur(var(--tl-blur)); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}

/* ---- the trail ----------------------------------------------------------
   The captions the line showed before this one, under it while it works:
   newest nearest the line, older ones fainter. At most three rows, so it
   grows three times in a turn and then only changes in place. Gone on
   settle; the trace behind the chevron is the record. */
.tl-trail {
  display: flex; flex-direction: column-reverse; gap: 3px;
  /* Stretched to the line's width with the indent as padding, not margin:
     `max-width: 100%` plus a 30px margin let a long caption run 30px past
     the bubble before its ellipsis applied. */
  align-self: stretch; box-sizing: border-box;
  min-width: 0; max-width: 100%;
  margin: -8px 0 0; padding-left: 30px;
  font: 400 calc(var(--fs-xs) - 1px)/1.35 var(--mono); letter-spacing: .02em;
  color: var(--t-faint);
  -webkit-user-select: none; user-select: none;
  pointer-events: none;
}
.tl-trail:empty, .thought-line:not([data-working]) .tl-trail { display: none; }
.tl-trail-item {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: opacity var(--tl-settle) var(--tl-ease-out), transform var(--tl-settle) var(--tl-ease-out);
}
.tl-trail-item::before { content: "\00b7\00a0"; opacity: .8; }
.tl-trail-item[data-age="0"] { opacity: .6; }
.tl-trail-item[data-age="1"] { opacity: .38; }
.tl-trail-item[data-age="2"] { opacity: .2; }
@starting-style {
  .tl-trail-item { opacity: 0; transform: translateY(-4px); }
}
/* The trail sits between the line and the bottom gap the line already keeps. */
.thought-line[data-working][data-trail] { padding-bottom: 8px; }

/* ---- the clock ----------------------------------------------------------
   Tabular, or the line jitters sideways every tenth of a second as the digits
   change width. IBM Plex Mono is already the row's font, so this is the
   figure style and not a second family. */
.tl-timer {
  flex: none;
  font-variant-numeric: tabular-nums;
  letter-spacing: .08em;
  color: var(--t-faint);
  transition:
    opacity var(--tl-settle) ease,
    transform var(--tl-settle) var(--tl-ease-in-out);
}
.thought-line:not([data-working]) .tl-timer { color: var(--t-meta); }

/* The disclosure mark, and `.cs-caret`'s own rotation — the search note's
   expandable used exactly this glyph and this transform, and the trace is
   what replaces it. */
.tl-chev {
  flex: none; margin-left: 2px; opacity: .85;
  transition: transform var(--dur-2) ease, opacity var(--dur-3) ease;
}
.tl-chev[data-on="off"] { opacity: 0; }
.thought-line[data-open] .tl-chev { transform: rotate(90deg); }

.tl-sr {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
/* The spoken copy and the chevron are not part of what a reader copies. */
.tl-sr, .tl-chev { -webkit-user-select: none; user-select: none; }

/* ---- the fold -----------------------------------------------------------
   0fr -> 1fr is the component's own mechanism and it is kept: it animates to
   the content's real height with nothing measured in script. */
.tl-trace {
  display: grid;
  grid-template-rows: 0fr;
  width: 100%; min-width: 0;
  transition: grid-template-rows var(--tl-settle) var(--tl-ease-out);
}
.tl-trace[data-open] { grid-template-rows: 1fr; }
/* `contain: paint` as well as the overflow: without it a shut fold's text
   (a long thought, a run of tool rows) still counted toward the chat column's
   scroll height in Chrome, so the column scrolled on into blank space below
   the reply (2026-11-16). overflow: hidden and overflow: clip alone didn't
   stop it; paint containment does, and it clips to the same box. */
.tl-fold { min-height: 0; overflow: hidden; contain: paint; }
/* A shut fold must not size the bubble: the bubble shrinks to its widest
   content, and a long hidden thought made a one-word line a full-width box. */
.tl-trace:not([data-open]) .tl-fold { contain: paint inline-size; }

/* `.cs-body`'s rule: a hairline the trace hangs off, so it reads as
   subordinate to the line above rather than as a second list. */
.tl-steps {
  display: flex; flex-direction: column; gap: 9px;
  min-width: 0;
  margin: 2px 0 2px 12px; padding: 6px 0 2px 10px;
  border-left: 1px solid var(--hair);
  font: 400 var(--fs-sm)/1.5 var(--mono); letter-spacing: 0; text-transform: none;
  color: var(--t-faint);
}

.tl-step {
  display: grid;
  grid-template-columns: 1em 1fr;
  gap: 2px 8px;
  min-width: 0;
  transition:
    opacity var(--dur-3) var(--tl-ease-out),
    transform var(--dur-3) var(--tl-ease-out);
}
@starting-style {
  .tl-step { opacity: 0; transform: translateY(-4px); }
}

.tl-mark {
  display: inline-grid; place-items: center;
  width: 1em; height: 1.5em;
  opacity: .55;
}
/* A finished step is `.cs-mark`'s dot, which is what every settled provenance
   row in this panel already is. The current one pulses. */
.tl-pulse {
  display: block; width: .45em; height: .45em;
  border-radius: 50%; background: currentColor;
}
.tl-step[data-state="current"] .tl-pulse {
  animation: tl-step-pulse 1.6s var(--tl-ease-in-out) infinite;
}
@keyframes tl-step-pulse {
  0%, 100% { opacity: .5; }
  50%      { opacity: 1; }
}
.tl-step[data-state="current"] .tl-step-text { color: var(--t-secondary); }

/* ---- SAID, NOT DONE ----------------------------------------------------
   An intent row ("I need to search the web for …") is the turn's own voice
   about work that has not happened yet, and it sits directly above the row
   for the work itself. Two rows that looked identical would read as the same
   thing listed twice, so the intent is marked as speech: a hollow mark,
   because nothing has landed, and italics, because it is a sentence rather
   than the label of a phase. Colour is NOT the difference — the ink ladder is
   the state machine's (current is brighter than done) and taking a rung of it
   for the register would make an intent that is current and an action that is
   done indistinguishable. */
.tl-step[data-kind="intent"] .tl-pulse {
  /* Smaller as well as hollow, because `failed` is hollow too (at a dimmed
     mark) and the two must not be one shape between them. */
  width: .38em; height: .38em;
  background: none;
  box-shadow: inset 0 0 0 1px currentColor;
}
.tl-step[data-kind="intent"] .tl-step-text { font-style: italic; }
.tl-step[data-state="failed"] .tl-mark,
.tl-step[data-state="skipped"] .tl-mark { opacity: .35; }
.tl-step[data-state="failed"] .tl-pulse { background: none; box-shadow: inset 0 0 0 1px currentColor; }

/* ---- A TOOL THE AGENT USED ----------------------------------------------
   The row carries the tool's own name as a tag between the mark and the
   words ("read_memory  Read memory · preferences/search.md"), so a tool use
   reads as a call rather than as a phase. The tag is the only addition: the
   state machine (done, failed) is the same marks as every other row. */
.tl-step[data-kind="tool"] { grid-template-columns: 1em auto 1fr; }
.tl-tool {
  align-self: start;
  padding: 0 5px; border-radius: var(--r-xs);
  background: var(--s-quiet);
  font: 500 var(--fs-xs)/1.5 var(--mono);
  color: var(--t-secondary);
  white-space: nowrap;
}
.tl-step[data-state="failed"] .tl-tool { text-decoration: line-through; opacity: .6; }
/* A connected app's mark takes the tag's place on the row, and sits beside the
   working caption while the turn is using it. */
.tl-tool-logo, .tl-line-logo { display: inline-flex; flex: none; align-self: center; }
.tl-tool-logo { align-self: start; }
.tl-line-logo:empty { display: none; }
.tl-step[data-state="failed"] .tl-tool-logo { opacity: .5; }

/* ---- A THINKING BLOCK'S SUMMARY (agent@2, panel-timeline.js) ------------
   What the model concluded, in its own words, under "Thought for 3.0s". Prose,
   not a phase: the reading face and size, no mark, and the whole of it. */
.tl-step[data-kind="summary"] { grid-template-columns: 1fr; }
.tl-step[data-kind="summary"] .tl-mark { display: none; }
.tl-step[data-kind="summary"] .tl-step-text {
  font: 400 var(--fs-base)/1.55 var(--sans); color: var(--t-meta);
  white-space: pre-wrap; overflow-wrap: anywhere;
}

/* The query and the step name wrap rather than truncating: the whole point of
   the trace is the exact string. */
.tl-step-text {
  min-width: 0;
  overflow-wrap: anywhere;
  transition: color var(--tl-settle) ease;
}

/* ---- WHAT A STEP FOUND --------------------------------------------------
   The sources under the search step. It is handed the search note's own body,
   so every `.cs-*` rule in panel.html styles it and there is no second
   vocabulary for one kind of object. Second column of the step's grid, so it
   lines up with the step's words and not with its mark. */
.tl-detail {
  grid-column: 2;
  min-width: 0;
  margin-top: 4px;
}
.tl-detail .cs-row + .cs-row { margin-top: 10px; }
/* Shut until its row is clicked; the caret says it opens. */
.tl-step[data-has-detail] { cursor: pointer; }
.tl-step[data-has-detail]:not([data-open]) .tl-detail { display: none; }
.tl-step[data-has-detail] .tl-step-text::after {
  content: "\203A"; display: inline-block; margin-left: .4em; opacity: .85;
  transition: transform var(--dur-2) ease;
}
.tl-step[data-has-detail][data-open] .tl-step-text::after { transform: rotate(90deg); }
.tl-step[data-has-detail]:focus-visible { outline: 1px solid var(--hair); outline-offset: 2px; border-radius: var(--r-xs); }
.tl-detail { cursor: auto; }

@media (prefers-reduced-motion: reduce) {
  /* The blur is the one part of the crossfade that cannot be slowed into
     acceptability — it is motion in the glyphs themselves. */
  .tl-text { filter: none !important; transition: opacity var(--tl-settle) ease; }
  .tl-timer { transition: opacity var(--tl-settle) ease; }
  .tl-step { transform: none !important; transition: opacity var(--dur-3) ease; }
  .tl-chev { transition: opacity var(--dur-3) ease; }
  .tl-trail-item { transform: none !important; transition: opacity var(--dur-3) ease; }
  .tl-text--work[data-swap] { animation: none !important; }
  .tl-step[data-state="current"] .tl-pulse { animation-duration: 2.4s; }
  /* The shimmer and the breath are switched off in script, not here: the
     shimmer paints a gradient through clipped text and has no legible static
     frame, so it is removed rather than stopped. See tlReduced(). */
}
