/* Copyright 2026, Niklas Hauser
 * SPDX-License-Identifier: MPL-2.0
 * The clock graph of graph-view.js, on top of ../shared/theme.css.
 * Green = the clock flows here, grey = idle, red = breaks a limit. */

:root { --cg-idle: #A9B1AD; --cg-used: #DDF1E4; --cg-target: #3557B7; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --cg-idle: #4A5752; --cg-used: #1C3A2A; --cg-target: #9DB4F5; }
}
:root[data-theme="dark"] { --cg-idle: #4A5752; --cg-used: #1C3A2A; --cg-target: #9DB4F5; }

.clock-graph { position: relative; overflow: hidden; cursor: grab; touch-action: none; min-height: 200px; }
.clock-graph.panning { cursor: grabbing; }
.clock-graph .cg-pan { position: absolute; left: 0; top: 0; will-change: transform; }
.clock-graph .cg-world { position: relative; }
.clock-graph .cg-wires { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.clock-graph .cg-wires path { fill: none; stroke: var(--rule); stroke-width: 1; }
.clock-graph .cg-wires path.sel { stroke: var(--cg-idle); stroke-width: 1.4; }
.clock-graph .cg-wires path.live { stroke: var(--ok); stroke-width: 2.2; }
.clock-graph .cg-wires path.alt { stroke: var(--cg-idle); stroke-dasharray: 3 3; }

.clock-graph .node {
  position: absolute; width: 172px; background: var(--surface); border: 1px solid var(--rule); border-radius: 7px;
  padding: 4px 6px 5px; font-size: 11px; overflow: hidden; color: var(--ink);
}
.clock-graph .node.used { background: var(--cg-used); }
.clock-graph .node.locked { border-color: var(--warn); }
.clock-graph .node.target { border-color: var(--cg-target); box-shadow: 0 0 0 1px var(--cg-target); }
.clock-graph .node.bad { border-color: var(--error); box-shadow: 0 0 0 2px color-mix(in srgb, var(--error) 30%, transparent); }
.clock-graph .node.periph { width: 150px; }
.clock-graph .node.wide { width: 250px; }
.clock-graph .node.alt { opacity: 0.55; border-style: dashed; }
.clock-graph .head {
  display: flex; justify-content: space-between; align-items: center; gap: 4px; font: 600 10.5px var(--font-mono);
}
.clock-graph.editable .head { cursor: move; }
.clock-graph .head .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clock-graph .kind { font: 9px var(--font-mono); color: var(--muted); text-transform: uppercase; }
.clock-graph .hz { font: 600 12px var(--font-mono); }
.clock-graph .hz.none { color: var(--muted); font-weight: 400; }
.clock-graph .row { display: flex; gap: 4px; align-items: center; margin-top: 3px; }
.clock-graph .row select, .clock-graph .row input {
  flex: 1; min-width: 0; width: auto; padding: 1px 4px; border: 1px solid var(--rule); border-radius: 5px;
  background: var(--surface); color: var(--ink); font: 10.5px var(--font-mono);
}
.clock-graph .lbl { font: 9.5px var(--font-mono); color: var(--muted); white-space: nowrap; }
.clock-graph .setting { font: 10.5px var(--font-mono); color: var(--ink); }
.clock-graph .row input.tgt { width: 74px; flex: none; }
.clock-graph .tgt.set { border-color: var(--cg-target); color: var(--cg-target); font-weight: 600; }
.clock-graph .lim { font: 9.5px var(--font-mono); color: var(--muted); margin-top: 2px; }
.clock-graph .lim.bad { color: var(--error); }
.clock-graph .chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.clock-graph .chip {
  padding: 0 5px; border-radius: 4px; border: 1px solid var(--cg-idle); background: var(--surface); color: var(--muted);
  font: 10.5px var(--font-mono); cursor: pointer;
}
.clock-graph .chip.sel { border-color: var(--ink); color: var(--ink); box-shadow: inset 0 -2px 0 currentColor; }
.clock-graph .chip.sel.ok { border-color: var(--ok); color: var(--ok); }
.clock-graph .feeds {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0 4px; margin-top: 4px; padding-top: 3px;
  border-top: 1px dashed var(--rule); font: 9.5px var(--font-mono); color: var(--muted);
}
.clock-graph .feed { display: flex; align-items: center; gap: 2px; white-space: nowrap; overflow: hidden; }
.clock-graph.editable .feed { cursor: pointer; }
.clock-graph .feed input { margin: 0; width: 10px; height: 10px; }
.clock-graph .feed.on { color: var(--ink); }
.clock-graph .feed.bad { color: var(--error); font-weight: 600; }
.clock-graph .lockbtn { border: none; background: none; cursor: pointer; padding: 0; font-size: 11px; color: var(--muted); }
.clock-graph .lockbtn.on { color: var(--warn); }

.clock-graph .cg-hud {
  position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px; background: var(--surface);
  border: 1px solid var(--rule); border-radius: 7px; padding: 4px;
}
.clock-graph .cg-hud button {
  padding: 4px 10px; border: 1px solid var(--accent); border-radius: 6px; background: transparent; color: var(--accent);
  font: 600 12px var(--font-sans); cursor: pointer;
}
.clock-graph .cg-hud button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
