/* ── Patch ───────────────────────────────────────────────────────────────────
   Cords run between brass sockets on a panel.

   The panel is a plain grid of .cn-cell, one per socket position, in row-major
   order — the deduce overlay addresses these by index. The cords themselves are
   an SVG laid over the top: a polyline per arm, round-capped, so a run reads as
   one continuous cord rather than a trail of coloured squares.

   The panel is drawn as SOCKETS, visible before a single cord exists. That is
   deliberate and it is the thing that keeps this game from reading as Subway:
   at rest Subway is a bare grid with a few numbered stops, and Patch is a field
   of hardware. In motion they both draw a line, so they have to differ standing
   still.                                                                       */

.connect-play .q-stage {
  display: flex;
  align-items: center;
  justify-content: center;
}

.cn-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cn-c), var(--cn-cs));
  grid-auto-rows: var(--cn-cs);
  background: var(--cn-panel);
  border: 2px solid var(--cn-frame);
  border-radius: var(--radius);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* a socket position: the lattice the cords are pinned to */
.cn-cell {
  position: relative;
  box-sizing: border-box;
  border: var(--hairline) solid var(--cn-line);
}

/* the empty sockets — small, recessed, and present from the first frame so the
   panel is furniture rather than a blank grid */
.cn-cell::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22%;
  height: 22%;
  border-radius: var(--radius-full);
  background: var(--cn-line);
  transform: translate(-50%, -50%);
}
.cn-cell.end::after { display: none; }

/* the refusal, borrowed wholesale from Subway so the two games say no in one
   voice: a shake on the panel, a red flash on the socket that refused. */
.cn-board.cn-biting { animation: cn-shake 0.22s var(--ease); }
@keyframes cn-shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-3px); }
  75%      { transform: translateX(3px); }
}
.cn-cell.cn-bit { animation: cn-bit 0.5s var(--ease); }
@keyframes cn-bit {
  0%   { box-shadow: inset 0 0 0 2px var(--danger-line); }
  100% { box-shadow: inset 0 0 0 2px transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .cn-board.cn-biting, .cn-cell.cn-bit { animation: none; }
}

/* ── the cords ───────────────────────────────────────────────────────────── */

.cn-wires {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}
.cn-wire {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* An endpoint: the brass ring, and the numeral that is the cord's REAL name.

   The numeral is inked in the panel's own colour, not in brass. Brass on a dark
   cord is brass on brown — it disappeared on four of nine hues the first time
   this ran, and it is precisely the channel a player without colour vision is
   reading. Panel-on-cord inverts correctly in both themes, and the glyph also
   carries a stroke of its own cord so it holds at any size. */
.cn-plug { stroke: var(--cn-socket); stroke-width: 1.5; }
.cn-num {
  fill: var(--cn-panel);
  font-family: var(--font-mono);
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  paint-order: stroke;
}

/* the arm the finger is currently drawing — brightened, not recoloured */
.cn-wire.live { filter: brightness(1.25); }

/* ── solved ──────────────────────────────────────────────────────────────── */

.cn-board.cn-solved { border-color: var(--accent); }

/* ── the level-card / hub thumbnail ──────────────────────────────────────── */

.cn-mini {
  display: grid;
  grid-template-columns: repeat(var(--cn-c), 1fr);
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--cn-panel);
}
.cn-mini i {
  box-sizing: border-box;
  border: 0.5px solid var(--cn-line);
  position: relative;
}
.cn-mini i.on::after {
  content: "";
  position: absolute;
  inset: 26%;
  border-radius: var(--radius-full);
  background: var(--cn-ink);
}
