/* ===========================================================================
   FLOWWORKS — the theme.

   A drawing-office blueprint. Not because blueprints are pretty, but because
   the thing on screen IS a diagram of a mechanism, and a diagram has its own
   long-settled visual language: a grid you can measure against, thin confident
   lines, labels in small caps, and no decoration whatsoever.

   - Ground is a deep desaturated blue-slate with a drawn grid, at two
     weights, like real gridded paper.
   - Nodes are plates: flat, square-shouldered, with a coloured spine down the
     left that says what KIND of block it is. Four kinds, four colours, and
     the colour never means anything else.
   - Wires are 1.5px and carry a count. A wire nothing went down is dimmed
     rather than hidden, because "nothing took this branch" is information.
   - The tokens that travel the wires are the only animation, and they are
     literal: one dot is one record.
   =========================================================================== */
:root{
  --bg:#101822;
  --grid:rgba(120,170,210,.055);
  --grid-2:rgba(120,170,210,.115);
  --plate:#18222E;
  --plate-2:#1E2A38;
  --line:rgba(150,190,220,.16);
  --line-2:rgba(150,190,220,.30);
  --ink:#E4EDF5;
  --ink-2:#9FB3C6;
  --mut:#7288A1;
  --trig:#41C8E0;      /* when something happens */
  --cond:#E0B341;      /* a question */
  --act:#5BD394;       /* something is done */
  --stop:#E2657A;      /* nothing more happens */
  --wire:#5E86A8;
  --ui:var(--f-text);
  --mono:var(--f-data);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;height:100vh;display:flex;flex-direction:column;overflow:hidden;
  color:var(--ink);font:14px/1.5 var(--ui);-webkit-font-smoothing:antialiased;
  background:
    linear-gradient(var(--grid) 1px,transparent 1px) 0 0/22px 22px,
    linear-gradient(90deg,var(--grid) 1px,transparent 1px) 0 0/22px 22px,
    linear-gradient(var(--grid-2) 1px,transparent 1px) 0 0/110px 110px,
    linear-gradient(90deg,var(--grid-2) 1px,transparent 1px) 0 0/110px 110px,
    var(--bg);
}
button,input,select{font:inherit;color:inherit}

#flow{flex:1;min-height:0;display:flex;flex-direction:column}

/* ------------------------------------------------------------------- head */
.hd{
  flex:none;display:flex;align-items:center;gap:16px;padding:12px 20px;
  border-bottom:1px solid var(--line);background:rgba(16,24,34,.82);
  backdrop-filter:blur(8px);
}
.hd .ttl{min-width:0}
.hd .ttl b{display:block;font-size:15px;font-weight:650;letter-spacing:-.01em}
.hd .ttl span{font-size:12px;color:var(--mut)}
.hd .acts{margin-left:auto;display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.bt{
  height:34px;padding:0 14px;border:1px solid var(--line-2);border-radius:4px;
  background:transparent;color:var(--ink-2);cursor:pointer;font-size:13px;
  font-weight:600;display:inline-flex;align-items:center;gap:8px;transition:.14s;
  white-space:nowrap;
}
.bt:hover:not(:disabled){background:var(--plate-2);color:#fff;border-color:var(--ink-2)}
.bt:disabled{opacity:.42;cursor:default}
.bt.go{background:var(--trig);border-color:var(--trig);color:#04222B}
.bt.go:hover:not(:disabled){filter:brightness(1.12)}
.bt.warn{border-color:var(--cond);color:var(--cond)}
.bt svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:2;
  stroke-linecap:round;stroke-linejoin:round}

/* ------------------------------------------------------------------ body */
.body{flex:1;min-height:0;display:grid;grid-template-columns:1fr 348px}
.canvas{position:relative;min-width:0;overflow:auto}
.canvas svg{display:block;min-width:940px;width:100%;height:auto}

/* the plates */
.node .plate{fill:var(--plate);stroke:var(--line-2);stroke-width:1.2}
.node:hover .plate{fill:var(--plate-2);stroke:var(--ink-2)}
.node.on .plate{stroke:#fff;stroke-width:2}
.node .spine{stroke-width:0}
.node .kind{font:700 8.5px var(--ui);letter-spacing:.18em;text-transform:uppercase}
.node .name{font:650 13px var(--ui);fill:var(--ink)}
.node .parm{font:600 11.5px var(--mono);fill:var(--ink-2)}
.node .cnt{font:700 12px var(--mono);fill:#fff}
.node .cntbg{fill:rgba(255,255,255,.10);stroke:var(--line-2);stroke-width:1}
.node{cursor:pointer}
.node.off .plate{stroke-dasharray:4 4;opacity:.5}
.node.off .name,.node.off .parm,.node.off .kind{opacity:.5}

.wire{fill:none;stroke:var(--wire);stroke-width:1.5;opacity:.6}
.wire.hot{stroke:var(--trig);opacity:1;stroke-width:2}
.wire.dead{stroke:var(--wire);opacity:.18;stroke-dasharray:3 5}
.wlab{font:700 10px var(--mono);fill:var(--ink-2)}
.wlab.zero{fill:var(--mut);opacity:.6}
.wtag{font:700 8.5px var(--ui);letter-spacing:.12em;fill:var(--mut);
  text-transform:uppercase}
.tok{fill:var(--trig);opacity:.95}
.tok.no{fill:var(--stop)}

/* ------------------------------------------------------------------ side */
.side{
  min-width:0;border-left:1px solid var(--line);overflow-y:auto;
  background:rgba(20,30,42,.72);
}
.sec{padding:15px 17px;border-bottom:1px solid var(--line)}
.sec h3{
  margin:0 0 11px;font:700 10.5px var(--ui);letter-spacing:.15em;
  text-transform:uppercase;color:var(--mut);display:flex;align-items:center;gap:8px;
}
.sec h3 .n{margin-left:auto;font-family:var(--mono);letter-spacing:0;font-size:12px}
.sec p.lead{margin:0 0 12px;font-size:12.5px;color:var(--ink-2);line-height:1.6}

.knob{margin-bottom:15px}
.knob:last-child{margin-bottom:0}
.knob label{display:block;font-size:12.5px;font-weight:600;margin-bottom:6px}
.knob .rowx{display:flex;align-items:center;gap:10px}
.knob input[type=range]{flex:1;-webkit-appearance:none;appearance:none;height:20px;
  background:none;margin:0;cursor:pointer}
.knob input[type=range]::-webkit-slider-runnable-track{height:3px;
  background:var(--line-2);border-radius:2px}
.knob input[type=range]::-moz-range-track{height:3px;background:var(--line-2);
  border-radius:2px}
.knob input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:16px;
  height:16px;border-radius:50%;background:var(--trig);margin-top:-6.5px;
  border:2px solid var(--bg)}
.knob input[type=range]::-moz-range-thumb{width:16px;height:16px;border-radius:50%;
  background:var(--trig);border:2px solid var(--bg)}
.knob .val{font:700 14px var(--mono);color:var(--trig);min-width:64px;text-align:right}
.knob .hint{font-size:11.5px;color:var(--mut);line-height:1.5;margin:6px 0 0}
/* These are <button>s. Without resetting the UA's own background and border
   they rendered as three white plates with black-on-white labels invisible
   against the blueprint - the kind of thing that never shows up in a unit
   test and is the first thing anyone sees. */
.sw{
  display:flex;align-items:center;gap:10px;padding:9px 0;cursor:pointer;
  background:transparent;border:0;color:inherit;width:100%;text-align:left;
  font:inherit;
}
.sw:hover span:last-child{color:#fff}
.sw:focus-visible{outline:2px solid var(--trig);outline-offset:3px;border-radius:3px}
.sw .box{
  width:34px;height:19px;border-radius:10px;background:var(--line-2);flex:none;
  position:relative;transition:background .16s;
}
.sw .box i{
  position:absolute;top:2px;left:2px;width:15px;height:15px;border-radius:50%;
  background:#fff;transition:transform .16s;
}
.sw[aria-pressed=true] .box{background:var(--act)}
.sw[aria-pressed=true] .box i{transform:translateX(15px)}
.sw span{font-size:12.5px;font-weight:600}

/* the result of a run */
.res{margin:0;padding:0;list-style:none}
.res li{
  padding:9px 0;border-bottom:1px solid var(--line);font-size:12.5px;
  display:flex;gap:9px;align-items:baseline;
}
.res li:last-child{border-bottom:0}
.res .id{font-family:var(--mono);font-size:11px;color:var(--mut);flex:none}
.res .tx{flex:1;min-width:0;line-height:1.45}
.res .tx b{color:#fff;font-weight:600}
.res .badge{
  font:700 10.5px var(--ui);letter-spacing:.1em;text-transform:uppercase;flex:none;
  padding:2px 6px;border-radius:2px;
}
.b-act{background:rgba(91,211,148,.16);color:var(--act)}
.b-hold{background:rgba(224,179,65,.16);color:var(--cond)}
.b-none{background:rgba(255,255,255,.07);color:var(--mut)}
.empty{color:var(--mut);font-size:12.5px;line-height:1.6;margin:0}

.note{
  margin:0;padding:11px 12px;border-left:2px solid var(--cond);
  background:rgba(224,179,65,.07);font-size:11.5px;line-height:1.6;color:var(--ink-2);
}
.note b{color:var(--cond)}

.legend{display:flex;flex-wrap:wrap;gap:10px 16px;padding:10px 20px;flex:none;
  border-top:1px solid var(--line);background:rgba(16,24,34,.8);font-size:11.5px;
  color:var(--mut)}
.legend span{display:inline-flex;align-items:center;gap:7px}
.legend i{width:10px;height:10px;border-radius:2px;flex:none}

@media(max-width:1060px){
  .body{grid-template-columns:1fr}
  .side{border-left:0;border-top:1px solid var(--line)}
  body{height:auto;overflow:auto;display:block}
  #flow{height:auto}
  .canvas{overflow-x:auto}
}
@media(max-width:620px){
  .hd{flex-wrap:wrap;padding:11px 14px}
  .hd .acts{margin-left:0;width:100%}
  .sec{padding:13px 14px}
  .legend{padding:10px 14px}
}
@media(prefers-reduced-motion:reduce){.tok{display:none}}

/* ------------------------------------------------------- touch, on a phone */
@media(max-width:620px) and (pointer:coarse){
  .bt{min-height:44px}
  .knob input[type=range]{height:44px}
  .sw{min-height:44px}
}
