/* ============================================================
   ATLAS — Free Body tab (fbd-ui.js owns the markup; this file its look)
   Three panes like Analysis: the model rail, the 3-D view over the
   N / V / T / M diagrams, the results rail. Every selector here is
   .fbd-… / #fbd-… / #panel-fbd (tests/atlas-wiring.mjs); the shared
   controls (.field, .pill-toggle, .btn, .readout-mini, .hint) keep
   styles.css's look and are only placed from here.
   ============================================================ */

#panel-fbd { display: flex; }

.fbd-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 372px;
  min-width: 0;
  min-height: 0;
}

/* ---- left rail: the model ---- */

.fbd-rail,
.fbd-results {
  background: var(--panel-solid);
  overflow-y: auto;
  min-height: 0;
  padding: 16px 16px 48px;
}

.fbd-rail { border-right: 1px solid var(--aether-faint); }
.fbd-results { border-left: 1px solid var(--aether-faint); }

.fbd-title {
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.25;
  color: var(--white);
  margin: 8px 0 6px;
}

.fbd-text {
  font-size: 11px;
  line-height: 1.6;
  color: var(--white-dim);
  margin: 0 0 12px;
}

.fbd-sec { border-top: 1px solid var(--aether-faint); }

.fbd-sec-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  padding: 12px 0 10px;
  cursor: pointer;
  text-align: left;
}

.fbd-sec-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--aether);
  width: 18px;
}

.fbd-sec-title {
  flex: 1;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--aether);
}

.fbd-sec[data-open="false"] .fbd-sec-title { color: var(--white-faint); }
.fbd-sec[data-open="false"] .fbd-sec-body { display: none; }

.fbd-sec-count {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--white-faint);
}

.fbd-sec-body { padding: 0 0 16px; }

/* Captions carry units and symbols (mm, N·mm, μ, g), which text-transform would corrupt —
   'μ' uppercases to 'Μ' and reads as M, 'g' as G — so they, the field labels and the table
   headers stay in sentence case; only unit-free eyebrows are uppercase. */
.fbd-sub {
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--white-faint);
  margin: 12px 0 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.fbd-sub-note {
  text-transform: none;
  letter-spacing: 0.02em;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--white-faint);
}

.fbd-v {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 62%;
}

/* doubled class: beats styles.css's .readout-mini .v (nowrap) without naming it */
.fbd-v-wrap.fbd-v-wrap { white-space: normal; text-align: right; }

label.fbd-label {
  text-transform: none;
  letter-spacing: 0.03em;
  font-size: 10.5px;
}

.fbd-pills { margin-bottom: 8px; }
.fbd-wide { width: 100%; margin-top: 8px; }

.fbd-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.fbd-actions-report { margin-top: 14px; }

.fbd-btn-sm {
  padding: 6px 9px;
  font-size: 9.5px;
  letter-spacing: 0.12em;
}

.fbd-btn-xs {
  padding: 2px 7px;
  font-size: 9px;
  letter-spacing: 0.1em;
  margin-left: auto;
}

.fbd-pick[aria-pressed="true"] {
  background: var(--aether-faint);
  border-color: var(--aether);
  color: var(--aether-bright);
}

.fbd-select {
  flex: 1;
  min-width: 0;
  background: var(--inset);
  border: 1px solid var(--aether-faint);
  color: var(--white);
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 6px;
  border-radius: var(--radius);
}

/* the item lists: one row per support / load / case */
.fbd-list { display: flex; flex-direction: column; gap: 3px; }

.fbd-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 8px;
  border: 1px solid var(--aether-ghost);
  border-radius: var(--radius);
  font-size: 10.5px;
  color: var(--white-dim);
  cursor: pointer;
}

.fbd-row:hover { border-color: var(--aether-faint); }

/* the row's id and text are one real button (keyboard: Tab to it, Enter / Space selects);
   it looks like the row, not like a button */
.fbd-row-pick {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.fbd-row-sel {
  border-color: var(--aether-dim);
  background: var(--aether-ghost);
  color: var(--white);
}

.fbd-row-id {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--aether);
  min-width: 22px;
}

.fbd-row-txt {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fbd-row-n {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--white-faint);
  white-space: nowrap;
}

.fbd-row-del {
  background: none;
  border: none;
  color: var(--white-faint);
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}

.fbd-row-del:hover:not(:disabled) { color: var(--alarm); }
.fbd-row-del:disabled { opacity: 0.25; cursor: default; }

.fbd-case-row { cursor: default; }

.fbd-case-name,
.fbd-combo-name,
.fbd-factor {
  background: var(--inset);
  border: 1px solid var(--aether-faint);
  color: var(--white);
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 3px 5px;
  border-radius: 3px;
  outline: none;
  min-width: 0;
}

.fbd-case-name { flex: 1; }
.fbd-combo-name { width: 100%; margin-top: 2px; }
/* wide enough for '1.35' beside WebKit's spin buttons, which are hidden anyway: a factor is typed */
.fbd-factor { width: 58px; text-align: right; appearance: textfield; -moz-appearance: textfield; }
.fbd-factor::-webkit-inner-spin-button,
.fbd-factor::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.fbd-combos { overflow-x: auto; margin-bottom: 6px; }

/* the editor of the selected item */
.fbd-editor {
  margin-top: 10px;
  padding: 10px 10px 12px;
  border: 1px solid var(--aether-faint);
  border-radius: var(--radius);
  background: rgba(22, 22, 22, 0.55);
}

.fbd-note { margin: 0 0 4px; }

.fbd-xyz { gap: 6px; }

.fbd-btn-flip {
  align-self: flex-end;
  padding: 6px 8px;
  margin-bottom: 13px;
  letter-spacing: 0;
  font-family: var(--mono);
}

.fbd-mask { display: flex; gap: 3px; }

.fbd-mask button {
  flex: 1;
  background: none;
  border: 1px solid var(--aether-faint);
  border-radius: 3px;
  color: var(--white-faint);
  font-family: var(--mono);
  font-size: 10px;
  padding: 5px 0;
  cursor: pointer;
}

.fbd-mask button[aria-pressed="true"] {
  background: var(--aether-faint);
  border-color: var(--aether-dim);
  color: var(--aether-bright);
}

/* the stiffness block is an ASSUMPTION: set apart in caution */
.fbd-assume {
  margin-top: 10px;
  padding: 2px 0 0 10px;
  border-left: 2px solid rgba(201, 154, 107, 0.45);
}

.fbd-assume .fbd-sub { color: var(--caution); letter-spacing: 0.02em; }

/* ---- centre: the 3-D view over the diagrams ---- */

/* One column bounded by the track: left implicit (auto) it grows to its items' min-content,
   and a canvas's min-content is its BITMAP width, which the next redraw re-measures from
   the grown box — WebKit measured the diagram canvas at 846 px in a 768 px column, feeding
   itself. minmax(0, 1fr) plus min-width 0 on both rows, and an absolutely placed canvas,
   keep a bitmap from ever sizing the layout. */
.fbd-center {
  display: grid;
  grid-template-rows: minmax(0, 1fr) 244px;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.fbd-viewport { min-height: 0; min-width: 0; }

.fbd-legend {
  position: absolute;
  right: 14px;
  top: 12px;
  display: flex;
  gap: 12px;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--white-faint);
  pointer-events: none;
}

.fbd-key::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 3px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: middle;
  background: var(--aether);
}

.fbd-key[data-cat="weight"]::before { background: var(--caution); }
.fbd-key[data-cat="reaction"]::before { background: #8FB3BA; }
.fbd-key[data-cat="alarm"]::before { background: var(--alarm); }

.fbd-diagrams {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--panel-solid);
  border-top: 1px solid var(--aether-faint);
}

.fbd-diag-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px 4px;
  min-width: 0;
}

.fbd-diag-axis { margin: 0; width: 196px; flex-shrink: 0; }
.fbd-diag-axis button { padding: 4px 3px; }

/* pills that carry units or symbols (kN, N·mm, 'Cut n'): styles.css uppercases pill
   buttons, which turns kN into KN and n into N */
#panel-fbd .fbd-unit-pills button { text-transform: none; letter-spacing: 0.04em; }

.fbd-diag-frame {
  padding: 0 14px 2px;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--white-dim);
  line-height: 1.45;
}

.fbd-dir { font-size: 9px; color: var(--white-faint); }

.fbd-diag-readout {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--white-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}

.fbd-diag-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  margin: 0 10px 8px;
}

.fbd-diag-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; cursor: crosshair; }

.fbd-diag-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--white-faint);
  background: var(--panel-solid);
  text-align: center;
  padding: 0 24px;
}

/* ---- right rail: results ---- */

.fbd-verdict {
  border: 1px solid var(--aether-faint);
  border-left: 2px solid var(--aether-dim);
  border-radius: var(--radius);
  padding: 11px 12px 10px;
  margin-bottom: 16px;
  background: rgba(22, 22, 22, 0.55);
}

.fbd-verdict[data-kind="ok"] { border-left-color: var(--aether); }
.fbd-verdict[data-kind="warn"] { border-left-color: var(--caution); }
.fbd-verdict[data-kind="err"] { border-left-color: var(--alarm); }

.fbd-verdict-title {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.25;
  color: var(--white);
  margin-bottom: 5px;
}

.fbd-verdict[data-kind="warn"] .fbd-verdict-title { color: var(--caution); }
.fbd-verdict[data-kind="err"] .fbd-verdict-title { color: var(--alarm); }

.fbd-verdict-sub {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--caution);
  margin-bottom: 5px;
}

.fbd-verdict-text {
  font-size: 11px;
  line-height: 1.6;
  color: var(--white-dim);
}

.fbd-verdict-list {
  margin: 6px 0 0;
  padding-left: 16px;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--white-dim);
}

.fbd-verdict-list li[data-kind="warn"] { color: var(--caution); }
.fbd-verdict-list li[data-kind="err"] { color: var(--alarm); }

.fbd-block {
  border-top: 1px solid var(--aether-faint);
  padding: 12px 0 14px;
}

.fbd-eyebrow { margin-bottom: 8px; }
.fbd-eyebrow-v { color: var(--white-faint); letter-spacing: 0.08em; }

.fbd-empty {
  font-size: 11px;
  line-height: 1.55;
  color: var(--white-faint);
}

.fbd-bad { color: var(--alarm); }
.fbd-warn { color: var(--caution); }

.fbd-card {
  border: 1px solid var(--aether-ghost);
  border-radius: var(--radius);
  padding: 8px 9px 7px;
  margin-bottom: 8px;
}

.fbd-card[data-state="lifted"],
.fbd-card[data-state="slack"] { border-color: rgba(201, 154, 107, 0.35); }

.fbd-card-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.fbd-card-id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--aether-bright);
}

.fbd-card-type {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--white-dim);
}

.fbd-card-pt {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--white-faint);
}

.fbd-chip {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--aether-faint);
  color: var(--aether);
  white-space: nowrap;
}

.fbd-chip[data-kind="warn"] { color: var(--caution); border-color: rgba(201, 154, 107, 0.45); }
.fbd-chip[data-kind="bad"] { color: var(--alarm); border-color: rgba(196, 97, 74, 0.5); }

/* the support-frame components, as label / value pairs */
.fbd-frame {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px 10px;
  margin-bottom: 6px;
}

.fbd-comp {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-family: var(--mono);
  font-size: 10.5px;
  white-space: nowrap;
  min-width: 0;
}

.fbd-comp-l { color: var(--white-faint); min-width: 22px; }
.fbd-comp .fbd-num { color: var(--white); overflow: hidden; text-overflow: ellipsis; }

.fbd-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 10.5px;
  margin: 2px 0 4px;
  table-layout: auto;
}

.fbd-table th {
  font-family: var(--sans);
  font-weight: 400;
  font-size: 9.5px;
  letter-spacing: 0.04em;
  color: var(--white-faint);
  text-align: right;
  padding: 2px 4px 3px;
  border-bottom: 1px solid var(--aether-faint);
}

.fbd-table td {
  text-align: right;
  padding: 3px 4px;
  color: var(--white);
  border-bottom: 1px solid var(--aether-ghost);
  white-space: nowrap;
}

.fbd-table th:first-child,
.fbd-table td:first-child {
  text-align: left;
  color: var(--white-dim);
  padding-left: 0;
  white-space: normal;
}

.fbd-by { color: var(--aether); font-size: 9.5px; }

.fbd-combo th,
.fbd-combo td { padding: 3px 3px; }
.fbd-combo td:first-child { min-width: 96px; }

.fbd-num { font-family: var(--mono); color: var(--white); }

.fbd-friction,
.fbd-resid,
.fbd-offset,
.fbd-gov,
.fbd-link-pass,
.fbd-margin-row {
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--white-dim);
  margin-top: 4px;
}

.fbd-gov-per {
  display: block;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--white-faint);
}

.fbd-conv { margin: 2px 0 8px; }

.fbd-hand {
  margin: 12px 0 4px;
  padding: 6px 8px;
  border: 1px dashed rgba(201, 154, 107, 0.45);
  border-radius: var(--radius);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  line-height: 1.5;
  color: var(--caution);
}

.fbd-margin {
  margin-top: 8px;
  padding: 7px 9px;
  border-left: 2px solid var(--aether);
  background: rgba(22, 22, 22, 0.55);
}

.fbd-margin[data-pass="false"] { border-left-color: var(--alarm); }
.fbd-ms { font-size: 12px; margin-right: 6px; }

.fbd-cut-controls { margin-top: 4px; }

.fbd-link-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 10.5px;
  color: var(--white-dim);
  margin-bottom: 4px;
}

.fbd-assume-note {
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--white-dim);
  margin: 8px 0;
  padding-left: 8px;
  border-left: 2px solid var(--aether-faint);
}

.fbd-assume-note.fbd-warn { border-left-color: rgba(201, 154, 107, 0.6); color: var(--caution); }

/* ---- narrower windows ---- */

@media (max-width: 1180px) {
  .fbd-layout { grid-template-columns: 268px minmax(0, 1fr) 320px; }
  .fbd-center { grid-template-rows: minmax(0, 1fr) 240px; }
  .fbd-diag-head { flex-wrap: wrap; row-gap: 4px; }
  .fbd-diag-readout { flex-basis: 100%; text-align: left; }
  .fbd-table { font-size: 10px; }
  .fbd-frame { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fbd-legend { display: none; }
}

/* One column that scrolls as a whole. The rails stop being their own scroll containers
   here: a scroll container's automatic minimum height is 0, so as auto grid rows they were
   squeezed to 158 px strips (WebKit, 860 × 900) with the editors behind a tiny window. */
@media (max-width: 900px) {
  .fbd-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(60vh, auto) auto; overflow-y: auto; }
  .fbd-rail, .fbd-results { overflow: visible; min-height: auto; padding-bottom: 20px; }
  .fbd-rail { border-right: none; border-bottom: 1px solid var(--aether-faint); }
  .fbd-results { border-left: none; border-top: 1px solid var(--aether-faint); }
  .fbd-center { grid-template-rows: 60vh 300px; }
}
