/* components.css — map, tabs, panels, and the agent / memory / timeline /
   relationship / metrics / probe / network / params widgets (dark theme). */

/* ---- Status pill ---- */
.status-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 650;
  font-size: 0.85rem;
  border: 1px solid var(--line-strong);
}
.status-pill[data-state="running"] {
  background: rgba(87, 201, 138, 0.16);
  color: var(--ok);
  border-color: rgba(87, 201, 138, 0.45);
}
.status-pill[data-state="paused"] { background: var(--panel-2); color: var(--muted); }
.status-pill[data-state="running"]::before { content: "● "; }
.status-pill[data-state="paused"]::before { content: "⏸ "; }
.time-indicator { font-family: var(--mono); font-weight: 650; font-size: 1rem; color: var(--ink); }

/* ---- Map: fills the viewport, framed by a soft glow over the starfield ----
   The host is the camera viewport, so it must FILL the stage area (not shrink
   to the baked art). The canvas inside then fills the host. */
.map-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: var(--space-4);
}
.map-host {
  position: relative;
  display: block;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  line-height: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #84b95a;
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 18px 60px rgba(0, 0, 0, 0.5),
    0 0 70px rgba(120, 180, 110, 0.18);
}
/* Loading placeholder text (shown briefly before the view mounts) */
.map-host[aria-busy="true"] {
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.85);
  font: 600 0.9rem/1.4 var(--mono, monospace);
  line-height: 1.4;
}
.map-host canvas,
.map-canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  cursor: grab; /* draggable map; the Camera swaps to grabbing/default at runtime */
}
.map-overlay {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

/* ---- Zoom buttons: compact, square, monospaced glyphs ---- */
.btn--zoom {
  min-width: 2.1rem;
  padding-left: 0;
  padding-right: 0;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1;
  text-align: center;
}

/* Floating "INITIALS: emoji" bubbles (canvas fallback) */
.speech-bubble {
  position: absolute;
  transform: translate(-50%, -100%);
  background: #ffffff;
  border: 2px solid #2a2333;
  border-radius: 9px;
  padding: 1px 7px;
  font: 700 11px/1.35 var(--mono);
  letter-spacing: 0.02em;
  color: #1e2330;
  white-space: nowrap;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.speech-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #2a2333;
}
.speech-bubble--talking { background: #fff6e2; }
.speech-bubble--selected {
  border-color: #b8770a;
  box-shadow: 0 0 0 2px #ffd23f, 0 2px 0 rgba(0, 0, 0, 0.35);
  z-index: 3;
}

/* ---- Floating legend bar at the foot of the map ---- */
.map-legend {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  padding: 9px var(--space-4);
  background: rgba(8, 12, 22, 0.66);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(6px);
  /* 24 resident chips can overflow: cap the height and scroll vertically. */
  max-height: 22vh;
  overflow-y: auto;
}
.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px 3px 4px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.8rem;
}
.legend-chip:hover { border-color: var(--accent); }
.legend-chip--selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  font-weight: 650;
}
.legend-swatch {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  border: 1px solid rgba(0, 0, 0, 0.25);
}

/* ---- Tabs ---- */
.tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 2px;
  margin: var(--space-3) var(--space-4) 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
}
.tab {
  flex: 1;
  appearance: none;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 7px;
  padding: 7px 6px;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { background: var(--panel); color: var(--accent); }
.tabpanel { display: flex; flex-direction: column; gap: var(--space-4); outline: none; }
.tabpanel[hidden] { display: none; }

/* ---- Panels / cards ---- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-4);
}
.panel > h2 {
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: var(--space-3);
}
.panel--scroll .mem-list,
.panel--scroll .timeline-list { max-height: none; }

/* ---- Agent details ---- */
.details { margin: 0; display: grid; gap: var(--space-2); }
.detail-row { display: grid; grid-template-columns: 92px 1fr; gap: var(--space-3); align-items: start; }
.detail-row dt { color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; }
.detail-row dd { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: 999px; padding: 1px 9px; font-size: 0.8rem; }

/* ---- Plan ---- */
.plan-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.plan-item {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: var(--space-2);
  align-items: center;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
}
.plan-time { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.plan-activity { font-size: 0.88rem; }
.plan-status { font-size: 0.72rem; font-weight: 650; white-space: nowrap; }
.plan-item--active { border-left-color: var(--accent); background: rgba(244, 183, 64, 0.12); }
.plan-item--active .plan-status { color: var(--accent); }
.plan-item--completed { opacity: 0.55; border-left-color: var(--ok); }
.plan-item--completed .plan-status { color: var(--ok); }

/* ---- Relationships ---- */
.rel-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.rel-item { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); background: var(--panel-2); }
.rel-name { font-weight: 650; }
.rel-bar { margin-top: 6px; }
.rel-bar-label { display: flex; justify-content: space-between; font-size: 0.76rem; color: var(--muted); }
.rel-bar-value { font-family: var(--mono); color: var(--ink); }
.rel-bar-track { height: 7px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 2px; }
.rel-bar-fill { height: 100%; background: var(--accent); }
.rel-notes { margin: 6px 0 0; font-size: 0.8rem; }

/* ---- Memory + timeline lists ---- */
.mem-list, .timeline-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.mem-item, .tl-item {
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  background: var(--panel-2);
}
.mem-head, .tl-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: 3px; }
.mem-type, .tl-type {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 1px 7px; border-radius: 999px; color: #0a0e18;
}
.mem-time, .tl-time { font-family: var(--mono); font-size: 0.74rem; margin-left: auto; }
.mem-importance { font-size: 0.74rem; color: var(--c-action); font-weight: 650; }
.mem-desc, .tl-desc { margin: 0; font-size: 0.86rem; }
.tl-title { font-size: 0.86rem; font-weight: 600; }
.tl-loc { font-size: 0.76rem; margin-top: 2px; }

.mem-item--observation, .tl-item--observation { border-left-color: var(--c-observation); }
.mem-item--action { border-left-color: var(--c-action); }
.mem-item--conversation, .tl-item--conversation { border-left-color: var(--c-conversation); }
.mem-item--reflection, .tl-item--reflection { border-left-color: var(--c-reflection); }
.mem-item--event, .tl-item--event { border-left-color: var(--c-event); }
.mem-item--plan { border-left-color: var(--c-plan); }
.tl-item--movement { border-left-color: var(--c-movement); }

.mem-type--observation, .tl-type--observation { background: var(--c-observation); }
.mem-type--action { background: var(--c-action); }
.mem-type--conversation, .tl-type--conversation { background: var(--c-conversation); }
.mem-type--reflection, .tl-type--reflection { background: var(--c-reflection); }
.mem-type--event, .tl-type--event { background: var(--c-event); }
.mem-type--plan { background: var(--c-plan); }
.tl-type--movement { background: var(--c-movement); }

/* ---- Metrics dashboard ---- */
.metrics-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-2); }
.metric { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.metric__value { font-family: var(--mono); font-size: 1.3rem; font-weight: 700; color: var(--ink); line-height: 1.1; }
.metric__label { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 3px; }

/* ---- Retrieval probe ---- */
.probe__form { display: flex; gap: var(--space-2); margin-bottom: var(--space-3); }
.probe__input { flex: 1; }
.probe__hint { color: var(--muted); font-size: 0.85rem; }
.probe__results { display: flex; flex-direction: column; gap: 7px; list-style: none; margin: 0; padding: 0; }
.probe-item { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 7px 9px; background: var(--panel-2); }
.probe-item__desc { font-size: 0.85rem; }
.probe-item__meta { display: flex; align-items: center; gap: var(--space-2); margin-top: 4px; font-size: 0.72rem; color: var(--muted); }
.probe-score { font-family: var(--mono); color: var(--accent); font-weight: 700; }
.probe-bars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 5px; }
.probe-bar { font-size: 0.62rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.probe-bar__track { height: 5px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 2px; }
.probe-bar__fill { height: 100%; }
.probe-bar--recency .probe-bar__fill { background: var(--c-movement); }
.probe-bar--importance .probe-bar__fill { background: var(--c-action); }
.probe-bar--relevance .probe-bar__fill { background: var(--c-observation); }

/* ---- Relationship network ---- */
.network-canvas {
  display: block;
  width: 100%;
  height: auto;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.network__hint { color: var(--muted); font-size: 0.78rem; margin-top: var(--space-2); }

/* ---- Parameter (ablation) controls ---- */
.params { display: flex; flex-direction: column; gap: var(--space-3); }
.param__head { display: flex; justify-content: space-between; font-size: 0.8rem; }
.param__label { color: var(--muted); }
.param__val { font-family: var(--mono); color: var(--ink); }
.param input[type="range"] { width: 100%; accent-color: var(--accent); margin-top: 4px; }
.params__footer { margin-top: var(--space-2); }
.io-row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }

/* ---- Debug ---- */
.panel--debug .debug-content .detail-row { grid-template-columns: 110px 1fr; }
.debug-content dd { font-family: var(--mono); font-size: 0.82rem; word-break: break-word; }
