/* Atlas — embedding map (docs/specs/visualization-redesign.md).
   The canvas is intentionally dark in both themes, like a chart surface;
   chrome around it uses tokens. */

.atl-wrap {
  margin-bottom: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #05070c;
}
.atl-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: var(--space-2) var(--space-3);
  background: rgba(13, 17, 23, 0.92);
  border-bottom: 1px solid rgba(48, 54, 61, 0.6);
}
.atl-search {
  background: rgba(22, 27, 34, 0.9);
  border: 1px solid rgba(48, 54, 61, 0.8);
  border-radius: var(--radius-md);
  color: #f0f6fc;
  font-size: 12px;
  padding: 6px 10px;
  width: 220px;
  outline: none;
  font-family: inherit;
}
.atl-search:focus { border-color: var(--accent); }
.atl-select {
  background: rgba(22, 27, 34, 0.9);
  border: 1px solid rgba(48, 54, 61, 0.8);
  border-radius: var(--radius-md);
  color: #c9d1d9;
  font-size: 12px;
  padding: 6px 8px;
  font-family: inherit;
  cursor: pointer;
}
.atl-sep { flex: 0 0 1px; height: 18px; background: rgba(48, 54, 61, 0.8); margin: 0 4px; }
.atl-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(48, 54, 61, 0.8);
  background: rgba(22, 27, 34, 0.7);
  color: #8b949e;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.atl-chip.atl-on { color: #f0f6fc; border-color: rgba(139, 148, 158, 0.6); }
.atl-chip:not(.atl-on) .atl-dot { opacity: 0.3; }
.atl-chip.atl-cta { color: var(--accent); border-color: rgba(232, 168, 48, 0.5); background: rgba(232, 168, 48, 0.08); }
.atl-chip[disabled] { opacity: 0.6; cursor: wait; }
.atl-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.atl-canvas-area { position: relative; height: 620px; }
.atl-canvas { display: block; cursor: grab; }
.atl-canvas:active { cursor: grabbing; }

.atl-tooltip {
  position: absolute;
  max-width: 270px;
  background: rgba(13, 17, 23, 0.95);
  border: 1px solid rgba(48, 54, 61, 0.9);
  border-radius: var(--radius-md);
  color: #c9d1d9;
  font-size: 12px;
  line-height: 1.4;
  padding: 7px 10px;
  pointer-events: none;
  z-index: 5;
}
.atl-tooltip b { color: var(--accent); font-weight: 600; margin-right: 4px; }

.atl-legend {
  position: absolute;
  left: 12px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: #8b949e;
  background: rgba(5, 7, 12, 0.7);
  border-radius: var(--radius-md);
  padding: 5px 10px;
  z-index: 4;
}
.atl-legend-item { display: inline-flex; align-items: center; gap: 5px; }
.atl-ramp {
  width: 110px; height: 8px; border-radius: var(--radius-full);
  background: linear-gradient(90deg, #1b0c41, #781c6d, #cf4446, #fb9b06, #f7d03c);
}

.atl-hint {
  position: absolute;
  right: 12px;
  bottom: 10px;
  font-size: 10px;
  color: rgba(139, 148, 158, 0.7);
  z-index: 4;
}

.atl-inspector {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 300px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  background: rgba(13, 17, 23, 0.96);
  border: 1px solid rgba(48, 54, 61, 0.9);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  z-index: 6;
  color: #c9d1d9;
}
.atl-inspector-close {
  position: absolute; top: 8px; right: 10px;
  background: none; border: none; color: #8b949e;
  font-size: 18px; cursor: pointer; font-family: inherit;
}
.atl-inspector-kind { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.atl-inspector-title { font-family: 'Garet', sans-serif; font-weight: 800; font-size: 14px; color: #f0f6fc; margin: 6px 0 4px; line-height: 1.35; }
.atl-inspector-meta { font-size: 12px; color: #8b949e; margin-bottom: 8px; }
.atl-inspector-link { font-size: 12px; color: var(--accent); text-decoration: none; }
.atl-inspector-nn-head { font-size: 11px; font-weight: 700; color: #8b949e; text-transform: uppercase; letter-spacing: 0.6px; margin: 14px 0 6px; }
.atl-nn {
  display: grid;
  grid-template-columns: 38px 86px 1fr;
  gap: 6px;
  align-items: baseline;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-top: 1px solid rgba(48, 54, 61, 0.5);
  padding: 7px 2px;
  cursor: pointer;
  font-family: inherit;
}
.atl-nn:hover { background: rgba(22, 27, 34, 0.8); }
.atl-nn-sim { color: var(--accent); font-size: 11px; font-weight: 700; }
.atl-nn-kind { color: #8b949e; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.atl-nn-label { color: #c9d1d9; font-size: 11px; line-height: 1.35; }

/* Banner shown on old analyses that predate the Atlas */
.atl-upgrade-note {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(232, 168, 48, 0.07);
  border: 1px solid rgba(232, 168, 48, 0.35);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin-bottom: var(--space-3);
}

@media (max-width: 900px) {
  .atl-canvas-area { height: 460px; }
  .atl-inspector { width: min(300px, 80%); }
  .atl-search { width: 150px; }
}

/* ── v2: 3D view ── */
.atl-gl { display: block; cursor: grab; }
.atl-gl:active { cursor: grabbing; }
.atl-labels { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.atl-3dlabel {
  position: absolute;
  top: 0; left: 0;
  width: 140px;
  text-align: center;
  font-family: 'Garet', sans-serif;
  font-weight: 800;
  font-size: 12px;
  color: rgba(240, 246, 252, 0.92);
  text-shadow: 0 0 6px rgba(5, 7, 12, 0.95), 0 0 2px rgba(5, 7, 12, 1);
  will-change: transform;
}
.atl-inspector-snippet {
  font-size: 11px;
  color: #8b949e;
  line-height: 1.5;
  margin: 6px 0 8px;
  border-left: 2px solid rgba(232, 168, 48, 0.4);
  padding-left: 8px;
}

/* Tracked-topic labels: the evaluation framework, shown as amber region
   markers in space (distinct from incidental medoid labels). */
.atl-3dlabel-topic {
  color: var(--accent);
  letter-spacing: 0.4px;
  text-shadow: 0 0 8px rgba(5, 7, 12, 0.98), 0 0 14px rgba(232, 168, 48, 0.35);
}

/* ── Phase 2: opportunity layer ── */

/* Caption — one-line, data-grounded readout under the toolbar */
.atl-caption {
  padding: 8px var(--space-3);
  font-size: 12px;
  line-height: 1.45;
  color: #c9d1d9;
  background: rgba(13, 17, 23, 0.85);
  border-bottom: 1px solid rgba(48, 54, 61, 0.45);
}

/* Opportunity-zone 3D labels — amber ▲ priority markers */
.atl-3dlabel-zone {
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.3px;
  opacity: 0.92;
  text-shadow: 0 0 8px rgba(5, 7, 12, 0.98), 0 0 12px rgba(232, 168, 48, 0.4);
}

/* Lasso overlay — captures pointer only when active (JS toggles pointer-events) */
.atl-lasso {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
}
.atl-lasso polygon {
  fill: rgba(232, 168, 48, 0.10);
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}
.atl-canvas-area.atl-lassoing { cursor: crosshair; }
.atl-canvas-area.atl-lassoing .atl-gl,
.atl-canvas-area.atl-lassoing .atl-canvas { cursor: crosshair; }

/* Selection / zone panel — mirrors the inspector, pinned top-left */
.atl-selection {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 300px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  background: rgba(13, 17, 23, 0.96);
  border: 1px solid rgba(232, 168, 48, 0.45);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  z-index: 6;
  color: #c9d1d9;
}
.atl-sel-summary { font-size: 13px; color: #f0f6fc; margin: 6px 0 8px; font-weight: 600; }
.atl-sel-list { font-size: 12px; color: #c9d1d9; line-height: 1.6; margin-bottom: 10px; }
.atl-sel-list div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.atl-zone-comps { font-size: 11px; color: #8b949e; margin: 4px 0 10px; }
.atl-sel-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.atl-brief-out { margin-top: 12px; border-top: 1px solid rgba(48, 54, 61, 0.5); padding-top: 10px; }
.atl-brief-head { font-family: 'Garet', sans-serif; font-weight: 800; font-size: 13px; color: var(--accent); line-height: 1.35; margin-bottom: 8px; }
.atl-brief-bullets { margin: 0; padding-left: 16px; }
.atl-brief-bullets li { font-size: 12px; color: #c9d1d9; line-height: 1.5; margin-bottom: 6px; }

/* Encroachment — which rivals sit in your opportunity zones */
.atl-encroach {
  position: absolute;
  left: 12px;
  bottom: 44px;
  width: 230px;
  background: rgba(5, 7, 12, 0.78);
  border: 1px solid rgba(48, 54, 61, 0.7);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  z-index: 4;
}
.atl-encroach-head { font-size: 10px; letter-spacing: 0.6px; text-transform: uppercase; color: #8b949e; font-weight: 700; margin-bottom: 6px; }
.atl-encroach-head span { cursor: help; opacity: 0.7; }
.atl-encroach-row { display: grid; grid-template-columns: 10px 1fr 60px 24px; gap: 6px; align-items: center; margin-bottom: 4px; }
.atl-encroach-name { font-size: 11px; color: #c9d1d9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.atl-encroach-bar { height: 6px; border-radius: var(--radius-full); background: rgba(48, 54, 61, 0.7); overflow: hidden; }
.atl-encroach-bar span { display: block; height: 100%; border-radius: var(--radius-full); }
.atl-encroach-z { font-size: 10px; color: #8b949e; text-align: right; }

@media (max-width: 900px) {
  .atl-selection { width: min(300px, 80%); }
  .atl-encroach { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .atl-3dlabel-zone { text-shadow: 0 0 6px rgba(5, 7, 12, 0.98); }
}
