/* X-ray mode — visible only when body.xray-mode is set. */

/* Floating toggle button — always visible so the feature is discoverable. */
#xray-fab {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 9000;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid #d4d4d8;
  background: #ffffff;
  color: #18181b;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
#xray-fab:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
#xray-fab.active {
  background: #ec4899;
  border-color: #db2777;
  color: #ffffff;
  box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.25), 0 4px 14px rgba(236, 72, 153, 0.35);
}

/* (Floating WHIP footer removed — credit lives inline in
   .disclaimer-banner now. See app.js renderAppSkeleton.) */

/* Highlight every tagged figure when x-ray is on. */
body.xray-mode [data-fig-id] {
  outline: 1px dashed #ec4899;
  outline-offset: 2px;
  cursor: help;
  border-radius: 2px;
  transition: outline-color 0.1s ease, background 0.1s ease;
}
body.xray-mode [data-fig-id]:hover {
  outline: 2px solid #ec4899;
  background: rgba(236, 72, 153, 0.06);
}

/* Suppress link-like hover styles on x-ray-clicked elements. */
body.xray-mode [data-fig-id] {
  position: relative;
}

/* The hover tooltip. Lives at body root, positioned by JS. */
#xray-tooltip {
  position: absolute;
  z-index: 9100;
  width: 320px;
  max-width: calc(100vw - 16px);
  padding: 0;
  border-radius: 8px;
  background: #18181b;
  color: #fafafa;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.45;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  pointer-events: none;  /* tooltip itself never captures hover */
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
#xray-tooltip.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.xray-tip-header {
  padding: 8px 12px;
  background: #ec4899;
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: 8px 8px 0 0;
  text-transform: uppercase;
  font-size: 10.5px;
}
.xray-tip-header.xray-tip-warn { background: #f59e0b; }
.xray-tip-body { padding: 10px 12px; }
.xray-tip-formula {
  background: #27272a;
  padding: 6px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
  color: #fde68a;
  white-space: pre-wrap;
  word-break: break-word;
}
.xray-tip-inputs > div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
  border-bottom: 1px dotted #3f3f46;
}
.xray-tip-inputs > div:last-child { border-bottom: 0; }
.xray-tip-inputs span { color: #a1a1aa; }
.xray-tip-inputs code { color: #e4e4e7; }
.xray-tip-more {
  margin-top: 6px;
  font-style: italic;
  color: #a1a1aa;
}
.xray-tip-footer {
  padding: 8px 12px;
  background: #27272a;
  border-radius: 0 0 8px 8px;
  color: #a1a1aa;
  font-size: 10.5px;
}
.xray-tip-footer code { color: #e4e4e7; }

/* The click-to-inspect modal. */
#xray-modal {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: none;
}
#xray-modal.open { display: block; }
.xray-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 15, 20, 0.55);
  backdrop-filter: blur(2px);
}
.xray-modal-card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(640px, 92vw);
  max-height: 84vh;
  overflow: auto;
  background: #ffffff;
  color: #18181b;
  border-radius: 10px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.xray-modal-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: #18181b;
  color: #fafafa;
  border-radius: 10px 10px 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.xray-modal-title {
  flex: 1;
  word-break: break-all;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.xray-modal-close {
  background: transparent;
  border: 0;
  color: #fafafa;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
}
.xray-modal-close:hover { color: #ec4899; }
.xray-modal-body {
  padding: 16px 20px 20px 20px;
  font-size: 13px;
}
.xray-modal-body h4 {
  margin: 0 0 6px 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #71717a;
}
.xray-section { margin-top: 16px; }
.xray-section:first-child { margin-top: 0; }
.xray-section-meta { color: #71717a; font-size: 11.5px; }
.xray-formula {
  background: #f4f4f5;
  padding: 8px 10px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #18181b;
  white-space: pre-wrap;
  word-break: break-word;
}
.xray-notes {
  margin-top: 6px;
  font-size: 12px;
  color: #52525b;
  font-style: italic;
}
.xray-table {
  width: 100%;
  border-collapse: collapse;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.xray-table th, .xray-table td {
  padding: 4px 8px;
  border-bottom: 1px solid #f4f4f5;
  text-align: left;
}
.xray-table th { color: #71717a; font-weight: 500; width: 40%; }
.xray-table td { color: #18181b; word-break: break-word; }
/* Compact matrix grid for spec MC inputs (mu/sigma vectors, rho 10×10
   correlation). Rendered inside an inputs-table cell when the value
   is a number array or array-of-arrays of length 10. The diagonal
   highlight on the rho matrix makes the symmetry visually obvious. */
.xray-matrix {
  border-collapse: collapse;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  margin: 4px 0;
}
.xray-matrix .xray-mat-h {
  color: #71717a;
  font-weight: 600;
  padding: 2px 4px;
  text-align: center;
  border: 1px solid #e4e4e7;
  background: #fafafa;
}
.xray-matrix .xray-mat-c {
  color: #18181b;
  padding: 2px 5px;
  text-align: right;
  border: 1px solid #f4f4f5;
  font-variant-numeric: tabular-nums;
}
.xray-matrix .xray-mat-diag {
  background: #fef3c7;
  font-weight: 600;
}
.xray-table-nested { width: auto; }
.xray-table-nested th, .xray-table-nested td { padding: 2px 6px; font-size: 11px; }
.xray-upstream { margin: 0; padding-left: 18px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.xray-upstream li { margin-bottom: 4px; }
.xray-upstream a {
  color: #ec4899;
  text-decoration: none;
  border-bottom: 1px dashed #ec4899;
}
.xray-upstream a:hover { color: #be185d; }
.xray-tip-source { color: #71717a; font-size: 11px; margin-left: 4px; }
.xray-warn {
  padding: 10px 12px;
  border-left: 3px solid #f59e0b;
  background: #fef3c7;
  border-radius: 0 4px 4px 0;
  color: #78350f;
  font-size: 13px;
}

/* MODES-10 — rule-citation spans (server-rendered by rule_handles.py).
   Always visible (subtle underline + cursor) so the user can click
   them to inspect the source. The magenta x-ray treatment kicks in
   when body.xray-mode is set, mirroring the [data-fig-id] pattern. */
.rule-citation {
  border-bottom: 1px dotted #6366f1;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.rule-citation:hover { background: rgba(99, 102, 241, 0.08); }
body.xray-mode .rule-citation {
  outline: 1px dashed #6366f1;
  outline-offset: 2px;
  border-radius: 2px;
}
body.xray-mode .rule-citation:hover {
  outline: 2px solid #6366f1;
  background: rgba(99, 102, 241, 0.10);
}

/* Tooltip header tint when hovering a rule-citation span — distinguishes
   it from the figure-handle hover (which uses the magenta header). */
.xray-tip-header.xray-tip-rule { background: #6366f1; }

/* XRAY-MAX — permanent subtle corner marker on bubbles carrying
   data-mode-trace. Visible WITHOUT x-ray mode toggled on, so the
   user has a hint that "this bubble has more info — open X-ray".
   No click handler on the dot itself (the existing click-anywhere-on-
   the-bubble pattern still owns interaction). Color matches the
   mode-pill color: amber for TS, blue for Advice. */
[data-mode-trace] {
  position: relative;
}
[data-mode-trace]::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f59e0b;       /* TS — amber, matches mode-pill */
  opacity: 0.55;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.6);
}
[data-mode-trace="advice"]::after {
  background: #ec4899;        /* Advice — pink, matches mode pill */
}
body.xray-mode [data-mode-trace]::after {
  opacity: 1;
}

/* XRAY-MERGE — mode-trace zones on user-message bubbles + assistant
   reply lead sentences. Same visual affordance as figure spans:
   subtle underline in x-ray mode, magenta tint on hover. */
body.xray-mode .xray-zone-user,
body.xray-mode [data-mode-trace] {
  border-bottom: 1px dashed #ec4899;
  cursor: help;
}
body.xray-mode .xray-zone-user:hover,
body.xray-mode [data-mode-trace]:hover {
  background: rgba(236, 72, 153, 0.10);
  outline: 1px solid #ec4899;
}
.xray-tip-header.xray-tip-mode { background: #ec4899; }

/* XRAY-MERGE — stub.* fig spans render with placeholder text inline
   (e.g. "[monthly savings pct]"). Faint dotted border + muted tone so
   the user reads it as a placeholder, not a real value. */
.xray-stub {
  font-style: italic;
  color: #6b7280;
  border-bottom: 1px dotted #9ca3af;
  cursor: help;
}
body.xray-mode .xray-stub {
  background: rgba(156, 163, 175, 0.12);
  border-bottom-color: #6366f1;
  border-bottom-style: dashed;
}
.xray-tip-header.xray-tip-stub { background: #6b7280; }
.xray-stub-block {
  border-left: 3px solid #6b7280;
  background: #f9fafb;
  padding-left: 12px;
  border-radius: 0 4px 4px 0;
  padding-top: 8px;
  padding-bottom: 8px;
}

/* MODES-10 — modal blocks for MODE / SEGMENT / ADVICE TRIGGER context. */
.xray-mode-block, .xray-segment-block, .xray-advice-trigger-block,
.xray-rule-citation-block {
  border-left: 3px solid #6366f1;
  padding-left: 12px;
  background: #f5f7ff;
  border-radius: 0 4px 4px 0;
  padding-top: 8px;
  padding-bottom: 8px;
}
.xray-mode-block        { border-left-color: #ec4899; background: #fdf2f8; }
.xray-segment-block     { border-left-color: #10b981; background: #ecfdf5; }
.xray-advice-trigger-block { border-left-color: #f59e0b; background: #fffbeb; }
.xray-rule-citation-block  { border-left-color: #6366f1; background: #eef2ff; }
.xray-subhdr {
  margin: 10px 0 4px 0;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
}
.xray-pred-list {
  margin: 0;
  padding-left: 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: #374151;
}
.xray-pred-list li { margin-bottom: 2px; }
.xray-warn-inline { color: #b45309; margin-left: 4px; }
.xray-rule-link {
  color: #4338ca;
  text-decoration: underline;
  word-break: break-all;
}
.xray-rule-link:hover { color: #312e81; }
.xray-rule-adjacent {
  margin: 0;
  padding-left: 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
}
.xray-draft-pane {
  background: #ffffff;
  border: 1px solid #fde68a;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 12px;
  max-height: 280px;
  overflow-y: auto;
}
.xray-draft-section { margin-bottom: 10px; }
.xray-draft-section:last-child { margin-bottom: 0; }
.xray-draft-section h5 {
  margin: 0 0 4px 0;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #b45309;
}
.xray-draft-body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 12px;
  color: #374151;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Chat-side x-ray: tagged numbers in agent replies. Always wrapped in
   spans by xray.js' MutationObserver; only visually styled when x-ray
   is on. Tagged spans share the [data-fig-id] selector at the top of
   this file, so they pick up the magenta dashed outline + click target.
   Untagged numbers get a yellow underline so the user can see what's
   not yet covered. */
.xray-chat-figure {
  font-weight: 600;
}
.xray-chat-untagged {
  font-style: italic;
}
body.xray-mode .xray-chat-untagged {
  background: linear-gradient(transparent 60%, rgba(245, 158, 11, 0.4) 60%);
  cursor: help;
}
