/* The board pages: /boards/ (the table) and /boards/<id>/ (src/boards/pages.mjs). On top of site.css. */

:root {
  /* pin roles: the bench's, the site's and VS Code's (brief-common.md) */
  --role-power: #c4262e; --role-ground: #3a3a3c; --role-digital: #2f6fdb; --role-analog: #1f8a4c;
  --role-bus: #8a4fd0; --role-control: #c27400; --role-nc: #9a9aa0;
  --pcb: #1f5c4a; --pcb-edge: #164537; --pcb-fg: #e9f3ef;
  --ok: #1f8a4c;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --role-power: #ff6961; --role-ground: #c7c7cc; --role-digital: #6ea8ff; --role-analog: #4cd387;
    --role-bus: #c19bff; --role-control: #ffb340; --role-nc: #8e8e93;
    --pcb: #1d4f41; --pcb-edge: #2e7560; --pcb-fg: #e9f3ef;
    --ok: #4cd387;
  }
}
:root[data-theme="dark"] {
  --role-power: #ff6961; --role-ground: #c7c7cc; --role-digital: #6ea8ff; --role-analog: #4cd387;
  --role-bus: #c19bff; --role-control: #ffb340; --role-nc: #8e8e93;
  --pcb: #1d4f41; --pcb-edge: #2e7560; --pcb-fg: #e9f3ef;
  --ok: #4cd387;
}

.bd { padding-top: 40px; padding-bottom: 72px; }
.bd-muted, .bd-none { color: var(--fg-3); }
.bd h1 { font-size: clamp(34px, 5vw, 56px); letter-spacing: -0.04em; line-height: 1.06; margin: 6px 0 12px; }
.bd .lede { color: var(--fg-2); font-size: clamp(17px, 2vw, 20px); line-height: 1.45; max-width: 44em; margin: 0; }

/* ---------- /boards/ ---------- */
.wrap.bd-index { max-width: 1320px; }
.bd-hero { margin-bottom: 28px; }
.bd-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; }
.bd-filters-label { font-size: 13px; color: var(--fg-3); margin-right: 4px; }
.bd-filter { appearance: none; border: var(--hair) solid var(--line-strong); background: var(--card); color: var(--fg); border-radius: 999px; height: 32px; padding: 0 14px; font: inherit; font-size: 13.5px; cursor: pointer; }
.bd-filter:hover { background: var(--fill-2); }
.bd-filter[aria-pressed="true"] { background: var(--ink); color: var(--ink-fg); border-color: var(--ink); }
.bd-clear { border-style: dashed; }
.bd-count { margin-left: auto; font-size: 13px; color: var(--fg-3); }
.bd-scroll { overflow-x: auto; border: var(--hair) solid var(--line); border-radius: var(--r); background: var(--card); -webkit-overflow-scrolling: touch; }
.bd-scroll:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.bd-table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 1000px; font-size: 14px; }
.bd-table th, .bd-table td { text-align: left; padding: 11px 12px; border-bottom: var(--hair) solid var(--line); vertical-align: middle; white-space: nowrap; }
.bd-table td:nth-child(2) { white-space: normal; min-width: 150px; }
.bd-table tbody tr:last-child > * { border-bottom: 0; }
.bd-table tbody tr:hover > * { background: var(--fill); }
.bd-table td { color: var(--fg); }
.bd-table .n { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 13px; }
.bd-table thead th { position: sticky; top: 0; background: var(--glass-solid); font-size: 12px; font-weight: 600; color: var(--fg-2); text-transform: uppercase; letter-spacing: .04em; padding: 0; z-index: 1; }
.bd-table thead th[data-type="num"] .bd-sort { justify-content: flex-end; }
.bd-sort { appearance: none; border: 0; background: none; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; width: 100%; padding: 12px; display: flex; align-items: center; gap: 4px; cursor: pointer; }
.bd-sort:hover { color: var(--fg); }
.bd-arrow::after { content: "↕"; opacity: .35; font-size: 11px; }
th[aria-sort="ascending"] .bd-arrow::after { content: "↑"; opacity: 1; }
th[aria-sort="descending"] .bd-arrow::after { content: "↓"; opacity: 1; }
/* the board's name stays in view while the rest scrolls */
.bd-table tbody th, .bd-table thead th:first-child { position: sticky; left: 0; background: var(--glass-solid); z-index: 2; }
.bd-table tbody th { white-space: normal; min-width: 150px; font-weight: 600; box-shadow: 1px 0 0 var(--line); }
.bd-table tbody th a { color: var(--fg); text-decoration: none; }
.bd-table tbody th a:hover { text-decoration: underline; }
.bd-vendor { display: block; font-size: 12px; font-weight: 400; color: var(--fg-3); }
.bd-chip { display: inline-block; font-size: 12px; line-height: 1; padding: 5px 8px; border-radius: 999px; background: var(--fill-2); color: var(--fg); }
.bd-nomatch { padding: 18px; margin: 0; color: var(--fg-2); }
.bd-note { font-size: 13.5px; color: var(--fg-3); margin: 14px 2px 0; line-height: 1.5; }
.bd-use .icon { width: 14px; height: 14px; }
.bd-use.done { border-color: var(--ok); }

/* ---------- /boards/<id>/ ---------- */
.bd-crumb { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 14px; margin-bottom: 22px; }
.bd-crumb a { text-decoration: none; }
.bd-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 32px; align-items: center; padding-bottom: 28px; border-bottom: var(--hair) solid var(--line); }
.bd-head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 20px; }
.bd-picture { margin: 0; padding: 10px; border: var(--hair) solid var(--line); border-radius: var(--r-l); background: var(--code-bg); overflow-x: auto; color: var(--fg); }
.bd-picture svg { display: block; width: 100%; height: auto; }

.bd-sec { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 32px; padding: 40px 0; border-bottom: var(--hair) solid var(--line); }
.bd-sec-head h2 { font-size: 24px; letter-spacing: -0.025em; margin: 0 0 8px; }
.bd-sec-head p { color: var(--fg-3); font-size: 14px; line-height: 1.5; margin: 0; }
.bd-short { font-size: clamp(18px, 2vw, 21px); line-height: 1.5; margin: 0 0 18px; max-width: 42em; }
.bd-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: var(--hair) solid var(--line); border-radius: var(--r); background: var(--card); }
.bd-tiles > div { padding: 12px 14px; border-left: var(--hair) solid var(--line); }
.bd-tiles > div:first-child { border-left: 0; }
.bd-tiles span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--fg-3); }
.bd-tiles b { display: block; font-size: 20px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; }

.bd-specs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 32px; margin: 0; }
.bd-specs > div { display: grid; grid-template-columns: 9.5em minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: var(--hair) solid var(--line); font-size: 14.5px; }
.bd-specs dt { color: var(--fg-3); }
.bd-specs dd { margin: 0; font-family: var(--mono); font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }

.bd-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 0; margin: 0 0 14px; font-size: 13.5px; }
.bd-legend li { display: inline-flex; align-items: center; gap: 6px; }
.bd-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--role); display: inline-block; }
.bd-pins { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.bd-pin { border: var(--hair) solid var(--line); border-left: 4px solid var(--role); border-radius: 8px; padding: 6px 8px; background: var(--card); font-size: 12px; line-height: 1.3; cursor: default; min-width: 0; }
.bd-pin:hover, .bd-pin:focus { background: color-mix(in srgb, var(--role) 12%, var(--card)); outline: none; }
.bd-pin b { display: block; font-family: var(--mono); font-size: 12.5px; }
.bd-pin span { display: block; color: var(--fg-3); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bd-pin-detail { min-height: 1.5em; font-size: 13.5px; color: var(--fg-2); margin: 12px 0 0; }
.r-power { --role: var(--role-power); } .r-ground { --role: var(--role-ground); } .r-digital { --role: var(--role-digital); }
.r-analog { --role: var(--role-analog); } .r-bus { --role: var(--role-bus); } .r-control { --role: var(--role-control); } .r-nc { --role: var(--role-nc); }

.bd-watch { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.bd-watch li { border: var(--hair) solid var(--line); border-left: 3px solid var(--warn); border-radius: var(--r-s); padding: 12px 14px; background: var(--card); }
.bd-watch p { margin: 0; font-size: 14.5px; line-height: 1.5; }
.bd-watch .bd-watch-check { margin-top: 8px; font-size: 12.5px; color: var(--fg-3); }
.bd-code code { font-size: 12px; }

.bd-code2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.bd-win { margin: 0; border: var(--hair) solid var(--line); border-radius: var(--r); background: var(--card); overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.bd-win figcaption { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 9px 14px; font-size: 12.5px; font-family: var(--mono); border-bottom: var(--hair) solid var(--line); background: var(--fill); }
.bd-win figcaption a { font-family: var(--font); font-size: 13px; }
.bd-win pre { margin: 0; padding: 14px; overflow: auto; font-size: 12.5px; line-height: 1.55; max-height: 520px; flex: 1; background: var(--code-bg); border-radius: 0; border: 0; }
.bd-win-note { margin: 0; padding: 8px 14px; font-size: 12px; color: var(--fg-3); border-top: var(--hair) solid var(--line); }
.bd-actions { margin: 16px 0 0; }

.bd-fixture { font-size: 13px; color: var(--warn); margin: 0 0 12px; }
.bd-parts { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.bd-board { border: var(--hair) solid var(--line); border-radius: var(--r); background: var(--code-bg); padding: 12px; }
.bd-parts-svg { display: block; width: 100%; height: auto; touch-action: manipulation; }
.bd-pcb { fill: var(--pcb); stroke: var(--pcb-edge); stroke-width: .5; }
.bd-part { cursor: pointer; outline: none; }
.bd-part-hit { fill: rgba(255, 255, 255, .1); stroke: rgba(255, 255, 255, .55); stroke-width: .25; stroke-dasharray: .8 .6; transition: fill .15s; }
.bd-part:hover .bd-part-hit, .bd-part:focus .bd-part-hit { fill: rgba(255, 255, 255, .26); }
.bd-part-num circle { fill: #fff; stroke: var(--pcb-edge); stroke-width: .3; }
.bd-part-num text { fill: #1d1d1f; font-family: var(--font); font-weight: 700; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.is-quiz .bd-part-num { display: none; }
.is-quiz .bd-part-hit { stroke-opacity: .35; }
.is-quiz .bd-part.is-done .bd-part-num { display: inline; }
.bd-part.is-done .bd-part-hit { fill: color-mix(in srgb, var(--ok) 55%, transparent); stroke: var(--ok); stroke-dasharray: none; }
.bd-part.is-found .bd-part-hit, .bd-part.is-hint .bd-part-hit { fill: rgba(255, 214, 10, .55); stroke: #ffd60a; stroke-width: .6; stroke-dasharray: none; }
.bd-part.is-hint .bd-part-hit { animation: bd-pulse .5s ease-in-out 3 alternate; }
.bd-part.is-wrong .bd-part-hit { fill: rgba(255, 69, 58, .55); stroke: #ff453a; stroke-dasharray: none; }
@keyframes bd-pulse { from { opacity: .4; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .bd-part.is-hint .bd-part-hit { animation: none; } }
.bd-partlist { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; counter-reset: none; }
.bd-partlist li.is-found .bd-partbtn { background: var(--fill-2); }
.bd-partbtn { appearance: none; display: flex; gap: 10px; width: 100%; text-align: left; border: 0; background: none; color: inherit; font: inherit; padding: 8px 10px; border-radius: var(--r-s); cursor: pointer; }
.bd-partbtn:hover { background: var(--fill); }
.bd-partbtn:disabled { cursor: default; }
.bd-partbtn b { display: block; font-size: 14.5px; }
.bd-partbtn span span { display: block; font-size: 13px; color: var(--fg-2); line-height: 1.45; margin-top: 2px; }
.bd-n { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: var(--ink-fg); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.bd-parts-left { position: sticky; top: calc(var(--topbar-h) + 12px); }
.bd-quiz-h { font-size: 18px; margin: 20px 0 4px; }
.bd-quiz-lede { margin: 0; font-size: 14px; }
.bd-quiz { margin-top: 12px; }
.bd-quiz-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 14px; border: var(--hair) solid var(--line); border-radius: var(--r); background: var(--card); }
.bd-quiz-ask { margin: 0; font-weight: 600; font-size: 15.5px; flex: 1 1 14em; min-height: 1.4em; }
.bd-quiz-ask:empty { display: none; }
.bd-quiz-tools { display: inline-flex; gap: 8px; }
.bd-quiz-score { font-size: 13px; color: var(--fg-3); font-variant-numeric: tabular-nums; }
.bd-foot { margin: 32px 0 0; }

@media (max-width: 900px) {
  .bd-head { grid-template-columns: 1fr; }
  .bd-sec { grid-template-columns: 1fr; gap: 16px; padding: 32px 0; }
  .bd-code2, .bd-parts, .bd-watch, .bd-specs { grid-template-columns: 1fr; }
  .bd-parts-left { position: static; }
}
@media (max-width: 600px) {
  .bd { padding-top: 24px; }
  .wrap.bd { padding-left: 16px; padding-right: 16px; }
  .bd-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bd-tiles > div:nth-child(4) { border-left: 0; }
  .bd-tiles > div:nth-child(n+4) { border-top: var(--hair) solid var(--line); }
  .bd-specs > div { grid-template-columns: 8em minmax(0, 1fr); }
  .bd-count { margin-left: 0; width: 100%; }
  .bd-table tbody th { min-width: 0; width: 128px; }
  .bd-pins { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .bd-quiz-bar { bottom: 8px; }
}
