/* Processes view (#427). The page styles (T5) come first or last in this file; the diagram has its own block. */

/* ==== process diagram (#430, js/process_diagram.js): one SVG, steps and transitions, pan and zoom ==== */
.proc-diagram {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 240px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: grab;
  touch-action: none; /* a touch drag pans: there is no native scroll here */
}
.proc-diagram.panning { cursor: grabbing; user-select: none; }
.proc-svg { display: block; width: 100%; height: 100%; }

/* the lane colours of the Dependencies view (deps.css: .deps-card.lane-*); the steps are filled by their lane */
.proc-node { --lane-color: var(--muted); }
.proc-node.proc-lane-in_progress { --lane-color: var(--accent); }
.proc-node.proc-lane-in_review { --lane-color: #c084fc; }
.proc-node.proc-lane-blocked,
.proc-node.proc-lane-human_action { --lane-color: var(--warn); }
.proc-node.proc-lane-done { --lane-color: var(--ok); }

/* steps */
.proc-node { cursor: pointer; outline: none; }
.proc-shape {
  fill: color-mix(in srgb, var(--lane-color) 16%, var(--panel));
  stroke: color-mix(in srgb, var(--lane-color) 70%, var(--border));
  stroke-width: 1.5;
  transition: stroke 0.12s, fill 0.12s;
}
.proc-shape-inner { fill: none; stroke: color-mix(in srgb, var(--lane-color) 70%, var(--border)); stroke-width: 1; }
.proc-escape .proc-shape { stroke-dasharray: 6 4; } /* reachable from any step */
.proc-node-name { fill: var(--text); font-size: 12px; font-weight: 600; pointer-events: none; }
.proc-node-sub { fill: var(--muted); font-size: 10px; pointer-events: none; }
.proc-start-marker circle { fill: var(--accent); }
.proc-start-marker path { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.proc-node:hover .proc-shape,
.proc-node.proc-related .proc-shape { stroke: var(--muted-2); }
.proc-node.proc-hl .proc-shape,
.proc-node:focus-visible .proc-shape { stroke: var(--accent); stroke-width: 2.2; }
.proc-node.proc-selected .proc-shape {
  stroke: var(--accent);
  stroke-width: 2.6;
  fill: color-mix(in srgb, var(--accent) 22%, var(--panel));
}

/* transitions: the line, a wide transparent path to hit it, and the label (the focusable button) */
.proc-edge-line { fill: none; stroke: var(--muted-2); stroke-width: 1.6; transition: stroke 0.12s, opacity 0.12s; pointer-events: none; }
.proc-edge-back .proc-edge-line { stroke-dasharray: 6 4; stroke: var(--muted); } /* a way back: dashed, under the steps */
.proc-edge-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
.proc-edge-label { cursor: pointer; outline: none; }
.proc-edge-label-bg { fill: var(--panel-2); stroke: var(--border); stroke-width: 1; transition: stroke 0.12s; }
.proc-edge-max .proc-edge-label-bg { stroke: var(--warn); } /* a limit: after it the triager decides */
.proc-edge-label-text { fill: var(--muted); font-size: 11px; pointer-events: none; }
.proc-edge.proc-hl .proc-edge-line,
.proc-edge:hover .proc-edge-line { stroke: var(--accent); stroke-width: 2.4; }
.proc-edge.proc-hl .proc-edge-label-bg,
.proc-edge-label:focus-visible .proc-edge-label-bg { stroke: var(--accent); }
.proc-edge.proc-hl .proc-edge-label-text { fill: var(--text); }
.proc-edge.proc-selected .proc-edge-line { stroke: var(--accent); stroke-width: 3; }
.proc-edge.proc-selected .proc-edge-label-bg { stroke: var(--accent); fill: color-mix(in srgb, var(--accent) 22%, var(--panel-2)); }
.proc-edge.proc-selected .proc-edge-label-text { fill: var(--text); }
.proc-arrow-head { fill: var(--muted-2); }
.proc-arrow-back { fill: var(--muted); }
.proc-arrow-hl { fill: var(--accent); }
/* with something highlighted, the transitions that do not touch it recede */
.proc-highlighting .proc-edge:not(.proc-hl):not(.proc-selected) { opacity: 0.3; }

/* the path a ticket took (#478, the ticket window's Process flow): thick over the template, the rest recedes */
.proc-has-path .proc-edge:not(.proc-taken) .proc-edge-line { opacity: 0.45; }
.proc-has-path .proc-node:not(.proc-taken) .proc-shape, .proc-has-path .proc-node.proc-cleared .proc-shape { opacity: 0.55; }
.proc-edge.proc-taken .proc-edge-line { stroke: var(--accent); stroke-width: 4.5; stroke-dasharray: none; stroke-linecap: round; }
.proc-edge.proc-taken .proc-edge-label-bg { stroke: var(--accent); }
.proc-edge.proc-taken .proc-edge-label-text { fill: var(--text); }
.proc-edge.proc-repeated .proc-edge-label-text { font-weight: 600; }
.proc-edge.proc-refused .proc-edge-line { stroke: var(--warn); stroke-dasharray: 3 4; opacity: 1; }
.proc-edge.proc-refused .proc-edge-label-bg { stroke: var(--warn); }
.proc-arrow-taken { fill: var(--accent); }
.proc-node.proc-taken:not(.proc-cleared) .proc-shape { stroke: var(--accent); stroke-width: 3; }
/* #570: a completed step (taken, not the current one) is green, the current one stays blue;
   #605: one a back-turn cleared (proc-cleared) looks like a step not run, its "(n times)" stays */
.proc-node.proc-taken:not(.proc-current):not(.proc-cleared) .proc-shape { stroke: var(--ok); fill: color-mix(in srgb, var(--ok) 16%, var(--panel)); }
.proc-node.proc-current .proc-shape { stroke-width: 4; fill: color-mix(in srgb, var(--accent) 26%, var(--panel)); }
/* #627: the step the ticket stands on (not one its process ended at) is alive like an active card: a soft glow
   that fades slowly up and down (base.css alive-fade) and the ECG icon upper right (process_diagram.js) */
.proc-node.proc-live .proc-shape {
  animation: alive-fade 1.6s ease-in-out infinite;
  filter: drop-shadow(0 0 calc(2px + 6px * var(--alive)) color-mix(in srgb, var(--accent) calc(35% + 45% * var(--alive)), transparent));
}
.proc-times-bg { fill: var(--accent); stroke: var(--panel); stroke-width: 1.5; }
.proc-times-text { fill: var(--bg); font-size: 10.5px; font-weight: 700; pointer-events: none; }

.proc-zoom { position: absolute; top: 8px; right: 8px; display: inline-flex; gap: 4px; }
.proc-zoom-btn.active { border-color: var(--accent); color: var(--accent); }
/* ==== end of the process diagram ==== */

/* ==== the Processes page (#433, js/processes.js): the list of the process files; a process opens in a window
   (#542, kind "process"): the header and the diagram, the details aside ==== */
.processes-view {
  height: 100%;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  font-size: 13px;
}
.proc-list-hint { margin: 0; max-width: 320px; }

/* a column at the left: the process windows open at the right edge (windows_core.js defaultRect), so it stays in reach */
.proc-list {
  width: 320px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.proc-list-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  width: 100%;
  padding: 8px 10px;
  text-align: left;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
}
.proc-list-item:hover { border-color: var(--muted-2); }
.proc-list-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.proc-list-item.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.proc-list-item.invalid .proc-list-name { color: var(--danger); }
.proc-list-item.disabled .proc-list-name { color: var(--muted); text-decoration: line-through; }
.proc-list-name { font-weight: 600; }
.proc-list-id { font-size: 11px; color: var(--muted); }
.proc-list-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.proc-list-description { color: var(--muted); font-size: 12px; line-height: 1.4; }
/* the built-in files (#543): no ticket starts on them any more, so they sit below the processes a ticket can follow */
.proc-group { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.proc-group-title { margin: 0; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }

/* #562: the problems of the project's process files, above the list; a disabled group is dimmed like its entries */
.proc-problems {
  width: 320px; max-width: 100%; box-sizing: border-box;
  margin-bottom: 8px;
  padding: 8px 10px;
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 10%, var(--panel));
  border: 1px solid var(--warn);
  border-radius: var(--radius);
}
.proc-problems h4 { margin: 0 0 4px; font-size: 12px; }
.proc-problems ul { margin: 0; padding-left: 18px; overflow-wrap: anywhere; }
.proc-group-disabled .proc-list-item { opacity: 0.8; }
.proc-fork-hint { margin: 0; font-size: 12px; overflow-wrap: anywhere; }

/* a process window: always kept (an outside click or a view switch must not close it), so no keep toggle */
.window-process .window-keep { display: none; }
.taskbar-badge-process { background: var(--ok); }
.window-process .window-body { container-type: inline-size; }
.proc-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 8px;
  padding: 10px;
  font-size: 13px;
}

.proc-chips, .proc-inline-chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.proc-inline-chips { display: inline-flex; margin-left: 6px; }
.proc-chip {
  display: inline-block;
  padding: 1px 7px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
}
.proc-chip-builtin { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.proc-chip-invalid { color: var(--danger); border-color: var(--danger); }
.proc-chip-max { color: var(--warn); border-color: var(--warn); }
.proc-chip-project { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, var(--border)); } /* #562: defined in the project's own processes dir */
.proc-chip-disabled { color: var(--warn); border-color: var(--warn); } /* #562: switched off by the project's _library.yaml */
.proc-chip-start { color: var(--accent); }
.proc-chip-lane { color: var(--text); }
.proc-chip.proc-lane-in_progress { border-color: var(--accent); }
.proc-chip.proc-lane-in_review { border-color: #c084fc; }
.proc-chip.proc-lane-blocked, .proc-chip.proc-lane-human_action { border-color: var(--warn); }
.proc-chip.proc-lane-done { border-color: var(--ok); }

.proc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; overflow: auto; }
.proc-head { flex: none; display: flex; flex-direction: column; gap: 6px; }
.proc-title-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.proc-title { margin: 0; font-size: 18px; }
.proc-id { color: var(--muted); font-size: 12px; }
.proc-gap { flex: 1; }
.proc-toggle.active { border-color: var(--accent); color: var(--accent); }
.proc-description { margin: 0; line-height: 1.45; max-width: 90ch; }
.proc-more, .proc-yaml {
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.proc-more { display: flex; flex-direction: column; gap: 8px; max-width: 100ch; }
.proc-about, .proc-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; margin: 0; }
.proc-messages h4 { margin: 0 0 4px; font-size: 12px; }
.proc-messages ul { margin: 0; padding-left: 18px; }
.proc-errors { color: var(--danger); }
.proc-warnings { color: var(--warn); }
.proc-yaml { margin: 0; max-height: 40vh; overflow: auto; font-size: 12px; line-height: 1.4; white-space: pre; tab-size: 2; }

.proc-diagram-host { flex: 1 0 320px; min-height: 320px; min-width: 0; position: relative; }
.proc-loading, .proc-empty, .proc-muted, .proc-hint { color: var(--muted); }
.proc-loading, .proc-empty { padding: 12px 0; }
.proc-error { color: var(--danger); padding: 12px 0; }
.proc-invalid {
  padding: 12px 14px;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--danger) 8%, var(--panel));
}
.proc-invalid h3 { margin: 0 0 6px; font-size: 14px; color: var(--danger); }
.proc-error-list { margin: 0 0 8px; padding-left: 18px; }

/* the details aside, like the Git view's commit detail */
.proc-detail {
  flex: 0 0 340px;
  min-width: 0;
  overflow: auto;
  padding: 10px 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}
.proc-detail:focus { outline: none; }
.proc-detail-head { display: flex; align-items: center; gap: 8px; }
.proc-detail-kicker { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.proc-detail-close { margin-left: auto; }
.proc-detail-title { margin: 4px 0 6px; font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; }
.proc-section { margin-top: 12px; }
.proc-section h4 { margin: 0 0 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.proc-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 10px 0 0; }
.proc-facts dt { color: var(--muted); }
.proc-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.proc-ways, .proc-gates, .proc-always ul, .proc-code { margin: 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.proc-always { margin-top: 6px; }
.proc-always ul { padding-left: 16px; list-style: disc; }
.proc-max { margin: 6px 0 0; }
.proc-link {
  padding: 0;
  color: var(--accent);
  background: none;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.proc-link:hover { text-decoration: underline; }
.proc-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.proc-prompt { margin: 0; padding: 6px 8px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; background: var(--panel-2); border-radius: var(--radius); }
.proc-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.proc-table th { text-align: left; color: var(--muted); font-weight: 600; }
.proc-table th, .proc-table td { padding: 4px 6px 4px 0; vertical-align: top; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.proc-code li { font-size: 12px; overflow-wrap: anywhere; }
.proc-settings td:first-child { width: 60%; }
.proc-hint { margin: 14px 0 0; font-size: 12px; }

/* phone width: the list spans the screen */
@media (max-width: 760px) {
  .processes-view { padding: 6px; }
  .proc-list, .proc-list-hint, .proc-problems { width: auto; max-width: none; }
}
/* a narrow process window (a phone fills the layer with it): everything stacks and the window scrolls as a whole */
@container (max-width: 700px) {
  .proc-pane { flex-direction: column; overflow: auto; padding: 6px; }
  .proc-main { flex: none; overflow: visible; }
  .proc-diagram-host { flex: none; height: 300px; min-height: 300px; }
  .proc-detail { flex: none; overflow: visible; }
}
/* ==== end of the Processes page ==== */
.proc-chip-unavailable { color: var(--warn); border-color: var(--warn); } /* #470: valid, but not selectable yet */

/* ==== the Agents section of a pass window (#602, js/process_flow_ui.js passAgentsView): the pass's agents, the live
   ones first; an entry opens the agent's window. A live agent's badge is .lit: it beats with --activity (#578) ==== */
.pass-agents { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pass-agents-head { flex-basis: 100%; color: var(--muted-2); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.pass-agent {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 12px;
}
a.pass-agent { cursor: pointer; text-decoration: none; } /* an agent ref (#1161) */
a.pass-agent:hover, a.pass-agent:focus-visible { border-color: var(--accent); text-decoration: none; }
.pass-agent.is-live { border-color: var(--ok); }
.pass-agent-id { font-weight: 600; }
.pass-agent-model, .pass-agent-status { color: var(--muted); }
.pass-agent.is-live .pass-agent-status { color: var(--ok); font-weight: 600; }
