/* ==========================================================================
   Parallel Machines / charts.css
   Hand-built chart primitives (assets/js/charts/). Every colour comes from the
   surface's semantic tokens (tokens.css), so one chart works on sky and paper:
     sky   : white ink, white dots            paper : ink, ink dots, electric emphasis
   System rule: solid = live / now; square dots = the record / the comparison.
   Hairline solid axes, mono ticks, generous whitespace.
   ========================================================================== */

.pc,
.pc-legend {
  --pc-fg: var(--fg, currentColor);
  --pc-accent: var(--accent, currentColor);      /* electric on paper, white on blue */
  --pc-dot: var(--dot-color, currentColor);
  --pc-line: var(--line, rgba(127, 127, 127, .22));
  --pc-line-strong: var(--line-strong, rgba(127, 127, 127, .45));
  --pc-tick: var(--fg-3, currentColor);
  --pc-on-solid: var(--bg, #fff);                /* text printed on a solid fg block */
  --pc-record-o: .9;
  --pc-dim-o: .3;
}
.pc {
  position: relative;
  min-width: 0;
  color: var(--pc-fg);
}

.pc-plot {
  position: relative;
  width: 100%;
  height: var(--pc-h, 220px);
  border-radius: var(--r-1, 2px);
  touch-action: pan-y;
}
.pc-spark .pc-plot { height: var(--pc-h, 44px); }
.pc-series .pc-plot { height: var(--pc-h, 240px); }
.pc-river .pc-plot { height: var(--pc-h, 132px); }   /* until river.js sizes the plot to rows x cell + the axis */
.pc-plot:focus { outline: none; }
.pc-plot:focus-visible,
.pc-river__canvas:focus-visible {
  outline: 2px solid var(--focus, currentColor);
  outline-offset: 6px;
}
.pc-svg { display: block; overflow: visible; max-width: none; }

/* ---------- chrome ---------- */
.pc-grid { stroke: var(--pc-line); stroke-width: 1; shape-rendering: crispEdges; }
.pc-axis { stroke: var(--pc-line-strong); stroke-width: 1; shape-rendering: crispEdges; }
.pc-tick {
  fill: var(--pc-tick);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
}
.pc-tick--strong { fill: var(--pc-fg); font-weight: 500; }
/* the level label (series.js) keeps clear of the live line where it can; where a busy line still crosses it, a halo in
   the surface colour keeps it legible */
.pc-level-label { paint-order: stroke fill; stroke: var(--bg, #F5F7FF); stroke-width: 3px; stroke-linejoin: round; }
.pc-tick--unit { letter-spacing: .06em; }

/* ---------- marks ---------- */
.pc-live {
  fill: none;
  stroke: var(--pc-fg);
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.pc-live--2 { stroke-width: 2; }
.pc-record {
  fill: var(--pc-dot);
  opacity: var(--pc-record-o);
  shape-rendering: crispEdges;
}
.pc-record--partial { opacity: calc(var(--pc-record-o) * .4); }
.pc-record--marker { opacity: 1; }
.pc-record--level { opacity: calc(var(--pc-record-o) * .8); }
.pc-solid { fill: var(--pc-fg); }
.pc-solid--live { fill: var(--pc-accent); }
.pc-now { fill: var(--pc-accent); shape-rendering: crispEdges; }
.pc-now.is-tick { animation: pc-tick 700ms var(--ease, ease-out) 1; }
@keyframes pc-tick { 0% { opacity: .15; } 45% { opacity: 1; } }
.pc-focus { fill: var(--pc-fg); opacity: .08; }

/* crosshair */
.pc-cross { pointer-events: none; }
.pc-cross__line { stroke: var(--pc-fg); stroke-opacity: .5; stroke-width: 1; shape-rendering: crispEdges; }
.pc-cross__live { fill: var(--pc-accent); shape-rendering: crispEdges; }
.pc-cross__rec { fill: none; stroke: var(--pc-dot); stroke-width: 1.5; shape-rendering: crispEdges; }

/* ---------- tooltip: ink card with mono rows, same look as core/tooltip.js ---------- */
.pc-tip {
  --pc-fg: var(--white, #fff);
  --pc-dot: var(--white, #fff);
  --pc-accent: var(--white, #fff);
  position: absolute;
  left: 0;
  top: 0;
  z-index: var(--z-tooltip, 400);
  min-width: 150px;
  max-width: 280px;
  padding: 10px 12px 9px;
  background: var(--ink, #070E3A);
  color: var(--white, #fff);
  border-radius: var(--r-1, 2px);
  box-shadow: var(--shadow-float, 0 18px 40px -20px rgba(7, 14, 58, .5));
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: .01em;
  pointer-events: none;
  white-space: nowrap;
}
.pc-tip[hidden] { display: none; }
.pc-tip__title {
  margin-bottom: 6px;
  font-size: 10.5px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .66);
}
.pc-tip__row { display: flex; align-items: baseline; gap: 10px; }
.pc-tip__value {
  min-width: 4.5ch;
  font-weight: 600;
  font-size: 12px;
  color: var(--white, #fff);
  font-variant-numeric: tabular-nums;
}
.pc-tip__label { display: inline-flex; align-items: center; gap: 7px; color: rgba(255, 255, 255, .72); }
.pc-tip__note {
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, .18);
  color: rgba(255, 255, 255, .72);
  white-space: normal;            /* a long note (time · interval, a skipped Substrate view) wraps inside the 280 px box */
}

/* ---------- keys (legend and tooltip): they mirror the marks ---------- */
.pc-key {
  display: inline-block;
  flex: none;
  width: 8px;
  height: 8px;
  vertical-align: middle;
}
.pc-key--live { width: 18px; height: 2px; background: var(--pc-fg); }
.pc-key--record {
  width: 18px;
  height: 2px;
  background: linear-gradient(90deg, var(--pc-dot) 2px, transparent 2px) 0 0 / 4px 2px repeat-x;
}
.pc-key--solid { background: var(--pc-fg); }
.pc-key--accent { background: var(--pc-accent); }
.pc-key--dim { background: var(--pc-fg); opacity: var(--pc-dim-o); }
.pc-key--ring { box-shadow: inset 0 0 0 1.5px var(--pc-accent); }
.pc-key--bars { /* a 3 × 3 patch of square dots */
  width: 10px;
  height: 10px;
  background: linear-gradient(90deg, var(--pc-dot) 2px, transparent 2px) 0 0 / 4px 4px;
  -webkit-mask: linear-gradient(180deg, #000 2px, transparent 2px) 0 0 / 4px 4px;
          mask: linear-gradient(180deg, #000 2px, transparent 2px) 0 0 / 4px 4px;
}

/* ---------- legend ---------- */
.pc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: var(--fs-micro, 11px);
  line-height: 1.5;
  letter-spacing: .03em;
  color: var(--fg-2, currentColor);
}
/* one line unless the key is wider than its container: then the label wraps beside its key (no page overflow at 390) */
.pc-legend__item { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.pc-legend__num { font-weight: 500; color: var(--pc-fg); font-variant-numeric: tabular-nums; }

/* ---------- mix bar (tall segmented bar) ---------- */
.pc-mix__bar { display: flex; gap: 2px; width: 100%; }
.pc-mix__seg {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 3px;
  height: 100%;
  border-radius: var(--r-1, 2px);
  overflow: hidden;
  transform-origin: left center;
}
.pc-mix__seg--solid { background: var(--pc-fg); color: var(--pc-on-solid); }
.pc-mix__seg--dim { color: var(--pc-fg); }
.pc-mix__seg--dim::before { content: ""; position: absolute; inset: 0; background: var(--pc-fg); opacity: var(--pc-dim-o); }
.pc-mix__seg--ring { box-shadow: inset 0 0 0 1.5px var(--pc-accent); color: var(--pc-fg); }
.pc-mix__val {
  position: relative;
  padding-left: 8px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}
.pc-mix__legend { margin-top: 12px; }

/* ---------- block river (canvas colours are read from these) ---------- */
.pc-river {
  --pc-river-solid: var(--pc-fg);
  --pc-river-ring: var(--pc-accent);
  --pc-river-tick: var(--pc-tick);
  --pc-river-axis: var(--pc-line-strong);
  --pc-river-hi: var(--pc-fg);
  --pc-river-dim-o: .6;               /* the inherents: a steady floor under every column */
  --pc-river-ghost-o: .025;           /* unlit cells, only under the newest columns (the write head) */
}
.pc-river__canvas { display: block; width: 100%; cursor: crosshair; }

/* ---------- data table twin ---------- */
/* min-width 0: in a flex or grid parent the wrap never widens to the nowrap table; .pc-table scrolls instead */
.pc-table-wrap { margin-top: 10px; min-width: 0; max-width: 100%; }
.pc-table-toggle {
  padding: 6px 0;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--fg-3, currentColor);
  border-bottom: 1px solid var(--pc-line);
  transition: color var(--dur-1, 240ms) var(--ease, ease-out), border-color var(--dur-1, 240ms) var(--ease, ease-out);
}
.pc-table-toggle:hover { color: var(--pc-fg); border-color: var(--pc-fg); }
.pc-table-toggle:focus-visible { outline: 2px solid var(--focus, currentColor); outline-offset: 3px; }
.pc-table {
  max-height: 320px;
  margin-top: 8px;
  overflow: auto;
  overscroll-behavior: contain;
  border-top: 1px solid var(--pc-line-strong);
}
.pc-table table {
  width: 100%;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.pc-table caption {
  padding: 8px 0 6px;
  caption-side: top;
  text-align: left;
  font-size: 11px;
  color: var(--fg-3, currentColor);
}
.pc-table th, .pc-table td {
  padding: 6px 10px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--pc-line);
}
.pc-table thead th { font-weight: 500; color: var(--fg-3, currentColor); letter-spacing: .04em; }
.pc-table tbody th { font-weight: 500; }
.pc-table .is-left { text-align: left; }

/* figure frames: use the design-system .fig (components.css); charts go in .fig__body */

@media (prefers-reduced-motion: reduce) {
  .pc-now.is-tick { animation: none; }
  .pc-table-toggle { transition: none; }
}
@media (forced-colors: active) {
  .pc-record, .pc-solid, .pc-now, .pc-cross__live { fill: CanvasText; }
  .pc-live, .pc-cross__line { stroke: CanvasText; }
  .pc-tip { border-color: CanvasText; }
}
