/* OpenWorldEngineer: bearing fault embeddings (artifacts-bearing.html, assets/art/bearing.js). Builds on styles.css
   (tokens, .card, .seg, .note, .tip); adds only bf- classes.

   Colour: the eight true conditions. Seven hues from the dataviz reference palette in an order that passes the
   validator's adjacent checks in light and dark (orange is never paired with red: there is no red), and healthy as a
   neutral ink tone (deliberately grey: "no fault"). Eight colours cannot all be told apart pairwise in a scatter, so
   every condition also has its own marker shape, a name in the legend and a direct label at its centre. */

.bf {
  container-type: inline-size;
  --bf-c0: #4A4F57; --bf-c1: #2A78D6; --bf-c2: #EB6834; --bf-c3: #6250D6;
  --bf-c4: #008300; --bf-c5: #E87BA4; --bf-c6: #EDA100; --bf-c7: #1BAF7A;
  --bf-frame: var(--rule);
  display: grid; gap: 16px; min-width: 0; color: var(--ink); font-size: var(--fs-ui);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bf {
    --bf-c0: #C9CDD3; --bf-c1: #3987E5; --bf-c2: #D95926; --bf-c3: #9085E9;
    --bf-c4: #008300; --bf-c5: #D55181; --bf-c6: #C98500; --bf-c7: #199E70;
  }
}
:root[data-theme="dark"] .bf {
  --bf-c0: #C9CDD3; --bf-c1: #3987E5; --bf-c2: #D95926; --bf-c3: #9085E9;
  --bf-c4: #008300; --bf-c5: #D55181; --bf-c6: #C98500; --bf-c7: #199E70;
}
.bf-head p { max-width: 78ch; }
.bf.is-loading .bf-grid { opacity: 0.6; }

.bf-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 18px; }
.bf-field { display: grid; gap: 4px; min-width: 0; }
.bf-field-k { font-size: 0.75rem; font-weight: 600; color: var(--muted); }

/* legend: one toggle per condition (isolates it in every panel), then the marker key */
.bf-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.bf-lg {
  display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 3px 9px 3px 6px; margin: 0;
  border: 1px solid transparent; border-radius: 0; background: transparent; color: var(--ink-2);
  font: inherit; font-size: 0.8125rem; cursor: pointer; white-space: nowrap;
}
.bf-lg:hover { background: var(--hover); color: var(--ink); }
.bf-lg[aria-pressed="true"] { border-color: var(--rule-strong); background: var(--hover); color: var(--ink); }
.bf-lg:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.bf-legend.is-dim .bf-lg[aria-pressed="false"] { opacity: 0.55; }
.bf-glyph { display: block; flex: none; overflow: visible; }
.bf-key { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.75rem; color: var(--muted); }
.bf-key span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

/* one panel per model */
.bf-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.bf-card { display: grid; gap: 8px; align-content: start; min-width: 0; padding: 12px 14px 14px; }
.bf-card.is-focus { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.bf-card-head { display: grid; gap: 2px; min-width: 0; }
.bf-name { margin: 0; font-family: var(--font-sans); font-size: 0.9375rem; font-weight: 650; line-height: 1.3; }
.bf-sub { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.bf-traj { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--ink-2); }
.bf-dot { color: var(--rule-strong); }
.bf-ba { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; font-size: 0.8125rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.bf-ba b { font-family: var(--font-mono); font-size: 0.9375rem; font-weight: 650; color: var(--ink); }
.bf-ba .bf-rr { font-size: 0.75rem; color: var(--muted); }
.bf-ne { font-weight: 700; color: var(--accent-ink); }

.bf-plot { position: relative; min-width: 0; border-radius: var(--radius-sm); }
.bf-plot svg { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--font-sans); }
.bf-plot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bf-frame { fill: none; stroke: var(--bf-frame); stroke-width: 1; }
.bf-axis0 { stroke: var(--rule); stroke-width: 1; }
.bf-pt { stroke-linejoin: round; }
.bf-pt.ok { stroke: var(--sheet); stroke-width: 1; paint-order: stroke; }
.bf-pt.bad { fill: var(--sheet); stroke-width: 1.4; }
.bf-anchor { stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; }
.bf-anchor-halo { stroke: var(--sheet); stroke-width: 4; stroke-linecap: round; }
.bf-al { font-size: 11px; font-weight: 600; fill: var(--ink); paint-order: stroke; stroke: var(--sheet); stroke-width: 3px; stroke-linejoin: round; }
.bf-al.is-off { opacity: 0.35; }
.bf-hl { fill: none; stroke: var(--ink); stroke-width: 1.5; pointer-events: none; }

/* per-condition recall */
.bf-rec { display: grid; gap: 2px; }
.bf-rec-row {
  display: grid; grid-template-columns: 14px minmax(0, 6.6rem) minmax(0, 1fr) 2.9rem 3.7rem; align-items: center; gap: 6px;
  min-height: 16px; font-size: 0.75rem; color: var(--ink-2);
}
.bf-rec-row.is-off { opacity: 0.4; }
.bf-rec-n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bf-rec-t { position: relative; height: 10px; border-radius: 0; background: var(--hover); }
.bf-rec-t i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0; }
.bf-rec-t u { position: absolute; top: -2px; bottom: -2px; width: 0; border-left: 1px solid var(--muted); }
.bf-rec-v { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
.bf-rec-r { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.bf-rec-axis { display: grid; grid-template-columns: 14px minmax(0, 6.6rem) minmax(0, 1fr) 2.9rem 3.7rem; gap: 6px; font-size: 0.6875rem; color: var(--muted); }
.bf-rec-axis span:nth-child(3) { position: relative; height: 14px; }
.bf-rec-axis em { position: absolute; top: 0; transform: translateX(-50%); font-style: normal; font-family: var(--font-mono); font-size: 10px; white-space: nowrap; }
.bf-rec-axis em:first-child { transform: none; }
.bf-rec-axis em:last-child { transform: translateX(-100%); }

/* one condition isolated from the legend (data-cond on .bf) */
.bf[data-cond="0"] .bf-pt:not(.c0) { opacity: 0.1; }
.bf[data-cond="1"] .bf-pt:not(.c1) { opacity: 0.1; }
.bf[data-cond="2"] .bf-pt:not(.c2) { opacity: 0.1; }
.bf[data-cond="3"] .bf-pt:not(.c3) { opacity: 0.1; }
.bf[data-cond="4"] .bf-pt:not(.c4) { opacity: 0.1; }
.bf[data-cond="5"] .bf-pt:not(.c5) { opacity: 0.1; }
.bf[data-cond="6"] .bf-pt:not(.c6) { opacity: 0.1; }
.bf[data-cond="7"] .bf-pt:not(.c7) { opacity: 0.1; }
.bf[data-cond="0"] :is(.bf-al, .bf-anchor, .bf-rec-row, .bf-rec-card):not(.c0) { opacity: 0.3; }
.bf[data-cond="1"] :is(.bf-al, .bf-anchor, .bf-rec-row, .bf-rec-card):not(.c1) { opacity: 0.3; }
.bf[data-cond="2"] :is(.bf-al, .bf-anchor, .bf-rec-row, .bf-rec-card):not(.c2) { opacity: 0.3; }
.bf[data-cond="3"] :is(.bf-al, .bf-anchor, .bf-rec-row, .bf-rec-card):not(.c3) { opacity: 0.3; }
.bf[data-cond="4"] :is(.bf-al, .bf-anchor, .bf-rec-row, .bf-rec-card):not(.c4) { opacity: 0.3; }
.bf[data-cond="5"] :is(.bf-al, .bf-anchor, .bf-rec-row, .bf-rec-card):not(.c5) { opacity: 0.3; }
.bf[data-cond="6"] :is(.bf-al, .bf-anchor, .bf-rec-row, .bf-rec-card):not(.c6) { opacity: 0.3; }
.bf[data-cond="7"] :is(.bf-al, .bf-anchor, .bf-rec-row, .bf-rec-card):not(.c7) { opacity: 0.3; }

.bf-note { margin: 0; max-width: 92ch; }
.bf-status:empty { display: none; }

/* context strip: one public dev record per condition */
.bf-strip-card { display: grid; gap: 10px; min-width: 0; padding: 14px 16px 16px; }
.bf-h { margin: 0; font-family: var(--font-sans); font-size: 0.9375rem; font-weight: 650; line-height: 1.3; }
.bf-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 16px; }
.bf-rec-card { display: grid; gap: 4px; min-width: 0; }
.bf-anchor-key { stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; }
.bf-rec-h { display: flex; align-items: center; gap: 6px; font-size: 0.8125rem; font-weight: 600; color: var(--ink); white-space: nowrap; }
.bf-rec-h small { margin-left: auto; font-weight: 400; font-size: 0.6875rem; color: var(--muted); font-family: var(--font-mono); }
.bf-mini { position: relative; min-width: 0; }
.bf-mini svg { display: block; width: 100%; height: auto; overflow: visible; }
.bf-wave { fill: none; stroke: var(--ink-2); stroke-width: 1; stroke-linejoin: round; }
.bf-spec { fill: none; stroke-width: 1.5; stroke-linejoin: round; }
.bf-spec-area { stroke: none; opacity: 0.12; }
.bf-grid-l { stroke: var(--rule); stroke-width: 1; }
.bf-tick { fill: var(--muted); font-family: var(--font-mono); font-size: 9.5px; font-variant-numeric: tabular-nums; }
.bf-cross { stroke: var(--muted); stroke-width: 1; pointer-events: none; }

@container (max-width: 980px) {
  .bf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container (max-width: 620px) {
  .bf-grid { grid-template-columns: minmax(0, 1fr); }
  .bf-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .bf-tick { font-size: 13px; }
}
@container (max-width: 420px) {
  .bf-card, .bf-strip-card { padding: 12px; }
  .bf-controls .bf-field { flex: 1 1 100%; }
  .bf-controls .seg { display: flex; }
  .bf-controls .seg button { flex: 1; padding-inline: 6px; }
}
@media (forced-colors: active) {
  .bf-pt.ok { fill: CanvasText; }
  .bf-pt.bad { stroke: CanvasText; }
}

/* a task page's frame (html.embed, see app.js initEmbed): one panel, the scatter beside its accuracy and recall */
.embed .bf-lg { cursor: default; }
.embed .bf-grid { grid-template-columns: minmax(0, 1fr); }
.embed .bf-card { grid-template-columns: minmax(0, 440px) minmax(0, 1fr); grid-template-rows: auto auto 1fr; grid-template-areas: "plot head" "plot ba" "plot rec"; gap: 8px 28px; }
.embed .bf-card > .bf-card-head { grid-area: head; }
.embed .bf-card > .bf-ba { grid-area: ba; }
.embed .bf-card > .bf-plot { grid-area: plot; }
.embed .bf-card > .bf-rec { grid-area: rec; align-self: start; }
@container (max-width: 620px) {
  .embed .bf-card { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-template-areas: "head" "ba" "plot" "rec"; }
}
