/*
 * Boards and solids: the layer-by-layer stack-up, current paths on a board,
 * and a solid card's interface conditions, orthotropic material and solved
 * surface field. Reads the roles in tokens.css only, so both themes follow.
 */

:root {
    /* Copper and laminate in a cross-section: the material's own colours,
       held a little back from the identity copper so they never read as
       a selection. */
    --stk-copper:      #b46a2c;
    --stk-copper-base: #b46a2c38;
    --stk-laminate:    #c9d8c4;
    --stk-laminate-edge: #a9bea2;
    /* A conductor carrying current: heat, hatched. */
    --path-fill:       color-mix(in srgb, var(--warm) 16%, transparent);
    --path-line:       color-mix(in srgb, var(--warm) 55%, transparent);
}
:root[data-theme="dark"] {
    --stk-copper:      #d08a4c;
    --stk-copper-base: #d08a4c40;
    --stk-laminate:    #33453a;
    --stk-laminate-edge: #44594b;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --stk-copper:      #d08a4c;
        --stk-copper-base: #d08a4c40;
        --stk-laminate:    #33453a;
        --stk-laminate-edge: #44594b;
    }
}

/* ---------------------------------------------------------------- copper model */

.pcb-cu-model { margin-top: 1px; }
.pcb-cu-model .seg-btn:disabled { opacity: .45; cursor: not-allowed; }
.pcb-cu-field + .pcb-stack-summary { margin-top: -2px; }

.pcb-stack-summary {
    margin: 0 0 12px;
    padding: 8px 9px 9px;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--field);
}
.pcb-stack-summary[hidden] { display: none; }
.stk-mini { cursor: pointer; line-height: 0; }
.stk-mini svg { width: 100%; height: auto; display: block; }
.stk-mini-line {
    margin: 7px 0 4px;
    font-size: 11.5px;
    color: var(--ink-mid);
    font-variant-numeric: tabular-nums;
}
.stk-mini-line b { font-family: var(--mono); font-weight: 600; color: var(--ink); }
.stk-good { color: var(--ok); }
.stk-bad { color: var(--danger); }
.pcb-stack-summary .pcb-derived { margin: 2px 0 7px; }
.pcb-stack-summary button { width: 100%; }

/* ---------------------------------------------------------------- cross-section */

.stk-svg { display: block; overflow: visible; }
.stk-svg .stk-di { fill: var(--stk-laminate); stroke: var(--stk-laminate-edge); stroke-width: .6; }
.stk-svg .stk-cu-base { fill: var(--stk-copper-base); }
.stk-svg .stk-cu { fill: var(--stk-copper); }
.stk-svg .stk-cu-dash { stroke: var(--stk-copper); }
.stk-svg .stk-sel { fill: none; stroke: var(--brand); stroke-width: 1.5; }
.stk-svg .stk-row { cursor: pointer; }
.stk-svg .stk-row:hover .stk-di { fill: color-mix(in srgb, var(--stk-laminate) 80%, var(--ink) 8%); }
.stk-svg text { font-family: var(--mono); font-size: 10px; fill: var(--ink-mid); font-variant-numeric: tabular-nums; }
.stk-svg .stk-tag { fill: var(--ink-faint); font-size: 9.5px; }
.stk-svg .stk-di-label { fill: var(--ink-soft); font-size: 9.5px; }

/* ---------------------------------------------------------------- stack editor */

.pcb-stack {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    max-height: 46%;
    min-height: 170px;
    border-top: 1px solid var(--rule-firm);
    background: var(--panel);
}
.pcb-stack[hidden] { display: none; }
.pcb-stack.folded { min-height: 0; }
.pcb-stack.folded .pcb-stack-body { display: none; }
.pcb-stack.folded #pcb-stack-fold svg { transform: rotate(180deg); }
.pcb-stack-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--rule);
}
.pcb-stack-title {
    font-family: var(--display);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--ink-faint);
}
.pcb-stack-head select { width: auto; }
.pcb-stack-head .grow { flex: 1 1 0; }
.pcb-stack-total {
    font-family: var(--mono);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    color: var(--ink-soft);
}
.pcb-stack-total.good { color: var(--ok); }
.pcb-stack-total.bad { color: var(--danger); }
.pcb-stack-total .stk-fix { font-family: var(--sans); font-size: 11.5px; padding: 2px 8px; margin-left: 4px; }

.pcb-stack-body { flex: 1; min-height: 0; overflow: auto; padding: 8px 12px 12px; }
.pcb-stack-body { container-type: inline-size; }
.stk-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
@container (min-width: 1180px) {
    .stk-grid { grid-template-columns: minmax(0, 1fr) 440px; gap: 18px; }
}
/* The table sits in a .pcb-panel so its fields take units ("0.2 mm"),
   as every board field does; none of the panel's own frame. */
.pcb-stack .stk-table-wrap.pcb-panel { padding: 0; border: 0; overflow-x: auto; overflow-y: visible; }

.stk-table td { padding: 2px 4px; }
.stk-table td.num input { width: 54px; }
.stk-table td.num input.stk-t { width: 70px; }
.stk-table input.stk-name { width: 100px; padding: 2px 5px; }
.stk-table th { white-space: nowrap; padding: 3px 4px; line-height: 1.2; vertical-align: bottom; }
.stk-table th small { display: block; font-weight: 400; font-size: 10px; color: var(--ink-faint); }
.stk-table tr.copper td { background: color-mix(in srgb, var(--stk-copper) 9%, transparent); }
.stk-table tr.on td { background: var(--brand-pale); }
.stk-table tr.bad td { background: var(--bad-pale); }
.stk-table td.muted { color: var(--ink-faint); }
.stk-table td.imported { color: var(--ok); font-size: 11px; }
.stk-table input.bad { border-color: var(--danger); background: var(--bad-pale); }
.stk-table .stk-row-note { display: block; color: var(--danger); font-size: 10.5px; line-height: 1.3; white-space: normal; }
.stk-table .stk-row-note:empty { display: none; }
.stk-plate { width: 84px; white-space: nowrap; }
.stk-di-word { font-size: 11px; color: var(--ink-faint); }
.stk-chip {
    display: inline-block;
    min-width: 30px;
    padding: 0 4px;
    border: 1px solid var(--rule-firm);
    border-radius: var(--radius);
    font-family: var(--mono);
    font-size: 10px;
    text-align: center;
    color: var(--ink-soft);
    background: var(--panel);
}
.stk-kind { color: var(--ink-mid); font-size: 11.5px; }
.stk-sw { display: inline-block; width: 10px; height: 8px; margin-right: 6px; border-radius: 1px; vertical-align: 0; }
.stk-sw.copper { background: var(--stk-copper); }
.stk-sw.dielectric { background: var(--stk-laminate); border: 1px solid var(--stk-laminate-edge); }
.stk-solved { color: var(--ink); }
.stk-solved .stale { color: var(--amber); }
.stk-acts { white-space: nowrap; }
.stk-acts .icon-btn.small { width: 22px; height: 20px; }
.stk-acts .icon-btn svg, .pp-rects .icon-btn svg { width: 12px; height: 12px; }

.stk-actions { display: flex; align-items: center; gap: 10px; margin: 8px 0 6px; }
.stk-count { font-size: 11px; color: var(--ink-faint); }
.stk-vias { margin-top: 2px; }
.stk-figure { margin: 0; }
.stk-figure figcaption { margin-top: 6px; font-size: 10.5px; line-height: 1.4; color: var(--ink-faint); }

/* The hint beside the tools takes the room left on its row and shortens,
   rather than wrapping onto a row of its own and resizing the board under
   a drawing tool in mid-stroke. */
.pcb-tools .pcb-hint { flex: 1 1 0; text-align: right; }

.pcb-plate { min-width: 0; }
.pcb-plate.on { border-color: var(--brand); box-shadow: inset 0 -2px 0 var(--brand); }

/* ---------------------------------------------------------------- current paths */

.pcb-paths { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.pcb-cpath { pointer-events: auto; cursor: grab; }
.pcb-paths .hatch-bg, .pcb-path-tool .hatch-bg { fill: var(--path-fill); }
.pcb-paths .hatch-line, .pcb-path-tool .hatch-line { stroke: var(--path-line); stroke-width: 1.6; }
.pcb-cpath .cond { fill: none; stroke: var(--warm); stroke-width: 2.4; }
.pcb-cpath .cond-fill { fill: url(#pcb-path-hatch); stroke: none; }
.pcb-path-tool .pcb-cpath .cond-fill { fill: url(#pcb-path-hatch-t); }
.pcb-cpath .pad { stroke-width: 1.2; }
.pcb-cpath .pad.src { fill: var(--warm); stroke: var(--warm-deep); }
.pcb-cpath .pad.snk { fill: var(--cool); stroke: var(--cool-deep); }
.pcb-cpath .pad-mark {
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 600;
    fill: var(--on-fill);
    pointer-events: none;
}
.pcb-cpath .path-label {
    font-family: var(--mono);
    font-size: 9.5px;
    fill: var(--warm-deep);
    paint-order: stroke;
    stroke: rgb(var(--glass) / .85);
    stroke-width: 3px;
    stroke-linejoin: round;
    pointer-events: none;
}
.pcb-cpath.far { opacity: .3; }
.pcb-cpath.selected .cond { stroke: var(--board); stroke-width: 3; }
.pcb-cpath.bad:not(.drawing) .cond { stroke-dasharray: 5 3; }
.pcb-path-tool { cursor: crosshair; }
.pcb-path-tool .rubber { fill: none; stroke: var(--ink); stroke-width: 1.2; stroke-dasharray: 4 3; }
.pcb-path-tool .rubber.source { fill: color-mix(in srgb, var(--warm) 30%, transparent); stroke: var(--warm); }
.pcb-path-tool .rubber.sink { fill: color-mix(in srgb, var(--cool) 30%, transparent); stroke: var(--cool); }
.pcb-path-tool .pcb-cpath { cursor: crosshair; pointer-events: none; }

.pcb-path-list i { background: repeating-linear-gradient(45deg, var(--path-line) 0 1.5px, var(--path-fill) 1.5px 4px); border: 1.5px solid var(--warm); }
.pcb-region-list button.path.bad { border-color: var(--bad-line); }
.pcb-region-list button.path.bad small { color: var(--danger); }

.pp-head {
    margin: 14px 0 6px;
    font-family: var(--display);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-faint);
}
.pp-head span { text-transform: none; letter-spacing: 0; font-family: var(--sans); font-weight: 400; }
.pp-head .stale-word { color: var(--amber); text-transform: none; letter-spacing: 0; font-family: var(--sans); }
.pp-rects { width: 100%; border-collapse: collapse; font-size: 11px; table-layout: fixed; }
.pp-rects th { font-weight: 500; color: var(--ink-faint); text-align: left; padding: 0 2px 3px; font-size: 10.5px; }
.pp-rects thead th:first-child { width: 62px; }
.pp-rects thead th:last-child { width: 24px; }
.pp-rects tbody th { color: var(--ink-soft); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-rects td { padding: 1px 2px; }
.pp-rects input { width: 100%; padding: 2px 4px; font-family: var(--mono); font-size: 11px; }
.pp-rects input.bad { border-color: var(--danger); }
.pp-draw { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pp-draw button { padding: 3px 8px; font-size: 11.5px; }
.pp-problems {
    margin: 10px 0 0;
    padding: 6px 8px;
    border: 1px solid var(--bad-line);
    border-radius: var(--radius);
    background: var(--bad-pale);
    color: var(--danger);
    font-size: 11.5px;
    line-height: 1.45;
}
.pp-problems p { margin: 0; }
.pp-problems p + p { margin-top: 3px; }
#pp-ipc .pcb-derived { margin: 4px 0 0; }
.ipc-good { color: var(--ok); }
.ipc-warn { color: var(--amber); }
.ipc-bad { color: var(--danger); }
.pcb-figures.stale .v { color: var(--ink-faint); }
.pcb-figures .pcb-derived.bad { color: var(--danger); }

.pp-steps { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; }
.pp-steps li {
    display: grid;
    grid-template-columns: 22px 1fr auto;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--field);
    font-size: 12px;
    color: var(--ink-soft);
}
.pp-steps li .n {
    width: 18px; height: 18px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-family: var(--mono); font-size: 10.5px;
    border: 1px solid var(--rule-firm);
}
.pp-steps li b { font-weight: 500; color: var(--ink-mid); }
.pp-steps li small { font-size: 10.5px; color: var(--ink-faint); }
.pp-steps li.on { border-color: var(--brand); box-shadow: inset 2px 0 0 var(--brand); background: var(--panel); }
.pp-steps li.on b { color: var(--ink); font-weight: 600; }
.pp-steps li.done .n { background: var(--ok-pale); border-color: var(--ok-line); color: var(--ok); }
.pp-tool-acts { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- solids */

.solid-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.solid-pair.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.solid-pair .field label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.solid-panel .field > .label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    color: var(--ink-soft);
}
.solid-cond { margin: 2px 0 6px; }
.solid-if-edit h4 { margin-top: 14px; }
.solid-axes input { width: 100%; }
.solid-axes td:first-child { font-family: var(--mono); color: var(--ink-soft); }
.solid-axis-list dt { display: flex; align-items: center; gap: 6px; }
.solid-axis-list i.axis { display: inline-block; width: 12px; height: 3px; border-radius: 1px; }
.solid-axis-list i.a0 { background: #d93333; }
.solid-axis-list i.a1 { background: #339e40; }
.solid-axis-list i.a2 { background: #3361e6; }

.solid-legend {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 6px 0 8px;
    font-family: var(--mono);
    font-size: 10.5px;
    font-variant-numeric: tabular-nums;
    color: var(--ink-soft);
}
.solid-legend i { flex: 1; height: 9px; border-radius: var(--radius); border: 1px solid var(--rule-firm); }

/* The card's interface conditions in the inspector. */
.sc-row {
    padding: 7px 0 8px;
    border-bottom: 1px solid var(--rule);
    font-size: 12px;
}
.sc-row:last-of-type { border-bottom: 0; }
.sc-row .sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }
.sc-row b { font-weight: 600; color: var(--ink); }
.sc-row .sc-kind { display: block; margin: 2px 0 0 15px; color: var(--ink-soft); font-size: 11.5px; line-height: 1.4; }
.sc-row .field { margin: 6px 0 0 15px; }
.sc-row .link-note { margin-left: 15px; }

/* On the canvas: a film or radiating face is tagged; a merged ambient names its node. */
.solid-ports li .cond {
    display: inline-block;
    min-width: 12px;
    margin-right: 4px;
    padding: 0 2px;
    border: 1px solid var(--rule-firm);
    border-radius: var(--radius);
    font-family: var(--mono);
    font-size: 9px;
    line-height: 12px;
    text-align: center;
    color: var(--ink-soft);
}
.solid-ports li .into { color: var(--ink-faint); font-size: 10px; }
