/* breadboard.css — Level 2 breadboard chapter + builder. */

/* ── builder layout ─────────────────────────────────────────────────────── */
.bb {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 28px;
  align-items: start;
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 24px;
}
@media (max-width: 900px) {
  .bb { grid-template-columns: 1fr; }
  /* board is portrait — don't let it span the full single-column width or it
     towers. Cap it and centre it so the controls stay reachable. */
  .bb-board-wrap { max-width: 440px; margin-inline: auto; width: 100%; }
}
@media (max-width: 640px) {
  .bb { padding: 14px; gap: 18px; }
  .bb-board-wrap { max-width: 360px; }
}

.bb-board-wrap {
  background: var(--bg-deeper);
  border-radius: 10px;
  padding: 8px;
}
.bb-svg { display: block; width: 100%; height: auto; }

/* min-width:0 is critical: .bb-side is a grid item holding the value scroll-strips,
   whose nowrap content would otherwise force a huge min-content and collapse the
   board column to nothing. This lets the strips scroll and the board keep its size. */
.bb-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.bb-parts { min-width: 0; }

/* ── probe oscilloscope ─────────────────────────────────────────────────── */
.bb-scope {
  margin: 4px 0 12px;
  border: 1px solid #1f5a3c;
  border-radius: 8px;
  overflow: hidden;
  background: #06140d;
}
.bb-scope-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 6px 9px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: #a8d4b6;
  background: #0a2014;
  border-bottom: 1px solid #143a26;
}
.bb-scope-dot { color: #4d7a60; letter-spacing: 0.08em; font-size: 10px; white-space: nowrap; }
.bb-scope-dot.on { color: #7dff9a; }
.bb-scope-svg { display: block; width: 100%; height: 116px; }
.bb-scope-grid line { stroke: #123723; stroke-width: 0.6; }
.bb-scope-axis { stroke: #2a6b46; stroke-width: 0.8; }
.bb-scope-trace { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round;
  filter: drop-shadow(0 0 3px currentColor); }
.bb-scope-fill { opacity: 0.12; stroke: none; }
.bb-scope-sweep { filter: drop-shadow(0 0 4px currentColor); }
.bb-scope-cap { fill: #4d7a60; font-family: "IBM Plex Mono", monospace; font-size: 9px; }
.bb-scope-tau { fill: #7fae90; font-family: "IBM Plex Mono", monospace; font-size: 10px; }

/* ── "how a breadboard works" primer — full-width banner above the board ─── */
.bb-primer {
  grid-column: 1 / -1;
  border: 1px solid var(--rule-strong);
  border-radius: 10px;
  background: var(--bg-deeper);
  overflow: hidden;
}
.bb-primer.open .bb-primer-list {
  columns: 2;
  column-gap: 28px;
}
@media (max-width: 640px) {
  .bb-primer.open .bb-primer-list { columns: 1; }
}
.bb-primer-list li { break-inside: avoid; }

/* probe readout sits at the top of the side column, beside the board */
.bb-probe { order: -1; }
.bb-primer.open { border-color: var(--current-soft); }
.bb-primer-head {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 12px 14px;
  text-align: left;
}
.bb-primer-title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--current);
}
.bb-primer-chevron {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 17px;
  line-height: 1;
  color: var(--ink-faint);
  width: 18px; text-align: center;
}
.bb-primer-list {
  list-style: none;
  margin: 0;
  padding: 0 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bb-primer-list li {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-soft);
  padding-left: 14px;
  position: relative;
}
.bb-primer-list li::before {
  content: "";
  position: absolute;
  left: 0; top: 8px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--current);
}
.bb-primer-k { color: var(--ink); font-weight: 500; }

.bb-goal .eyebrow { margin-bottom: 6px; }
.bb-goal p { margin: 0; font-size: 15px; line-height: 1.5; color: var(--ink-soft); }

.bb-parts {
  border: 1.5px solid var(--rule-strong);
  border-radius: 12px;
  padding: 16px;
  margin-top: 14px;
  background: color-mix(in oklch, var(--bg-card) 50%, transparent);
}
.bb-tools-grouped {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}
.bb-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.bb-tool {
  appearance: none;
  border: 1.5px solid var(--rule-strong);
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  transition: border-color 140ms ease, background 140ms ease;
}
.bb-tool:hover { border-color: var(--ink-faint); }
.bb-tool.sel { border-color: var(--current); background: color-mix(in oklch, var(--current) 8%, transparent); }
.bb-tool.full { opacity: 0.5; }
.bb-tool-label { font-family: 'Geist', system-ui, sans-serif; font-size: 14px; color: var(--ink); }
.bb-tool-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.bb-tool-polar {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--ink-faint);
  background: color-mix(in oklch, var(--ink) 6%, transparent);
  white-space: nowrap;
}
.bb-tool-polar.warn {
  color: var(--current-deep);
  background: color-mix(in oklch, var(--current) 14%, transparent);
}
.bb-tool-count {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  letter-spacing: 0.1em; color: var(--ink-faint);
}

.bb-prompt {
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-soft);
  background: var(--bg-deeper);
  border-radius: 8px;
  padding: 10px 12px;
  font-style: italic;
}

.bb-actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* POWER is the payoff action: full-width on its own row, visually primary.
   The board-state utilities (undo/remove/probe/clear) stay small above it. */
.bb-actions .bb-btn.primary { flex: 1 1 100%; padding: 12px 14px; font-size: 14px; }
/* remove-a-part mode: the toggle glows, placed parts become pluckable */
.bb-btn.danger-on {
  border-color: oklch(0.55 0.17 35);
  color: oklch(0.5 0.18 35);
  background: color-mix(in oklch, oklch(0.62 0.19 35) 10%, transparent);
}
.bb-removable { cursor: pointer; }
.bb-removable:hover { opacity: 0.45; }
.bb-removable:hover * { stroke: oklch(0.55 0.17 35); }

.bb-btn {
  appearance: none;
  flex: 1;
  border: 1px solid var(--rule-strong);
  background: transparent;
  color: var(--ink);
  padding: 10px 12px;
  border-radius: 999px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
}
.bb-btn:disabled { opacity: 0.4; cursor: default; }
.bb-btn.primary { background: var(--current); color: var(--bg-card); border-color: var(--current); flex: 1.4; }
.bb-btn.primary:not(:disabled):hover { box-shadow: 0 6px 18px -8px var(--current); }
/* powered-on toggle state: reads as a live, pressed control */
.bb-btn.primary.on {
  background: var(--water);
  border-color: var(--water);
  box-shadow: inset 0 2px 6px -2px color-mix(in oklch, var(--ink) 50%, transparent);
}
.bb-btn.primary.on::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--bg-card);
  margin-right: 7px; vertical-align: middle;
  animation: bb-live 1.2s ease-in-out infinite;
}
@keyframes bb-live { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* LED halo gently breathes while lit */
.bb-led-halo { animation: bb-halo 1.8s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes bb-halo { 0%, 100% { transform: scale(1); opacity: 0.85; } 50% { transform: scale(1.14); opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .bb-led-halo, .bb-btn.primary.on::before { animation: none; }
}

.bb-verdict {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.5;
  border: 1px solid var(--rule-strong);
}
.bb-verdict .v-icon {
  flex: 0 0 auto;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.bb-verdict.pass { background: color-mix(in oklch, var(--water) 10%, transparent); border-color: var(--water); }
.bb-verdict.pass .v-icon { background: var(--water); color: var(--bg-card); }
.bb-verdict.warn { background: color-mix(in oklch, var(--current) 8%, transparent); border-color: var(--current-soft); }
.bb-verdict.warn .v-icon { background: var(--current-soft); color: var(--bg-card); }
.bb-verdict.fail { background: color-mix(in oklch, var(--current) 12%, transparent); border-color: var(--current); }
.bb-verdict.fail .v-icon { background: var(--current); color: var(--bg-card); }
