/* ════════════════════════════════════════════════════════════════════
   Job detail page: step timeline (/dashboard/jobs/<id>).
   Rendered by jstRender() in app.js into #jst-root. Modelled on Browser
   Use's run view: a collapsible "Worked for 3m 52s · 19 steps" header,
   then compact icon-led one-liners, each with an optional "Thinking"
   block and expandable details. Theme tokens only, so Light (default)
   and Dark both follow app.css.
   ════════════════════════════════════════════════════════════════════ */

/* The page column shrinks to its content when nothing wide (an error or
   result block) is on it; keep it full width so short timelines don't
   squeeze into a narrow card. */
.job-detail-page:has(.jst) { width: 100%; box-sizing: border-box; }

.jst { --jst-col: 22px; --jst-gap: 10px; --jst-indent: calc(var(--jst-col) + var(--jst-gap) + 6px); }

/* ── header ─────────────────────────────────────────────────────────── */
.jst-head {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 0 0 4px -8px; padding: 5px 8px;
  background: transparent; border: 0; border-radius: var(--radius, 6px);
  color: var(--text); font: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer;
}
.jst-head:hover { background: var(--navy-700); }
.jst-head:focus-visible { outline: none; box-shadow: var(--vercel-focus); }
.jst-head-n { color: var(--text-muted); font-weight: 400; }
.jst-head-n::before { content: "·"; margin-right: 8px; }
.jst-head .jst-chev { transform: rotate(90deg); }
.jst-head[aria-expanded="false"] .jst-chev { transform: none; }

/* ── list + rail ────────────────────────────────────────────────────── */
.jst-list { list-style: none; margin: 0; padding: 0; }
/* The rail: each step draws its own segment so it can stop at the last
   icon instead of running down past that step's text. */
.jst-step { position: relative; }
.jst-step::before {
  content: ""; position: absolute; top: 0; bottom: 0;
  left: calc(6px + var(--jst-col) / 2); width: 1px; background: var(--border);
}
.jst-step:first-child::before { top: 12px; }
.jst-step:last-child::before { bottom: auto; height: 8px; }
.jst-step:last-child:has(> .jst-think)::before { height: 34px; }
.jst-step:only-child::before { display: none; }
.jst-step:only-child:has(> .jst-think)::before { display: block; top: 12px; height: 22px; }

.jst-step summary { list-style: none; }
.jst-step summary::-webkit-details-marker { display: none; }

/* One row: icon | text | duration | chevron */
.jst-act > summary,
.jst-row {
  display: grid; grid-template-columns: var(--jst-col) minmax(0, 1fr) auto auto;
  align-items: start; column-gap: var(--jst-gap);
  padding: 4px 6px; border-radius: var(--radius, 6px);
}
.jst-act > summary { cursor: pointer; }
.jst-act > summary:hover,
.jst-think > summary:hover { background: var(--navy-700); }
.jst-act > summary:focus-visible,
.jst-think > summary:focus-visible { outline: none; box-shadow: var(--vercel-focus); }

.jst-ico-wrap {
  position: relative; z-index: 1;
  width: var(--jst-col); height: var(--jst-col); border-radius: 50%;
  display: grid; place-items: center;
  background: var(--navy-800); border: 1px solid var(--border-light);
  color: var(--text-muted);
}
.jst-ico { width: 13px; height: 13px; display: block; }
.jst-chev {
  width: 14px; height: 14px; margin-top: 4px; color: var(--text-muted);
  transition: transform .15s ease;
}
details[open] > summary > .jst-chev { transform: rotate(90deg); }

.jst-main { min-width: 0; display: flex; flex-direction: column; }
.jst-label {
  font-size: 13.5px; line-height: 22px; color: var(--text);
  overflow-wrap: anywhere;
}
.jst-sub {
  font-size: 12.5px; line-height: 1.45; color: var(--text-muted); margin-bottom: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: anywhere;
}
.jst-dur {
  font-family: var(--font-mono); font-size: 11.5px; line-height: 22px;
  color: var(--text-muted); font-variant-numeric: tabular-nums;
}

/* ── thinking ───────────────────────────────────────────────────────── */
.jst-think > summary {
  display: grid; grid-template-columns: var(--jst-col) auto minmax(0, 1fr) auto;
  align-items: center; column-gap: var(--jst-gap);
  padding: 3px 6px; border-radius: var(--radius, 6px); cursor: pointer;
}
.jst-think > summary > .jst-ico {
  justify-self: center; position: relative; z-index: 1;
  width: 12px; height: 12px; padding: 3px; box-sizing: content-box;
  background: var(--navy-800); border-radius: 50%; color: var(--text-muted);
}
.jst-think > summary > .jst-chev { margin-top: 0; }
.jst-think-lbl { font-size: 12.5px; font-weight: 500; color: var(--text-muted); }
.jst-think-sum {
  font-size: 12.5px; color: var(--text-muted); opacity: .85;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.jst-think[open] .jst-think-sum { visibility: hidden; }
.jst-think-body {
  margin: 2px 6px 6px var(--jst-indent); padding: 2px 0 2px 12px;
  border-left: 2px solid var(--border-light);
  font-size: 13px; line-height: 1.55; color: var(--text-muted);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.jst-think-body strong { color: var(--text); font-weight: 600; }

/* ── expanded details ───────────────────────────────────────────────── */
.jst-detail {
  margin: 4px 6px 10px var(--jst-indent); padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-lg, 8px);
  background: var(--navy-900);
  display: flex; flex-direction: column; gap: 8px;
}
.jst-kv { display: flex; gap: 10px; align-items: baseline; font-size: 12.5px; min-width: 0; }
.jst-k {
  flex: none; min-width: 44px;
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-muted);
}
.jst-v { color: var(--text); min-width: 0; overflow-wrap: anywhere; }
a.jst-url { color: var(--emerald); text-decoration: none; }
a.jst-url:hover { text-decoration: underline; }
.jst-block { min-width: 0; }
.card-drawer-body .jst-block pre,
.jst-block pre {
  margin: 4px 0 0; max-height: 240px;
  background: var(--navy-800); border: 1px solid var(--border);
  font-size: 11.5px; padding: 10px;
}
.jst-raw-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.jst-copy {
  font: inherit; font-size: 11.5px; padding: 2px 9px; border-radius: 5px; cursor: pointer;
  background: var(--navy-800); color: var(--text-muted); border: 1px solid var(--border-light);
}
.jst-copy:hover { color: var(--text); }
.jst-copy:focus-visible { outline: none; box-shadow: var(--vercel-focus); }

/* ── tones ──────────────────────────────────────────────────────────── */
.jst-step.is-done .jst-ico-wrap {
  color: var(--emerald);
  border-color: color-mix(in srgb, var(--emerald) 40%, var(--border));
  background: color-mix(in srgb, var(--emerald) 8%, var(--navy-800));
}
.jst-step.is-warn .jst-ico-wrap {
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber) 40%, var(--border));
}
.jst-step.is-err .jst-ico-wrap {
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 45%, var(--border));
  background: color-mix(in srgb, var(--red) 8%, var(--navy-800));
}
.jst-step.is-err .jst-label { color: var(--red); }
.jst-step.is-err .jst-sub { color: color-mix(in srgb, var(--red) 75%, var(--text-muted)); }
.card-drawer-body .jst-block-err pre,
.jst-block-err pre {
  color: var(--red);
  background: color-mix(in srgb, var(--red) 6%, var(--navy-800));
  border-color: color-mix(in srgb, var(--red) 30%, var(--border));
}
.jst-block-err .jst-k { color: var(--red); }
.jst-code {
  font-family: var(--font-mono); font-size: 11px; line-height: 22px;
  color: var(--red); white-space: nowrap;
}
.jst-end .jst-row { grid-template-columns: var(--jst-col) minmax(0, 1fr) auto; }

/* ── live ───────────────────────────────────────────────────────────── */
.jst-pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--emerald);
  animation: jst-pulse 1.4s ease-in-out infinite;
}
.jst-live .jst-label { color: var(--text-muted); }
@keyframes jst-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .35; transform: scale(.75); }
}
@media (prefers-reduced-motion: reduce) {
  .jst-pulse { animation: none; }
  .jst-chev { transition: none; }
}

.jst-empty { margin: 0; font-size: 13px; color: var(--text-muted); }

/* ── narrow screens ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .jst { --jst-gap: 8px; }
  .jst-detail { margin-left: 6px; }
  .jst-think-body { margin-left: 12px; }
}
