/* =============================================================================
   joints.css  —  Endeavos Online SOW
   Joint & Contact assignment dialog, legend overlay, and tag sprites.
============================================================================= */

/* ── Checkbox-style radio row / 2×2 grid ────────────────────────────────── */
.jnt-chk-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}
.jnt-chk-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 0;
  padding: 2px 8px;
}
/* Wrapper for a model/type selector row (radios or a 2×2 grid) plus its help
   icon, positioned at the row's top-right corner rather than on the shared
   Joint Type label, since the guidance is specific to that joint type. Reused
   by Bolted (model/size grid) and Adhesive Bonded (Bonded/CZM radio row). */
.jnt-model-row { position: relative; }
.jnt-model-row .jnt-info-icon {
  position: absolute;
  right: 4px;
  top: 2px;
}
.jnt-chk-lbl {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--t-label);
  font-weight: var(--w-option);
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}
.jnt-chk-lbl input[type="radio"],
/* Size/shape come from the app-wide checkbox standard in base.css. */
.jnt-chk-lbl input[type="checkbox"] { cursor: pointer; }

/* ── Joint dialog (right side of viewer) ────────────────────────────────── */
/* Standard vertical gap between distinct groups/sections inside any Step-3
   joint dialog — the single source of truth so every gap in the dialog
   (dropdown↔radios, radios↔size row, size row↔preload, block↔divider,
   divider↔block, textarea-group↔checkbox, checkbox↔buttons) matches. */
#jnt-dialog {
  --jnt-gap: 16px;
  position: absolute;
  top: 50%; right: 230px;
  transform: translateY(-50%);
  background: #fff;
  border: 1.5px solid rgba(232,116,30,0.4);
  border-radius: 12px;
  padding: 18px;
  width: 310px;
  z-index: 25;
  display: none;
  flex-direction: column;
  gap: var(--jnt-gap);
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  overflow: visible;
  box-sizing: border-box;
  font-family: var(--font-label);
}
#jnt-dialog.show { display: flex; }

.jnt-dlg-hint {
  font-family: var(--font-hint);
  font-size: var(--t-hint);
  color: var(--ink-soft);
  font-style: italic;
  line-height: 1.5;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  margin-bottom: 2px;
}

/* Small inline help icon — keeps the dialog minimalist by hiding longer
   guidance (which may grow over time) behind a hover tooltip instead of
   always-visible text. Tooltip wraps (unlike the toolbar's nowrap tips)
   since this content can run to a full sentence or more. */
.jnt-info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 5px;
  border-radius: 50%;
  border: 1.3px solid var(--ink-soft);
  color: var(--ink-soft);
  font-size: 9.5px;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, serif;
  cursor: help;
  position: relative;
  vertical-align: middle;
}
.jnt-info-icon:hover {
  border-color: var(--orange);
  color: var(--orange);
}
.jnt-info-icon[data-tip]::before {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: rgba(43,47,54,.94);
  color: #fff;
  font-size: 11px;
  font-weight: 400;
  font-style: normal;
  font-family: var(--font-label);
  line-height: 1.45;
  padding: 8px 10px;
  border-radius: 6px;
  white-space: normal;
  width: 210px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 9999;
}
.jnt-info-icon[data-tip]::after {
  content: '';
  position: absolute;
  top: calc(100% + 3px);
  right: 5px;
  border: 5px solid transparent;
  border-bottom-color: rgba(43,47,54,.94);
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 9999;
}
.jnt-info-icon[data-tip]:hover::before,
.jnt-info-icon[data-tip]:hover::after { opacity: 1; }

.jnt-dlg-label {
  font-size: var(--t-label);
  font-weight: var(--w-label);
  color: var(--ink);
  margin-bottom: 5px;
}

.jnt-dlg-select {
  width: 100%;
  border: 1.5px solid var(--line-strong);
  border-radius: 8px;
  padding: 9px 11px;
  font-family: var(--font-label);
  font-size: var(--t-label);
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235b626c' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
  outline: none;
  transition: border-color .15s;
}
.jnt-dlg-select:focus { border-color: var(--orange); }

.jnt-dlg-input {
  width: 100%;
  border: 1.5px solid var(--line-strong);
  border-radius: 8px;
  padding: 9px 11px;
  font-family: var(--font-entered) !important;
  font-size: var(--t-label) !important;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color .15s;
}
.jnt-dlg-input:focus { border-color: var(--orange); }
.jnt-dlg-input::placeholder { color: var(--c-muted); font-style: italic; font-weight: var(--w-body); font-size: var(--t-body); }
.jnt-dlg-input:focus::placeholder { color: var(--c-muted); font-style: italic; font-weight: var(--w-body); font-size: var(--t-body); }

.jnt-field-group {
  display: flex;
  flex-direction: column;
  gap: var(--jnt-gap, 16px);
}

/* ── Segmented radio buttons ─────────────────────────────────────────────── */
.jnt-radio-row {
  display: flex;
  gap: 6px;
}
.jnt-radio-btn {
  flex: 1;
  padding: 7px 6px;
  border: 1.5px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  font-family: "Archivo", sans-serif;
  font-weight: var(--w-option);
  font-size: var(--t-label);
  color: var(--ink-soft);
  cursor: pointer;
  text-align: center;
  transition: .15s;
  user-select: none;
}
.jnt-radio-btn:hover { border-color: var(--orange); color: var(--orange); }
.jnt-radio-btn.active {
  background: rgba(232,116,30,0.1);
  border-color: var(--orange);
  color: var(--orange);
}

/* ── Input with unit tag ──────────────────────────────────────────────────── */
.jnt-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.jnt-input-lbl {
  font-size: var(--t-label);
  font-weight: var(--w-label);
  color: var(--ink);
}
.jnt-input-with-unit {
  display: flex;
  align-items: center;
}
.jnt-input-with-unit input {
  flex: 1;
  border: 1.5px solid var(--line-strong);
  border-right: none;
  border-radius: 8px 0 0 8px;
  padding: 9px 11px;
  font-family: var(--font-entered);
  font-size: var(--t-label);
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color .15s;
}
.jnt-input-with-unit input:focus { border-color: var(--orange); }
.jnt-unit-tag {
  padding: 9px 10px;
  background: var(--bg);
  border: 1.5px solid var(--line-strong);
  border-radius: 0 8px 8px 0;
  font-size: var(--t-label);
  color: var(--ink-soft);
  font-family: var(--font-label);
  white-space: nowrap;
}

/* ── Two-column sub-grid ─────────────────────────────────────────────────── */
.jnt-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ── Preload row (label left, input right, same line) ────────────────────── */
.jnt-preload-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  overflow: hidden;
}
.jnt-preload-row .jnt-input-lbl {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
  white-space: normal;
  word-break: break-word;
  padding-top: 2px;
}
.jnt-input-sm {
  width: 110px;
  flex-shrink: 0;
  border: 1.5px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 9px;
  font-family: inherit;
  font-size: var(--t-label);
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color .15s;
}
.jnt-input-sm:focus { border-color: var(--orange); }

/* ── Optional section ────────────────────────────────────────────────────── */
.jnt-optional-section {
  display: flex;
  flex-direction: column;
  gap: var(--jnt-gap, 16px);
}
.jnt-optional-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: var(--t-body);
}
.jnt-optional-divider::before,
.jnt-optional-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}
.jnt-dlg-textarea {
  width: 100%;
  border: 1.5px solid var(--line-strong);
  border-radius: 8px;
  padding: 11px 13px;
  font-family: var(--font-entered);
  font-size: var(--t-body);
  color: var(--ink);
  background: #fff;
  resize: vertical;
  min-height: 58px;
  outline: none;
  transition: border-color .15s;
  box-sizing: border-box;
}
.jnt-dlg-textarea:focus { border-color: var(--orange); }
.jnt-dlg-textarea::placeholder { color: var(--c-muted); font-style: italic; font-weight: var(--w-body); font-size: var(--t-body); }
.jnt-dlg-textarea:focus::placeholder { color: var(--c-muted); font-style: italic; font-weight: var(--w-body); font-size: var(--t-body); }
.jnt-file-label {
  display: flex;
  align-items: center;
  width: 100%;
  border: 1.5px dashed var(--line-strong);
  border-radius: 8px;
  padding: 9px 14px;
  font-size: var(--t-body);
  color: var(--ink-soft);
  font-style: normal;
  cursor: pointer;
  transition: border-color .15s;
  box-sizing: border-box;
  gap: 6px;
}
.jnt-file-label:hover { border-color: var(--orange); color: var(--orange); }

/* ── Save / Cancel buttons ────────────────────────────────────────────────── */
.jnt-dlg-btns { display: flex; gap: 8px; justify-content: center; }
.jnt-btn-save {
  padding: 0 18px;
  height: 32px;
  min-width: 80px;
  background: var(--orange); border: none;
  border-radius: 7px; color: #fff;
  font-family: var(--font-btn); font-weight: var(--w-option); font-size: var(--t-label);
  cursor: pointer; box-sizing: border-box;
  transition: background .15s;
}
.jnt-btn-save:hover { background: var(--accent2); }
.jnt-btn-cancel {
  padding: 0 18px;
  height: 32px;
  min-width: 80px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px; color: var(--ink);
  font-family: var(--font-btn); font-weight: var(--w-option); font-size: var(--t-label);
  cursor: pointer; box-sizing: border-box;
}
.jnt-btn-cancel:hover { border-color: var(--ink-soft); }

/* ── Joint legend overlay ─────────────────────────────────────────────────── */
#jnt-legend {
  position: absolute;
  top: 12px; left: 248px;
  z-index: 8;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(232,116,30,0.25);
  border-radius: 10px;
  padding: 10px 18px 14px;
  display: none;
  min-width: 240px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.10);
  pointer-events: none;
}
#jnt-legend.show { display: block; }

.jnt-leg-title {
  font-size: var(--t-body);
  font-weight: var(--w-label);
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(232,116,30,0.2);
  font-family: "Archivo", sans-serif;
}

/* ── Joint tag sprites (floating labels on the 3D model) ─────────────────── */
.jnt-sprite {
  position: absolute;
  pointer-events: none;
  z-index: 7;
}
.jnt-bubble {
  background: #ffffff;
  color: #1a1a1a;
  border: 2px solid #2b2f36;
  font-size: var(--t-label);
  font-weight: var(--w-option);
  padding: 7px 12px 8px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
  cursor: grab;
  pointer-events: all;
  user-select: none;
  font-family: var(--font-ui);
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
  transition: box-shadow .15s;
  width: max-content;
  min-width: var(--bubble-min-w, 250px);
  max-width: var(--bubble-max-w, 440px);
}
.jnt-bubble:hover { box-shadow: 0 3px 14px rgba(43,47,54,.35); }
.jnt-bubble:active { cursor: grabbing; }
/* Title line: swatch + joint text, drives bubble width */
.jnt-bubble-title { font-weight: var(--w-label); font-size: var(--t-label); white-space: normal; overflow-wrap: anywhere; display: flex; align-items: center; gap: 6px; }
/* Colored swatch with thin black outline */
.jnt-bubble-swatch { display: inline-block; width: 11px; height: 11px; border-radius: 2px; border: 1px solid rgba(0,0,0,0.3); flex-shrink: 0; }
/* Note: contributes to the bubble's auto-width (along with the title), wraps naturally */
.jnt-bubble-note { font-weight: var(--w-body); font-size: var(--t-body); opacity: 0.9; white-space: normal; box-sizing: border-box; }
/* Upload line */
.jnt-bubble-upload { font-weight: var(--w-body); font-size: var(--t-body); opacity: 0.9; white-space: nowrap; }
/* Dotted separator */
.jnt-bubble-sep { width: 100%; height: 0; border-top: 1.5px dotted rgba(43,47,54,0.45); margin: 4px 0; }

.jnt-edit-btn {
  position: absolute;
  top: -9px; right: -9px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid var(--orange);
  color: var(--orange);
  font-size: var(--t-arrow);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: all;
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.jnt-sprite:hover .jnt-edit-btn { display: flex; }

.jnt-delete-btn {
  position: absolute;
  top: -9px; left: -9px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid var(--danger);
  color: var(--danger);
  font-size: var(--t-body);
  font-weight: var(--w-label);
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: all;
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
  transition: background .12s, color .12s;
}
.jnt-delete-btn:hover { background: var(--danger); color: #fff; }
.jnt-sprite:hover .jnt-delete-btn { display: flex; }
