/* Pipes / Net board (archetype 06, "mark-the-grid") scoped under .pipes-root.
   A square grid where every cell holds a rotatable pipe piece; matched connectors
   light gold as the network fills from the central source. Uses the shared design
   tokens (gold accent + warm neutrals); light + dark via .mode-dark. */

.pipes-root {
  --cell: 58px;
  --line: #cfc8b8; --ink: #2a2620; --paper: #fbf9f3;
  --pipe: #b3a988; --pipe-on: #b68235; --pipe-core: #e7d3a3;
  --src: #b68235; --src-ink: #fff;
  --bad: #c8503b; --sel: #b68235;
  display: flex; flex-direction: column; align-items: center;
  gap: clamp(12px, 3vw, 22px);
  padding: clamp(10px, 2.5vw, 22px) 0;
  color: var(--ink);
}
/* Board tonality is fixed by the surface panel (BOARD_SURFACES.md): the board
   follows our .mode-dark class only, never the OS colour-scheme. */
.pipes-root.mode-dark {
  --line: #3a4030; --ink: #ece8e2; --paper: #262a21;
  --pipe: #5f5a48; --pipe-on: #d8b65c; --pipe-core: #6a5c2a;
  --src: #d8b65c; --src-ink: #201d14;
  --bad: #d9694f; --sel: #d8b65c;
}

.pipes-grid {
  display: grid; justify-content: center;
  gap: 2px; padding: 2px;
  background: var(--line); border-radius: 10px;
}

.pipes-cell {
  position: relative;
  inline-size: var(--cell); block-size: var(--cell);
  display: grid; place-items: center;
  padding: 0; margin: 0; border: 0;
  background: var(--paper); color: var(--pipe);
  cursor: pointer; user-select: none; overflow: hidden;
  transition: background 0.12s ease, box-shadow 0.12s ease;
}
.pipes-cell:hover { box-shadow: inset 0 0 0 2px var(--pipe-core); }

.pk-rot {
  inline-size: 100%; block-size: 100%;
  display: block;
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
  transform-origin: 50% 50%;
}
.pk-svg { inline-size: 100%; block-size: 100%; display: block; }

/* Pipe strokes take their colour from the cell's `color`. */
.pk-line {
  stroke: currentColor; stroke-width: 15; stroke-linecap: round; fill: none;
  transition: stroke 0.14s ease;
}
.pk-hub { fill: currentColor; transition: fill 0.14s ease; }
.pk-end {
  fill: var(--paper); stroke: currentColor; stroke-width: 8;
  transition: stroke 0.14s ease;
}
.pk-src { fill: var(--src); stroke: none; }

/* Powered pieces (reached from the source through matched connectors) glow gold. */
.pipes-cell.on { color: var(--pipe-on); }
.pipes-cell.on .pk-hub { fill: var(--pipe-on); }

/* A piece with a loose / unmatched connector is flagged red. */
.pipes-cell.stub { color: var(--bad); }
.pipes-cell.stub .pk-end { stroke: var(--bad); }

.pipes-cell.sel { box-shadow: inset 0 0 0 3px var(--sel); }
.pipes-cell.source { background: color-mix(in srgb, var(--src) 12%, var(--paper)); }

.pipes-root.solved .pipes-cell { color: var(--pipe-on); }
.pipes-root.solved .pipes-cell .pk-hub { fill: var(--pipe-on); }
.pipes-root.solved .pipes-cell { background: color-mix(in srgb, var(--pipe-on) 9%, var(--paper)); }

@media (prefers-reduced-motion: reduce) { .pk-rot, .pk-line, .pk-hub, .pipes-cell { transition: none; } }
.pipes-root.no-motion .pk-rot,
.pipes-root.no-motion .pk-line,
.pipes-root.no-motion .pk-hub,
.pipes-root.no-motion .pipes-cell { transition: none; }
