/* THE TRAIL LINE (UI/UX PR 3, 2026-11-19) — trail-line.js says what it is.

   One thin line down the left of a piece of work's steps, a small node per
   step, the node centred on the step's FIRST line of text however many lines
   the step runs to. Drawn the same way in the chat (a turn's fold, steps.js)
   and in the side panel (a ticket's history, ticket-panel.js), so the two
   read as one path.

   The measurements are the decision, so they are named:
     --trail-node    9px: big enough to read a fill at a glance, small enough
                     to sit beside 13px text without becoming a bullet;
     --trail-stroke  1.5px: the line and the rings, one weight;
     --trail-row     the height of a step's first line box (its padding
                     included): the node sits in the middle of it. Set per
                     place below, because a tool row and a history line are
                     different heights;
     --trail-gap     3px of air between the line and each node, so the path
                     reads as a line passing THROUGH stations rather than a
                     string of beads glued together.

   Colour: the line is a quiet neutral (`--line-2`) until the step above it is
   done, then the ink (`--text`). Running is the working blue the fold's own
   dot already uses; needing the person is the "Needs you" amber the approval
   card uses (`--st-needs`). Every colour is a token, so dark mode is the
   tokens' and nothing is restated for it.

   It sits after the stylesheets whose rules it shapes (style.css's `.st-body`
   and `.tool`, beta-shell.css's side panel) only where it says so with more
   specific selectors; it is linked before the shells so their sizes still
   win on anything it does not name. */

.trail {
  --trail-node: 9px;
  --trail-stroke: 1.5px;
  --trail-row: 18px;
  --trail-gap: 3px;
  --trail-indent: 20px;
  --trail-quiet: var(--line-2);
  --trail-ink: var(--text);
  --trail-run: var(--st-working);
  --trail-attn: var(--st-needs);
  --trail-fail: var(--st-failed);
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column;
}
.trail-step { position: relative; min-width: 0; padding-left: var(--trail-indent); }

/* The node: centred on the first line, a ring by default (not reached). */
.trail-node {
  position: absolute; left: 0; top: calc((var(--trail-row) - var(--trail-node)) / 2);
  width: var(--trail-node); height: var(--trail-node); box-sizing: border-box;
  border: var(--trail-stroke) solid var(--trail-quiet); border-radius: 50%;
  background: transparent;
  transition: background-color var(--dur-panel) var(--ease-standard), border-color var(--dur-panel) var(--ease-standard);
}

/* The segment from this step's node down to the next step's: it starts
   --trail-gap under the node and stops --trail-gap above the next one, which
   sits half a row's slack into the next step. */
.trail-step::before {
  content: ""; position: absolute;
  left: calc((var(--trail-node) - var(--trail-stroke)) / 2);
  width: var(--trail-stroke); border-radius: var(--trail-stroke);
  top: calc((var(--trail-row) + var(--trail-node)) / 2 + var(--trail-gap));
  bottom: calc(var(--trail-gap) - (var(--trail-row) - var(--trail-node)) / 2);
  background: var(--trail-quiet);
  transition: background-color var(--dur-panel) var(--ease-standard);
}
.trail-step:last-child::before { display: none; }

/* done: walked. Filled, and the line under it is ink. */
.trail-step[data-state="done"] > .trail-node { background: var(--trail-ink); border-color: var(--trail-ink); }
.trail-step[data-state="done"]::before { background: var(--trail-ink); }

/* running: where it is. A ring with a dot at its centre, breathing. */
.trail-step[data-state="running"] > .trail-node {
  border-color: var(--trail-run);
  background: radial-gradient(circle, var(--trail-run) 0 1.75px, transparent 2.25px);
  animation: trail-breathe 2.2s var(--ease-standard) infinite;
}
@keyframes trail-breathe {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--trail-run) 34%, transparent); }
  55% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--trail-run) 0%, transparent); }
}

/* needs: the path waits on the person. Amber node, amber line after it. */
.trail-step[data-state="needs"] > .trail-node {
  background: var(--trail-attn); border-color: var(--trail-attn);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--trail-attn) 22%, transparent);
}
.trail-step[data-state="needs"]::before { background: var(--trail-attn); }

/* failed: a ring in the failure colour. */
.trail-step[data-state="failed"] > .trail-node { border-color: var(--trail-fail); }

/* The last step is not the end of the path while it is still going. A
   running step trails a few dotted pixels of line not walked yet; a step
   that needs the person trails a short amber line fading out, pointing at
   what is under the list (in the chat, the approval card). */
.trail-step:last-child:is([data-state="running"], [data-state="needs"])::before {
  display: block; bottom: auto; height: 14px;
}
.trail-step:last-child[data-state="running"]::before {
  background: repeating-linear-gradient(to bottom, var(--trail-quiet) 0 2px, transparent 2px 4px);
}
.trail-step:last-child[data-state="needs"]::before {
  background: linear-gradient(to bottom, var(--trail-attn), color-mix(in srgb, var(--trail-attn) 0%, transparent));
}

/* The state in words, for a reader that cannot see the node. */
.trail-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* A plain step (a ticket's history): what happened, and a quiet time. */
.trail-body { display: flex; flex-direction: column; min-width: 0; padding-bottom: 10px; }
.trail-step:last-child .trail-body { padding-bottom: 0; }
.trail-text { font-size: 13px; line-height: var(--trail-row); color: var(--text); overflow-wrap: anywhere; }
.trail-step[data-state="needs"] .trail-text { color: var(--st-needs-ink); font-weight: 500; }
.trail-step[data-state="failed"] .trail-text { color: var(--wine, var(--err)); }
.trail-meta { font-size: 12px; line-height: 16px; color: var(--dim); font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  /* Still, not gone: the ring and its dot say "here" without moving. */
  .trail-step[data-state="running"] > .trail-node {
    animation: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--trail-run) 18%, transparent);
  }
  .trail-node, .trail-step::before { transition: none; }
}

/* ---------- in the chat: a turn's fold (steps.js) -----------------------------
   The fold's body WAS a 2px rule down the left (style.css `.st-body`); the
   trail is that rule, drawn with stations. Each step is a tool row or a
   thought, whose summary is a 28px line (44px for a thumb), so that is the
   row the node centres on. The trail starts under the fold's own status dot:
   the summary pads 10px before a 7px dot, so the dot's centre is 13.5px in,
   and a 9px node 9px in centres on the same x. */
.steps .st-body.trail {
  --trail-row: 32px;
  --trail-indent: 16px;
  margin: 2px 0 2px 9px; padding: 0; border-left: 0; gap: 0;
}
/* The row is the summary's height exactly — no padding above or below its
   centred line — so the node's centre and the words' centre are one y. With
   style.css's 5px padding the line measured 34px in Chromium and the nodes
   sat 3px above the words (2026-11-19). */
.st-body.trail > .trail-step > .reasoning > summary,
.st-body.trail > .trail-step > .tool > details > summary {
  min-height: var(--trail-row); padding-top: 0; padding-bottom: 0; box-sizing: border-box;
}
/* The ▸ beside each row was a second column of marks next to the nodes; on
   the trail it shows only where it says something — under the pointer, on
   the keyboard's focus, or on a row that is open. It keeps its room, so a
   row's words do not move when it appears. */
.st-body.trail > .trail-step > .tool > details > summary::before,
.st-body.trail > .trail-step > .reasoning > summary::before { opacity: 0; transition: opacity var(--dur-tap) var(--ease-standard), transform var(--dur-tap) var(--ease-standard); }
.st-body.trail > .trail-step > .tool > details:is([open], :hover, :focus-within) > summary::before,
.st-body.trail > .trail-step > .reasoning:is([open], :hover, :focus-within) > summary::before { opacity: 1; }
@media (pointer: coarse) {
  /* No pointer to hover with: the mark stays, as the only sign a row opens. */
  .st-body.trail > .trail-step > .tool > details > summary::before,
  .st-body.trail > .trail-step > .reasoning > summary::before { opacity: 1; }
}
/* The desk's chat pulls its fold summary 8px left with no padding before the
   dot (beta-shell.css), and the phone's Ask sheet pads it 0: there the dot's
   centre is 3.5px in, so the trail starts 1px to the left of the fold. */
@media (min-width: 821px) {
  #chat-panel .stream .steps .st-body.trail { margin-left: -1px; }
}
@media (max-width: 720px) {
  #sheet .stream .steps .st-body.trail { margin-left: -1px; }
}
@media (pointer: coarse) {
  .steps .st-body.trail { --trail-row: 44px; }
}

/* ---------- in the side panel: a ticket's history (ticket-panel.js) ---------- */
.spt-trail { margin-top: 2px; }
/* ---------- and its Activity tab (side-panel.js `activityBody`) ----------------
   The same trail; the tab's lines are longer than a ticket's stations, so a
   little more air under each (12px, where the dotted list had 14px between
   rows). The inset is beta-shell.css's `.sp-activity`. */
.trail.sp-activity .trail-body { padding-bottom: 12px; }
.trail.sp-activity .trail-step:last-child .trail-body { padding-bottom: 0; }
@media (max-width: 820px) {
  /* The sheet reads at the phone's sizes (beta-shell.css), so does its trail. */
  #side-panel.is-sheet :is(.spt-trail, .sp-activity) { --trail-row: 21px; }
  #side-panel.is-sheet :is(.spt-trail, .sp-activity) .trail-text { font-size: 15px; }
  #side-panel.is-sheet :is(.spt-trail, .sp-activity) .trail-meta { font-size: 13px; line-height: 18px; }
}
