/* The project's electronics workspace (issue #268): Snakie's wiring canvas
   (project-wiring.js), in the document in place of the wiring diagram, or
   full screen over the editor. Full screen it's under the parts catalog
   (z-index 10050), which opens over it to add parts. */
.project-wiring {
  display: flex;
  flex-direction: column;
  background: #faf9f5;
  /* A drag between pins (or across the panels) shouldn't sweep up the pin
     labels, the toolbar and the page underneath as a browser text selection.
     Fields stay selectable so you can still edit and copy what's in them. */
  -webkit-user-select: none;
  user-select: none;
}
.project-wiring :is(input, textarea, [contenteditable]:not([contenteditable="false"])) {
  -webkit-user-select: text;
  user-select: text;
}
.project-wiring-overlay {
  position: fixed;
  inset: 0;
  z-index: 10040;
  display: flex;
}
.project-wiring-overlay > .project-wiring {
  flex: 1;
  min-width: 0;
}
/* In the page: the column's width, a fixed height, framed like a picture. */
.project-wiring.is-inline {
  height: min(600px, 75vh);
  border: 1px solid #e3e0d6;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  font-size: 0.875rem;
  line-height: 1.4;
}
.project-wiring.is-inline .project-wiring-bar {
  gap: 0.35rem;
  padding: 0.4rem 0.5rem;
}
.project-wiring.is-inline .project-wiring-bom { width: 260px; }
/* Shorter labels in the page, and the status on a line of its own. */
.project-wiring .pw-inline-label,
.project-wiring.is-inline .pw-full-label { display: none; }
.project-wiring.is-inline .pw-inline-label { display: inline; }
.project-wiring.is-inline .project-wiring-status:not(:empty) {
  order: 99;
  flex-basis: 100%;
  margin-left: 0 !important;
}
.project-wiring-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #e3e0d6;
  background: #fff;
}
.project-wiring-canvas {
  position: relative;
  flex: 1;
  min-height: 0;
}
.project-wiring-canvas > .snakie-embed {
  position: absolute;
  inset: 0;
  min-height: 0;
}
body.project-wiring-open {
  overflow: hidden;
}

/* "Edit wiring" on the diagram in the editor's live view. */
.project-wiring-edit {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 0.25em 0.6em;
  border: 1px solid #e3e0d6;
  border-radius: 6px;
  background: #fff;
  color: #141413;
  font: 600 0.75rem/1.2 ui-sans-serif, system-ui, sans-serif;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  cursor: pointer;
}
.project-wiring-edit:hover {
  background: #f0eee6;
}
/* Only while the pointer is over the picture (or the button has keyboard
   focus), like the image size bar. Readers never get the button: only the
   editor adds it. */
.cm-md-image-wrap .project-wiring-edit {
  opacity: 0;
  transition: opacity 0.12s;
}
.cm-md-image-wrap:hover .project-wiring-edit,
.cm-md-image-wrap .project-wiring-edit:focus-visible {
  opacity: 1;
}
@media (hover: none) {
  .cm-md-image-wrap .project-wiring-edit { opacity: 1; }
}

/* The canvas and, beside it, the Bill of Materials panel (wiring-bom.js). */
.project-wiring-body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}
.project-wiring-body > .project-wiring-canvas {
  flex: 1;
  min-width: 0;
}
.project-wiring-bom {
  width: 300px;
  flex: none;
  overflow: auto;
  border-left: 1px solid #e3e0d6;
  background: #faf9f5;
  font-size: 0.8125rem;
}
.project-wiring.bom-hidden .project-wiring-bom { display: none; }
.project-wiring-bom .wb-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #e3e0d6;
  background: #faf9f5;
}
.project-wiring-bom .wb-list { list-style: none; margin: 0; padding: 0; }
.project-wiring-bom .wb-row {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 0.25rem 0.6rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #efece3;
}
.project-wiring-bom .wb-thumb {
  grid-row: span 2;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #f0eee6;
  color: #8a7f66;
  overflow: hidden;
}
.project-wiring-bom .wb-thumb img { width: 100%; height: 100%; object-fit: contain; }
.project-wiring-bom .wb-text { display: flex; flex-direction: column; min-width: 0; }
.project-wiring-bom .wb-name { font-weight: 600; overflow-wrap: anywhere; }
.project-wiring-bom .wb-state { font-size: 0.75rem; color: #6c6552; }
.project-wiring-bom .wb-state.is-placed { color: #2f6b3b; }
.project-wiring-bom .wb-state.is-board { color: #2f6b3b; font-weight: 600; }
.project-wiring-bom .wb-state.is-unlinked { color: #9a5b12; }
.project-wiring-bom .wb-state.is-nopins { color: #8a6d1a; }
.project-wiring-bom .wb-acts { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.project-wiring-bom .wb-acts:empty { display: none; }
.project-wiring-bom .wb-acts .btn { --bs-btn-padding-y: 0.1rem; --bs-btn-padding-x: 0.45rem; --bs-btn-font-size: 0.75rem; }
.project-wiring-bom .wb-empty,
.project-wiring-bom .wb-foot { margin: 0; padding: 0.75rem; color: #6c6552; }
@media (max-width: 700px) {
  .project-wiring-body { flex-direction: column; }
  .project-wiring-bom { width: auto; max-height: 40%; border-left: 0; border-top: 1px solid #e3e0d6; }
}

/* Edit part: Snakie's Part Editor in a dialog over the workspace, above
   the full screen overlay and below the parts catalog. */
.project-wiring-part-dialog {
  position: fixed;
  inset: 0;
  z-index: 10045;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(20, 24, 28, 0.55);
}
.project-wiring-part-dialog .pwp-box {
  width: min(1280px, 100%);
  max-height: 100%;
  overflow: auto;
  background: #fff;
  border-radius: 10px;
  padding: 12px 16px 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.project-wiring-part-dialog .pwp-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.project-wiring-part-dialog .part-electronics-editor { height: 72vh; }
