/* Interactive BOM: app-specific styles (shared styles: /assets/css/site.css) */

:root {
  --accent: #1f6fb2;
  --accent-dark: #17578d;
  --ok: #2ea043;
  --danger: #b3261e;
  --lit: #4cc2ff;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app { max-width: 1520px; margin: 0 auto; padding: 1.5rem 1.25rem 0; display: flex; flex-direction: column; gap: 1rem; }
.app-head { max-width: 82ch; }
.app-head h1 { margin: 0 0 0.35rem; font-size: 2rem; color: var(--brand); }
.app-head p { margin: 0; color: var(--ink-soft); }
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem 1.1rem; min-width: 0; }
.panel h2 { margin: 0 0 0.75rem; font-size: 1.0625rem; color: var(--brand); }

.btn {
  font: inherit; font-size: 0.9375rem; font-weight: 700; color: var(--ink); background: var(--surface);
  border: 1px solid #c5c8d4; border-radius: 5px; padding: 0.5rem 0.9rem; cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--accent); background: #edf4fb; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-small { font-size: 0.8125rem; padding: 0.3rem 0.65rem; }
.btn[aria-pressed="true"] { background: #fff4d6; border-color: #e0a800; }
input[type="text"], input[type="search"], select {
  font: inherit; font-size: 0.9375rem; padding: 0.35rem 0.5rem; border: 1px solid #c5c8d4; border-radius: 5px; background: var(--surface); color: var(--ink); min-width: 0;
}
.field { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.field > span { font-weight: 700; font-size: 0.8125rem; }
.check { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.875rem; cursor: pointer; white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- loading ---------- */

.loadbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem 2rem; padding: 0.8rem 1rem; }
.lb-files { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.lb-hint { font-size: 0.8125rem; color: var(--ink-soft); }
.lb-gh { display: flex; align-items: flex-end; gap: 0.5rem; flex-wrap: wrap; }
.lb-gh input { width: 17rem; }
.lb-gh select { max-width: 16rem; }
.lb-save { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; margin-left: auto; }
.lb-label { font-weight: 700; font-size: 0.8125rem; margin-right: 0.15rem; }
.lb-status { flex-basis: 100%; margin: 0; font-size: 0.875rem; color: var(--ink-soft); min-height: 1.2em; }
.lb-status:empty { display: none; }
.lb-status.err { color: var(--danger); font-weight: 700; }
.lb-status.warn { color: #8a5a00; font-weight: 700; }
body.dragging .app { outline: 3px dashed var(--accent); outline-offset: 6px; }

/* ---------- work area ---------- */

.work { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 1rem; align-items: start; }
.board-panel { position: sticky; top: 0.75rem; padding: 0.7rem; display: flex; flex-direction: column; gap: 0.5rem; }
.board-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.9rem; }
.board-head .zoom { display: flex; gap: 0.25rem; margin-left: auto; }
.board-head select { font-size: 0.8125rem; padding: 0.25rem 0.4rem; }
.seg { display: inline-grid; grid-template-columns: 1fr 1fr; border: 1px solid #c5c8d4; border-radius: 6px; overflow: hidden; }
.seg button { font: inherit; font-size: 0.8125rem; font-weight: 700; padding: 0.3rem 0.8rem; border: 0; background: var(--surface); color: var(--ink-soft); cursor: pointer; }
.seg button + button { border-left: 1px solid #c5c8d4; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.board-wrap { position: relative; height: min(calc(100vh - 9.5rem), 860px); min-height: 320px; border-radius: 6px; overflow: hidden; background: #1b2029; }
.board-wrap canvas { display: block; touch-action: none; cursor: grab; }
.board-wrap.teaching canvas { cursor: crosshair; }
.empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.8rem; padding: 1.5rem; text-align: center; color: #c9d1dc; }
.empty[hidden] { display: none; }
.empty p { margin: 0; max-width: 34ch; }
.try { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; }
.try button { font: inherit; font-size: 0.8125rem; padding: 0.3rem 0.7rem; border-radius: 999px; border: 1px solid #4a5568; background: #232a36; color: #e6edf3; cursor: pointer; }
.try button:hover { border-color: var(--lit); }
.hover { margin: 0; font-size: 0.8125rem; color: var(--ink-soft); min-height: 1.25em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hover b { color: var(--ink); }

.teach { background: #fff8e6; border: 1px solid #f0d58a; border-radius: 6px; padding: 0.5rem 0.7rem; }
.teach[hidden] { display: none; }
.teach-q { margin: 0 0 0.4rem; font-weight: 700; }
.teach-q code { font-family: var(--mono); background: #ffd166; padding: 0.05rem 0.35rem; border-radius: 3px; }
.teach-b { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.teach-h { margin: 0.4rem 0 0; font-size: 0.78rem; color: #6b5310; }

/* ---------- parts list ---------- */

.bom-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.bom-head h2 { margin: 0; }
.progress { display: flex; align-items: center; gap: 0.6rem; font-size: 0.8125rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.progress[hidden] { display: none; }
.bar { width: 9rem; height: 0.55rem; border-radius: 999px; background: #e3e5ec; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--ok); transition: width 0.2s; }
.bom-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem 0.8rem; margin-bottom: 0.6rem; }
.bom-tools input[type="search"] { flex: 1 1 12rem; }
.bom-tools select { font-size: 0.875rem; }
.bom { border: 1px solid #e3e5ec; border-radius: 6px; }
.bom:empty::before { content: "The parts of the board appear here."; display: block; padding: 0.8rem; font-size: 0.875rem; color: var(--ink-soft); }
.line {
  display: grid; grid-template-columns: 1.6rem 2.2rem minmax(0, 1.1fr) minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 0.25rem 0.6rem; align-items: start; padding: 0.45rem 0.6rem; border-bottom: 1px solid #f0f1f5; cursor: pointer; font-size: 0.875rem;
}
.line:last-child { border-bottom: 0; }
.line:hover { background: #f5f8fc; }
.line.sel { background: #e6f4fd; box-shadow: inset 3px 0 0 var(--lit); }
.line.done { color: var(--ink-soft); }
.line.done .val { text-decoration: line-through; text-decoration-color: #9aa0ad; }
.line input[type="checkbox"] { width: 1.05rem; height: 1.05rem; margin: 0.15rem 0 0; accent-color: var(--ok); }
.line .qty { font-variant-numeric: tabular-nums; text-align: right; font-weight: 700; }
.line .val { font-weight: 700; overflow-wrap: anywhere; }
.line .val small { display: block; font-weight: 400; color: var(--ink-soft); font-size: 0.75rem; }
.line .fp { font-size: 0.78rem; color: var(--ink-soft); overflow-wrap: anywhere; }
.line .fp a { color: var(--link); }
.refs { display: flex; flex-wrap: wrap; gap: 0.2rem; }
.ref {
  font: inherit; font-family: var(--mono); font-size: 0.75rem; padding: 0.05rem 0.35rem; border-radius: 4px;
  border: 1px solid #c9d7e6; background: #f2f7fc; color: #17578d; cursor: pointer;
}
.ref.nopos { border-style: dashed; background: #fff; color: #8a5a00; border-color: #e0c27a; }
.ref.focus { background: #ffd166; border-color: #e0a800; color: #2b2f36; }
.ref.other { opacity: 0.7; }
.ref.other::after { content: " B"; font-size: 0.65rem; }
.bom-foot { margin: 0.5rem 0 0; font-size: 0.8125rem; color: var(--ink-soft); }

.help { margin-bottom: 1.5rem; }
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 2rem; }
.help ul { margin: 0; padding-left: 1.2rem; font-size: 0.9375rem; }
.help li { margin: 0.4rem 0; }

@media (max-width: 1000px) {
  .work { grid-template-columns: minmax(0, 1fr); }
  .board-panel { position: static; order: -1; }
  .board-wrap { height: 62vh; }
  .help-cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .app { padding: 1rem 0.75rem 0; }
  .app-head h1 { font-size: 1.6rem; }
  .line { grid-template-columns: 1.6rem 2rem minmax(0, 1fr); }
  .line .refs { grid-column: 3; }
  .line .fp { grid-column: 3; }
  .lb-gh input { width: 100%; }
  .lb-gh, .lb-gh .field { flex: 1 1 100%; }
  .lb-save { margin-left: 0; }
}
