/* Timeline view (#410, #415, js/timeline.js): one lane per story, the x axis is time. A sticky band header on top,
   a left column of lane labels (HTML, same y as the lanes), the chart as one SVG. The work bars' fill is set by
   the script (the role / runner colour); everything else uses the theme variables. */
.timeline-view {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 8px;
}

.timeline-toolbar, .timeline-legendbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  flex: none;
  min-height: 26px;
  font-size: 12px;
  color: var(--muted);
}
.timeline-summary { min-width: 8ch; }
.timeline-story-filter { margin-left: 0; }
.timeline-check { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.timeline-color { font-size: 12px; padding: 3px 6px; }
.timeline-presets, .timeline-zoom { display: inline-flex; gap: 4px; }
.timeline-toolbar .btn:focus-visible, .timeline-chart:focus-visible, .timeline-label:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.timeline-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.timeline-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.timeline-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.tl-wait-swatch { background: var(--tl-wait); border: 1px solid var(--border); }
.tl-wait-human-swatch {
  background: repeating-linear-gradient(45deg, var(--warn) 0 2px, transparent 2px 5px), color-mix(in srgb, var(--warn) 14%, transparent);
  border: 1px solid var(--warn);
}
.timeline-notice { color: var(--warn); }
.timeline-error { color: var(--danger); }

.timeline-view {
  --tl-wait: color-mix(in srgb, var(--muted) 30%, transparent);
  --tl-span: color-mix(in srgb, var(--accent) 6%, transparent);
  --tl-band: var(--panel);
}

/* vertical scroll is the page's; the header sticks to the top of it */
.timeline-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  position: relative;
}
.timeline-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  background: var(--tl-band);
  border-bottom: 1px solid var(--border);
}
.timeline-corner {
  flex: none;
  box-sizing: border-box;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-right: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
}
.timeline-head { flex: 1; min-width: 0; overflow: hidden; touch-action: pan-y; cursor: grab; }
.timeline-head-svg { display: block; }
.tl-band-cell { fill: transparent; stroke: var(--border); stroke-width: 1; }
.tl-band.tick .tl-band-cell { fill: color-mix(in srgb, var(--text) 3%, transparent); }
.tl-band-label { fill: var(--muted); font-size: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; pointer-events: none; }
.tl-band.tick .tl-band-label { fill: var(--text); }

.timeline-content { display: flex; align-items: flex-start; }
.timeline-labels {
  flex: none;
  position: relative;
  box-sizing: border-box;
  border-right: 1px solid var(--border);
  background: var(--bg);
  z-index: 2;
}
.timeline-label {
  position: absolute;
  left: 0;
  right: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 8px;
  overflow: hidden;
  font-size: 12px;
  line-height: 14px;
  cursor: pointer;
  border-left: 3px solid var(--kind-task);
  border-bottom: 1px solid var(--border-soft);
}
.timeline-label.kind-story { border-left-color: var(--kind-story); }
.timeline-label:hover { background: var(--panel); }
.timeline-label-top { display: flex; gap: 6px; min-width: 0; white-space: nowrap; }
.timeline-label-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.timeline-label-chips { display: flex; gap: 4px; flex: none; }
.timeline-label .chip { padding: 0 6px; line-height: 13px; }
.timeline-label.deleted .timeline-label-title, .timeline-label.deleted .card-id { text-decoration: line-through; color: var(--muted); }
.timeline-label.loose .timeline-label-title { font-style: italic; }
.timeline-lane-chip { font-size: 10px; }
.timeline-lane-chip.lane-in_progress { color: var(--accent); }
.timeline-lane-chip.lane-done, .timeline-lane-chip.lane-archived { color: var(--ok); }
.timeline-lane-chip.lane-blocked, .timeline-lane-chip.lane-human_action { color: var(--warn); }

.timeline-chart {
  flex: 1;
  min-width: 0;
  min-height: 48px; /* room for the hint of an empty timeline */
  position: relative;
  overflow: hidden;
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
}
.timeline-chart.hit { cursor: pointer; }
.timeline-chart.panning, .timeline-head.panning { cursor: grabbing; }
.timeline-svg { display: block; }
.timeline-hint { position: absolute; top: 12px; left: 12px; right: 12px; color: var(--muted); font-size: 13px; pointer-events: none; }

.tl-grid { stroke: var(--border-soft); stroke-width: 1; fill: none; }
.tl-span { fill: var(--tl-span); stroke: color-mix(in srgb, var(--accent) 35%, var(--border)); stroke-width: 1; }
.tl-lane.deleted .tl-span { stroke-dasharray: 3 3; }
.tl-wait { fill: var(--tl-wait); }
.tl-wait-human { fill: url(#tl-hatch); stroke: var(--warn); stroke-width: 1; }
.tl-hatch-bg { fill: color-mix(in srgb, var(--warn) 14%, transparent); }
.tl-hatch-line { stroke: var(--warn); stroke-width: 2; }
.tl-bar { stroke: color-mix(in srgb, #000 35%, transparent); stroke-width: 0.5; rx: 2; }
.tl-bar.open { stroke: var(--text); stroke-width: 1; }
.tl-bar.overflow { opacity: 0.6; }
.tl-bar.tick { rx: 0; }
.tl-bar:focus { outline: none; stroke: var(--text); stroke-width: 2; }
.tl-bar-label { fill: #0d1117; font-size: 10px; font-weight: 600; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; pointer-events: none; }
.tl-overflow { fill: var(--muted); font-size: 10px; pointer-events: none; }
.tl-now { stroke: var(--danger); stroke-width: 1; pointer-events: none; }

.timeline-tooltip {
  position: fixed;
  z-index: 50;
  max-width: 360px;
  padding: 6px 9px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  pointer-events: none;
  overflow-wrap: anywhere;
}
.timeline-tip-title { font-weight: 700; }
.timeline-tip-more { color: var(--muted); }
