/* million-workflows: proof-of-concept viewer.
 *
 * Deliberately plain CSS: the demo has no build step and no framework, so this file is the whole
 * stylesheet. Light theme, high contrast, and colour used only to encode meaning (node status,
 * level of automation, loop membership) rather than decoration. */

:root {
  --bg: #fbfaf7;
  --panel: #ffffff;
  --ink: #1b1f24;
  --ink-soft: #5b6570;
  --ink-faint: #8a939c;
  --line: #e2e0da;
  --line-strong: #c9c5bb;
  --accent: #2f6f4f;

  /* node status: the honesty axis of the whole demo */
  --st-resolved: #2f6f4f;   /* really runs here */
  --st-simulated: #b4802a;  /* runs, but is NOT a contribution */
  --st-human: #4a6fa5;      /* a human channel */
  --st-stub: #9aa1a8;       /* nothing implemented yet */
  --st-unknown: #9aa1a8;
  --st-failed: #b3453a;
  --st-gated: #7a5aa8;      /* credential-gated */

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------- chrome */

header.top {
  display: flex;
  align-items: baseline;
  gap: 18px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex: none;
}

header.top h1 { font-size: 15px; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
header.top .sub { color: var(--ink-faint); font-size: 12px; }

nav.tabs { display: flex; gap: 2px; margin-left: auto; }
nav.tabs button {
  font: inherit; font-size: 13px;
  padding: 5px 12px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
}
nav.tabs button:hover { background: #f2f0eb; color: var(--ink); }
nav.tabs button[aria-selected="true"] {
  background: #eef3ef; border-color: #cfe0d6; color: var(--accent); font-weight: 600;
}

main { flex: 1; min-height: 0; overflow: hidden; }
.view { display: none; height: 100%; }
.view.active { display: flex; }

/* ------------------------------------------------------------- workflow view */

#view-workflow { flex-direction: row; }

aside.rail {
  width: 268px;
  flex: none;
  border-right: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
  padding: 14px 0;
}

.rail h2 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-faint); margin: 0 0 6px; padding: 0 16px; font-weight: 600;
}

.rail .wf-item {
  display: block; width: 100%; text-align: left;
  padding: 9px 16px; border: 0; background: none; cursor: pointer;
  font: inherit; border-left: 2px solid transparent;
}
.rail .wf-item:hover { background: #f6f4f0; }
.rail .wf-item[aria-current="true"] {
  background: #eef3ef; border-left-color: var(--accent);
}
.rail .wf-item .t { font-weight: 600; display: block; }
.rail .wf-item .m { color: var(--ink-faint); font-size: 12px; display: block; margin-top: 1px; }

.stage { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.stage .head { padding: 16px 22px 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
.stage .head h2 { margin: 0 0 3px; font-size: 17px; letter-spacing: -0.01em; }
.stage .head p { margin: 0; color: var(--ink-soft); max-width: 96ch; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  font-size: 11.5px; padding: 2px 8px; border-radius: 11px;
  border: 1px solid var(--line-strong); color: var(--ink-soft); background: #fff;
  font-variant-numeric: tabular-nums;
}
.chip b { font-weight: 650; color: var(--ink); }
.chip.ok { border-color: #cfe0d6; background: #eef3ef; color: var(--accent); }
.chip.bad { border-color: #e6c9c5; background: #fbeeec; color: var(--st-failed); }

/* ------------------------------------------------------------ graph canvas */
/* A node-editor canvas: the pane owns the gestures, the <g class="canvas"> carries the pan/zoom
   transform, and nothing re-flows when a node is dragged. */

.graph-pane { flex: 1; min-height: 0; overflow: hidden; position: relative;
  background:
    radial-gradient(circle at 1px 1px, #e6e3dc 1px, transparent 0) 0 0 / 22px 22px,
    var(--bg);
  cursor: grab; }
.graph-pane.panning { cursor: grabbing; }
svg.graph { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; }
svg.graph .canvas { will-change: transform; }

.tools { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.tools button {
  font: inherit; font-size: 12px; min-width: 26px; padding: 2px 8px; border-radius: 5px;
  border: 1px solid var(--line-strong); background: #fff; cursor: pointer; color: var(--ink-soft);
}
.tools button:hover { border-color: var(--accent); color: var(--accent); }
.tools .hint { color: var(--ink-faint); font-size: 11.5px; margin-left: 4px; }

/* nodes */
.node { cursor: grab; }
.node.dragging { cursor: grabbing; }
.node .body { fill: #fff; stroke: var(--line-strong); stroke-width: 1.4; }
.node.human .body { stroke: var(--st-human); }
.node.simulated .body { stroke: var(--st-simulated); }
.node.stub .body { stroke: var(--st-stub); stroke-dasharray: 3 3; }
.node.resolved .body { stroke: var(--st-resolved); }
.node:hover .body { stroke-width: 2.2; }
.node.sel .body { stroke: var(--accent); stroke-width: 2.6; fill: #f4f8f5; }
.node { transition: opacity .12s linear; }
.node.dim { opacity: 0.28; }
.node.near .body { stroke-width: 1.8; }
.node text { font-family: var(--sans); pointer-events: none; }
.node .ntype { font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase; fill: var(--ink-faint); }
.node .nlabel { font-size: 12.5px; fill: var(--ink); font-weight: 600; }
.node .strip { rx: 1.5; }
/* the header/rows separator: a hairline that keeps the label from reading as a socket name */
.node .head-sep { stroke: var(--line); stroke-width: 1; }

/* sockets: the dot is the click target of an edge, the label names the data */
.socket .socket-dot { fill: #fff; stroke: var(--line-strong); stroke-width: 1.4; }
.socket .socket-name { font-size: 10px; fill: var(--ink-soft); font-family: var(--mono); }
.socket .socket-name.dead { fill: var(--ink-faint); font-style: italic; }
.socket.in .socket-dot { stroke: #9aa1a8; }
.socket.out .socket-dot { stroke: var(--accent); }
.socket:hover .socket-dot { fill: var(--accent); stroke: var(--accent); }
.node.dim .socket { opacity: 0.4; }

/* edges: a thin visible line over a fat invisible hit area */
.edge-group { transition: opacity .12s linear; }
.edge-group.dim { opacity: 0.12; }
.edge { fill: none; stroke: #a49b8c; stroke-width: 1.5; }
.edge-hit { fill: none; stroke: transparent; stroke-width: 14; cursor: pointer; }
.edge-group.back .edge { stroke: #b07d3a; stroke-dasharray: 5 4; stroke-width: 1.5; }
.edge-group.hi .edge { stroke: var(--accent); stroke-width: 2.4; }
.edge-group:hover .edge { stroke: var(--accent); stroke-width: 2; }

.loop-group { transition: opacity .12s linear; }
.loop-group.dim { opacity: 0.3; }
.loop-band { fill: #b07d3a; opacity: 0.05; stroke: #b07d3a; stroke-opacity: 0.3; stroke-dasharray: 4 4; }
.loop-ring { fill: none; stroke: #b07d3a; stroke-opacity: 0.25; stroke-width: 1; }
.loop-title { font-size: 10px; fill: #8a6224; font-family: var(--mono); }

/* inspector */
aside.inspector {
  width: 396px; flex: none; border-left: 1px solid var(--line);
  background: var(--panel); overflow-y: auto; padding: 16px 18px 40px;
}
.inspector h3 { margin: 0 0 2px; font-size: 15px; }
.inspector .id { font-family: var(--mono); font-size: 11.5px; color: var(--ink-faint); }
.inspector h4 {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-faint); margin: 16px 0 5px; font-weight: 650;
}
.inspector p { margin: 0 0 8px; color: var(--ink-soft); }
.inspector table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.inspector td { padding: 2px 0; vertical-align: top; }
.inspector td:first-child { color: var(--ink-faint); padding-right: 10px; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 11.5px; }
code.block {
  display: block; font-family: var(--mono); font-size: 11px; white-space: pre-wrap;
  background: #f6f4f0; border: 1px solid var(--line); border-radius: 5px;
  padding: 7px 9px; color: #333a41; word-break: break-all;
}
.socket { display: flex; align-items: baseline; gap: 6px; padding: 3px 0; font-size: 12.5px; }
.socket .dir { font-family: var(--mono); color: var(--ink-faint); width: 12px; }
.socket .kind { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); margin-left: auto; }
.socket .art { font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint); }
.badge {
  display: inline-block; font-size: 10.5px; padding: 1px 7px; border-radius: 9px;
  border: 1px solid currentColor; font-weight: 600;
}
.badge.resolved { color: var(--st-resolved); }
.badge.simulated { color: var(--st-simulated); }
.badge.human { color: var(--st-human); }
.badge.stub, .badge.unknown { color: var(--st-stub); }
.badge.failed { color: var(--st-failed); }
.badge.credential-gated { color: var(--st-gated); }

/* ------------------------------------------------------------- data tables */

#view-catalog, #view-taxonomy, #view-runs { flex-direction: column; overflow-y: auto; }
.pad { padding: 18px 22px 60px; max-width: 1180px; }
.pad h2 { margin: 0 0 4px; font-size: 17px; }
.pad h3 { margin: 26px 0 8px; font-size: 14px; }
.pad p.lead { color: var(--ink-soft); margin: 0 0 8px; }

table.grid { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.grid th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-faint); border-bottom: 1px solid var(--line-strong); padding: 5px 9px 5px 0;
  font-weight: 650; position: sticky; top: 0; background: var(--bg);
}
table.grid td { padding: 4px 9px 4px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid tr:hover td { background: #f8f6f2; }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
a { color: var(--accent); }

.bar { display: inline-block; height: 7px; border-radius: 3px; background: var(--st-resolved); vertical-align: middle; }
.bar.sim { background: var(--st-simulated); }

/* runs */
.run-pick { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 16px; }
.run-pick button {
  font: inherit; font-size: 12px; padding: 4px 10px; border-radius: 5px;
  border: 1px solid var(--line-strong); background: #fff; cursor: pointer;
}
.run-pick button[aria-current="true"] { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.status-pill { font-family: var(--mono); font-size: 10.5px; font-weight: 600; }
.status-pill.ok { color: var(--st-resolved); }
.status-pill.pending-human { color: var(--st-human); }
.status-pill.credential-gated { color: var(--st-gated); }
.status-pill.error { color: var(--st-failed); }

.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 11.5px; color: var(--ink-soft); margin-top: 10px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; border: 1.5px solid; }
.legend i.solid { background: #fff; }

.empty { color: var(--ink-faint); font-style: italic; }
