/* ── Global configurable CSS variables (editable via Settings panel) ────────── */
:root {
  --ui-font:       var(--font-ui); /* references base.css --font-ui */
  --bubble-min-w:  250px;
  --bubble-max-w:  440px;
}

/* ── Per-bubble width resize handle (leader-drag.js: ldAttachBubbleResizeHandle) ──
   Shared across .mat-bubble/.jnt-bubble/.goal-bubble (Materials, Joints,
   Load Cases, Solution Outputs) — all already position:relative, so the
   handle sits absolutely against the bubble's own right edge regardless of
   which tag type it belongs to. */
.bubble-resize-handle {
  position: absolute;
  /* Starts below the edit button (a 20px circle centered on the bubble's
     top-right corner, top:-9px/right:-9px in joints.css etc.) — the handle
     used to run the bubble's full height, so its hit zone overlapped the
     button and the cursor stayed stuck on <-> (ew-resize) even directly over
     "edit", making the button unreliable to click. */
  top: 16px;
  right: -7px;
  width: 14px;
  height: calc(100% - 16px);
  cursor: ew-resize;
  pointer-events: all;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.bubble-resize-grip {
  width: 4px;
  height: 28px;
  min-height: 60%;
  background: rgba(43,47,54,0.2);
  border-radius: 2px;
  transition: background 0.12s, width 0.12s;
}
.bubble-resize-handle:hover .bubble-resize-grip,
.bubble-resize-grip.active {
  background: var(--orange);
  width: 5px;
}

/* =============================================================================
   viewer.css  —  Endeavos Online SOW
   Step 3+ full-screen 3D viewer: canvas, SVG leader-line overlay,
   viewer toolbar, view-preset buttons, status bar, loading overlay,
   hover tooltip, coordinate triad, empty-state panel.
============================================================================= */

/* ── Viewer area — fills the entire content shell ────────────────────────── */
#viewer-area {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  background: #fff;
  user-select: none;
  -webkit-user-select: none;
}

/* Three.js canvas */
#canvas {
  display: block;
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

/* SVG overlay for leader lines and anchor dots (pointer-events: none so
   clicks pass through to the canvas) */
#leader-svg,
#jnt-leader-svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 5;
  overflow: visible;
}

/* ── Empty state (shown when no STEP file has been uploaded) ─────────────── */
#no-model-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 8;
  background: rgba(244,245,247,0.95);
  backdrop-filter: blur(6px);
}
.nm-icon  { font-size: 52px; opacity: .25; }
.nm-title { font-family: "Archivo"; font-size: 18px; font-weight: 700; color: var(--ink); }
.nm-sub   { font-size: 13px; color: var(--ink-soft); }
.nm-btn {
  padding: 10px 28px;
  background: var(--orange);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-family: "Archivo";
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
}
.nm-btn:hover { background: var(--accent2); }

/* ── Viewer toolbar (top-right: tag mode, reset, screenshot) ─────────────── */
#viewer-toolbar {
  position: absolute;
  top: 10px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  gap: 4px;
  z-index: 900;
}
.vtool-btn {
  width: 34px; height: 34px;
  background: rgba(255,255,255,0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: .15s;
  position: relative;
}
.vtool-btn:hover {
  background: var(--orange-soft);
  color: var(--orange);
}
.vtool-btn:active {
  background: var(--orange);
  color: #fff;
  border-color: var(--orange);
  transform: scale(0.93);
}
/* Tooltip on hover — appears BELOW toolbar buttons now that the toolbar is
   a horizontal row across the top instead of a vertical column on the right */
.vtool-btn[data-tip]::before {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(43,47,54,.9);
  color: #fff;
  font-size: 11px;
  font-family: "Hanken Grotesk", sans-serif;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 9999;
}
/* Up-pointing caret */
.vtool-btn[data-tip]::after {
  content: '';
  position: absolute;
  top: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: rgba(43,47,54,.9);
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 9999;
}
.vtool-btn[data-tip]:hover::before,
.vtool-btn[data-tip]:hover::after { opacity: 1; }
.vtool-sep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }
.vtool-btn.inactive { color: var(--ink-soft); }
#vtool-undo { font-size: 16px; }
.vtool-pick { width: auto; padding: 0 10px; font-size: 11px; font-weight: 700; font-family: "Archivo", sans-serif; letter-spacing: 0.02em; }

/* ── View presets (bottom-centre: Front / Top / Right / Iso) ─────────────── */
/* Pick mode toggle — top-center */
#pick-mode-bar {
  position: absolute;
  top: 10px;
  /* Anchored to the right edge rather than a % of the viewport, so it always
     clears the tag dialogs (right: 230px + 310px wide = 540px of occupied
     space) no matter how wide the viewer gets. */
  right: 560px;
  display: none;
  gap: 0;
  z-index: 6;
  background: rgba(255,255,255,0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}
.pick-mode-btn {
  padding: 6px 18px;
  font-size: 11.5px;
  font-weight: 700;
  font-family: "Archivo", sans-serif;
  background: transparent;
  border: none;
  border-right: 1px solid var(--line);
  cursor: pointer;
  color: var(--ink-soft);
  transition: background .12s, color .12s;
  letter-spacing: 0.03em;
}
.pick-mode-btn:last-child { border-right: none; }
.pick-mode-btn:hover { background: var(--orange-soft); color: var(--orange); }
.pick-mode-btn.active { background: var(--orange); color: #fff; }

#view-presets {
  position: absolute;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  z-index: 6;
}
.preset-btn {
  width: 38px;
  height: 30px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255,255,255,0.96);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink-soft);
  transition: .15s;
  font-family: "Hanken Grotesk";
}
.preset-btn:hover {
  border-color: var(--orange);
  color: var(--orange);
  background: var(--orange-soft);
}
.preset-btn.active {
  border-color: var(--orange);
  color: #fff;
  background: var(--orange);
}
/* "Previous view" button carries longer text and only appears conditionally —
   exempt it from the uniform icon-button width every other preset button shares. */
#preset-prev {
  width: auto;
  padding: 5px 10px;
}
/* Tooltip for bottom-bar preset buttons — appears above the button */
.preset-btn[data-tip] { position: relative; overflow: visible; }
.preset-btn[data-tip]::before {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(43,47,54,.9);
  color: #fff;
  font-size: 11px;
  font-family: "Hanken Grotesk", sans-serif;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 9999;
}
.preset-btn[data-tip]::after {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(43,47,54,.9);
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 9999;
}
.preset-btn[data-tip]:hover::before,
.preset-btn[data-tip]:hover::after { opacity: 1; }

/* ── Status bar (bottom edge: OCCT status, triangle & part counts) ───────── */
#statusbar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 28px;
  background: rgba(255,255,255,0.93);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 20px;
  font-size: 11px;
  color: var(--ink-soft);
  font-family: "IBM Plex Mono", monospace;
  z-index: 6;
}
.stat { display: flex; align-items: center; gap: 6px; }
.stat-dot { width: 6px; height: 6px; border-radius: 50%; }

/* ── Viewer loading overlay (shown while STEP is parsing) ────────────────── */
#viewer-loading {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(255,255,255,.88);
  z-index: 15;
  backdrop-filter: blur(4px);
}
#viewer-loading.show { display: flex; }
.load-msg { font-size: 13px; color: var(--ink-soft); }

/* ── Hover tooltip (bottom-left of viewer, just above the status bar —
   matches SolidWorks/ANSYS convention of keeping hover hints out of the way
   of the toolbar and main view. Left-aligned rather than centered since
   #view-presets already occupies the bottom-center slot. ──────────────── */
.hover-info {
  position: absolute;
  bottom: 38px;
  left: 16px;
  transform: translateY(8px);
  background: rgba(43,47,54,.85);
  color: #fff;
  font-size: 11px;
  padding: 5px 12px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: .2s;
  z-index: 6;
  white-space: nowrap;
  font-family: "IBM Plex Mono", monospace;
}
.hover-info.show {
  opacity: 1;
  transform: translateY(0);
}

/* ── Model-name title overlay (top-centre of viewer, set from Step 2) ─────── */
#viewer-model-title {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  font-family: "Archivo", sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(4px);
  padding: 5px 18px;
  border-radius: 6px;
  border: 1px solid var(--line);
  white-space: nowrap;
  display: none;
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}

/* ── Settings panel ─────────────────────────────────────────────────────────── */
#sow-settings-panel {
  position: absolute;
  top: 12px;
  right: 56px;
  width: 280px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  z-index: 50;
  display: none;
  font-family: "Hanken Grotesk", sans-serif;
  overflow: hidden;
}
#sow-settings-panel.show { display: block; }

.sow-set-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft, #f4f5f7);
}
.sow-set-title {
  font-family: "Archivo", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink);
}
.sow-set-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
}
.sow-set-close:hover { color: var(--ink); }

.sow-set-body { padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 14px; }

.sow-set-row { display: flex; flex-direction: column; gap: 5px; }
.sow-set-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sow-set-slider-row { display: flex; align-items: center; gap: 8px; }
.sow-set-slider {
  flex: 1;
  height: 4px;
  accent-color: var(--orange);
  cursor: pointer;
}
.sow-set-pct {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  min-width: 32px;
  text-align: right;
}
.sow-set-twin { display: flex; gap: 8px; }
.sow-set-twin-item { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.sow-set-sublabel { font-size: 10px; color: var(--ink-soft); }
.sow-set-num {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--font-entered) !important; /* beats forms.css's input[type=number] specificity */
  color: var(--ink);
  box-sizing: border-box;
}
.sow-set-num:focus { outline: none; border-color: var(--orange); }
.sow-set-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  box-sizing: border-box;
}
.sow-set-select:focus { outline: none; border-color: var(--orange); }
.sow-set-font-preview {
  font-size: 11px;
  color: var(--ink-soft);
  padding: 4px 0 0 2px;
  line-height: 1.4;
}

.sow-set-foot {
  display: flex;
  gap: 8px;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--line);
}
.sow-set-btn {
  flex: 1;
  padding: 7px 0;
  border-radius: 7px;
  font-family: var(--font-btn);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--bg-soft, #f4f5f7);
  color: var(--ink);
  transition: .12s;
}
.sow-set-btn:hover { background: var(--orange-soft); border-color: var(--orange); color: var(--orange); }
.sow-set-btn.primary { background: var(--orange); color: #fff; border-color: var(--orange); }
.sow-set-btn.primary:hover { background: var(--accent2, #c95e0a); border-color: var(--accent2, #c95e0a); }
