/*! StiffStruct, (c) 2026 Mohammad Asad. All rights reserved. Proprietary: copying, mirroring or reusing this code is not permitted without written permission (see terms.html#intellectual-property). build 20261018-2133 */
/* 3D viewer / results canvas (js/ui/viewer3d.js). All colours come from the design-system variables;
   the axis colours below are the only semantic extras (X red, Y green, Z blue) and have dark variants. */

.v3d {
  --v3d-x: #e5484d;
  --v3d-y: #30a46c;
  --v3d-z: #3e63dd;
  container: v3d / inline-size;
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 240px;
  overflow: hidden;
  background: var(--bg-elev);
  font-family: var(--font-ui);
  user-select: none;
  -webkit-user-select: none;
  outline: none;
}
:root[data-theme="dark"] .v3d { --v3d-x: #ff6369; --v3d-y: #3dd68c; --v3d-z: #7d9bff; }
.v3d:focus-visible { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent); }

.v3d-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.v3d-canvas.is-hit { cursor: pointer; }
.v3d-canvas.is-add { cursor: crosshair; }
.v3d-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.v3d-labels * { pointer-events: none; }

/* CSS2D labels (node / member ids, load and result values) */
.v3d-label {
  font: 11px/1.25 var(--font-mono);
  padding: 0 4px;
  border-radius: 3px;
  color: var(--fg);
  background: color-mix(in srgb, var(--bg-elev) 78%, transparent);
  white-space: nowrap;
  pointer-events: none;
}
.v3d-label.is-node { color: var(--fg-muted); font-size: 10.5px; }
.v3d-label.is-member { color: var(--member); font-size: 10.5px; background: transparent; }
.v3d-label.is-load { color: var(--load); }
.v3d-label.is-reaction { color: var(--reaction); }
.v3d-label.is-value { font-weight: 600; }
.v3d-label.is-N { color: var(--diag-N); }
.v3d-label.is-V { color: var(--diag-V); }
.v3d-label.is-M { color: var(--diag-M); }
.v3d-label.is-T { color: var(--diag-T); }
.v3d-label.is-d { color: var(--deflected); }

/* toolbars */
.v3d-top {
  position: absolute; top: 10px; left: 10px; right: 10px; z-index: 3;
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  pointer-events: none;
}
.v3d-bar {
  align-self: stretch;
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 6px 8px;
  pointer-events: none;
}
.v3d-tb {
  pointer-events: auto;
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  padding: 4px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  max-width: 100%;
}
.v3d-tb .btn { flex: none; white-space: nowrap; }
.v3d-tb .btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text, var(--accent)); }
.v3d-tb .v3d-scale { min-width: 34px; justify-content: center; font-variant-numeric: tabular-nums; }
.v3d-sep { flex: none; width: 1px; align-self: stretch; margin: 3px 4px; background: var(--border); }
.v3d-sub { display: flex; max-width: 100%; pointer-events: none; }
.v3d-sub[hidden] { display: none; }
.v3d-sub .v3d-tb { flex-wrap: wrap; }
.v3d-sub .v3d-note { padding: 0 6px; color: var(--fg-muted); font-size: 12px; }
.v3d-preset .wg-ic { color: var(--support); }

/* bottom-left caption / legend */
.v3d-caption {
  position: absolute; left: 10px; bottom: 10px; z-index: 2;
  max-width: calc(100% - 130px);
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  padding: 5px 10px;
  font-size: 12px; color: var(--fg-muted);
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  pointer-events: none;
}
.v3d-caption:empty { display: none; }
.v3d-caption b { color: var(--fg); font-weight: 600; }
.v3d-lg { display: inline-flex; align-items: center; gap: 5px; color: var(--fg); }
.v3d-lg i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.v3d-lg .t { background: var(--tension); }
.v3d-lg .c { background: var(--compression); }
.v3d-lg .z { background: var(--zero-force); }

/* message banner (no results / errors) */
.v3d-msg {
  position: absolute; left: 50%; top: 64px; transform: translateX(-50%); z-index: 4;
  max-width: min(520px, calc(100% - 24px));
  padding: 7px 12px;
  font-size: 12.5px; color: var(--fg);
  background: var(--bg-elev);
  border: 1px solid var(--warning); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-1);
  pointer-events: none;
}
.v3d-msg[hidden] { display: none; }
.v3d-msg.is-error { border-color: var(--danger); }

/* tooltip */
.v3d-tip {
  position: absolute; z-index: 5; pointer-events: none;
  padding: 3px 8px;
  font: 11.5px/1.3 var(--font-mono);
  color: var(--bg-elev); background: var(--fg); opacity: 0.9;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.v3d-tip[hidden] { display: none; }

/* axis triad (bottom-right) */
.v3d-triad { position: absolute; right: 10px; bottom: 10px; width: 88px; height: 88px; pointer-events: none; z-index: 2; }
.v3d-triad span {
  position: absolute; transform: translate(-50%, -50%);
  font: 700 11px/1 var(--font-ui);
}
.v3d-triad .ax-x { color: var(--v3d-x); }
.v3d-triad .ax-y { color: var(--v3d-y); }
.v3d-triad .ax-z { color: var(--v3d-z); }

.v3d-form { display: grid; gap: 8px; }
.v3d-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* the canvas (not the window) decides: with side panels open it is much narrower than the viewport */
@container v3d (max-width: 900px) {
  .v3d-tb .lbl { display: none; }
  .v3d-tb .v3d-viewtxt .lbl, .v3d-tb .v3d-scale .lbl { display: inline; } /* text-only buttons must keep their label */
}
