/* IP-098 — simulator explorer. Flat & sharp per IP-097: radius 0, shadow
   none, separation by 1px borders, tokens only. */

/* ------------------------------------------------------------ full-bleed shell */
body.full-bleed {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}
.full-bleed-main {
  flex: 1;
  min-height: 0;
  display: flex;
}

/* ------------------------------------------------------------ workbench grid */
.wb {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  min-height: 0;
  width: 100%;
  background: var(--bg);
}
.wb.wb-rail-closed { grid-template-columns: 0 1fr; }
.wb.wb-rail-closed .wb-rail { display: none; }

.wb-rail {
  border-right: 1px solid var(--ink-12);
  background: var(--surface);
  overflow-y: auto;
  min-height: 0;
}
.wb-rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--ink-12);
}
.wb-rail-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-60);
}
.wb-rail-table { width: 100%; }
.wb-rail-table td, .wb-rail-table th { padding: 0.45rem 0.9rem; }
.wb-rail-row { cursor: pointer; }
.wb-rail-row:hover { background: var(--primary-08); }
.wb-rail-row.is-active { background: var(--primary-light); }
.wb-rail-row .cell-title { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.wb-toggle {
  border: 1px solid var(--ink-12);
  background: var(--surface);
  color: var(--ink-60);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.2rem 0.55rem;
  cursor: pointer;
}
.wb-toggle:hover { background: var(--ink-06); color: var(--ink); }
.wb-rail-opener {
  position: absolute;
  left: 0;
  top: 50%;
  z-index: 500;
}
.wb-strip-toggle { position: absolute; top: 0.4rem; right: 0.4rem; }
.wb-strip-opener { position: absolute; bottom: 0.4rem; right: 0.4rem; z-index: 500; }

.wb-stage-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
}
.wb-stage {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--surface);
  display: flex;
  align-items: stretch;
  justify-content: center;
}

/* ------------------------------------------------------------ context strip */
.wb-strip {
  position: relative;
  border-top: 1px solid var(--ink-12);
  background: var(--surface-alt);
  max-height: 34dvh;
  overflow-y: auto;
  padding: 0.9rem 1.2rem;
}
.wb-strip-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.4rem;
}
.wb-strip-h {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-60);
  margin: 0 0 0.5rem;
}
.wb-strip-col + .wb-strip-col { border-left: 1px solid var(--ink-12); padding-left: 1.4rem; }
.wb-kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 0.9rem;
  margin: 0 0 0.8rem;
  font-size: 0.82rem;
}
.wb-kv dt { color: var(--ink-40); font-family: var(--font-mono); }
.wb-kv dd { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wb-metrics { font-size: 0.82rem; }
.wb-empty { align-self: center; }

/* ------------------------------------------------------------ stage viewers */
.stage-media {
  margin: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 1rem;
}
.stage-media img,
.stage-media video {
  max-width: 100%;
  max-height: calc(100% - 1.6rem);
  object-fit: contain;
  border: 1px solid var(--ink-12);
  background: white;
  cursor: zoom-in;
}
.stage-media img.zoomed {
  max-width: none;
  max-height: none;
  cursor: zoom-out;
}
.stage-media figcaption { margin-top: 0.5rem; font-size: 0.75rem; color: var(--ink-40); }

.stage-frame { flex: 1; display: flex; }
.stage-frame iframe { flex: 1; border: 0; width: 100%; height: 100%; background: white; }

.stage-replay { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.stage-replay .replay-map { flex: 1; min-height: 0; background: var(--bg-alt); }
.stage-replay .replay-loading,
.stage-replay .replay-missing { align-self: center; margin: auto; }
.replay-controls {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0.9rem;
  border-top: 1px solid var(--ink-12);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.replay-controls input[type="range"] { flex: 1; accent-color: var(--primary); }
.replay-controls .replay-time { min-width: 9ch; text-align: right; color: var(--ink-60); }
.replay-controls select { font-family: var(--font-mono); font-size: 0.78rem; }
.replay-controls label { display: flex; align-items: center; gap: 0.3rem; color: var(--ink-60); }

/* Legend — keys every map element; mirrors the floor_walk Plotly artefact. */
.replay-legend {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 500;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--ink-12);
  padding: 0.45rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--ink-60);
  max-width: 16rem;
  pointer-events: auto;
}
.replay-legend .lg-row { display: flex; align-items: center; gap: 0.4rem; }
.replay-legend .lg-sw { flex: 0 0 auto; width: 12px; height: 12px; display: inline-block; }
.replay-legend .lg-dot { border-radius: 50%; }
.replay-legend .lg-ring { border-radius: 50%; background: transparent; border: 2px solid; }
.replay-legend .lg-fill { border: 1px solid; }
.replay-legend .lg-line { height: 3px; width: 14px; }
.replay-legend .lg-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Agent hover read-out — id · group · subtype · x,y at the live frame. */
.replay-agent-tip {
  position: absolute;
  z-index: 600;
  pointer-events: none;
  background: var(--ink, #0F142F);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.35;
  padding: 0.3rem 0.45rem;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.leaflet-tooltip.replay-tip { font-family: var(--font-mono); font-size: 0.72rem; }

.stage-metrics, .stage-download, .stage-chart {
  flex: 1;
  padding: 1.6rem;
  max-width: 880px;
}
.stage-chart .simchart { width: 100%; min-height: 60dvh; border: 1px solid var(--ink-12); background: white; }

/* ------------------------------------------------------------ session / sweep pages */
.session-figures {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}
.session-figure { margin: 0; border: 1px solid var(--ink-12); background: white; padding: 0.6rem; }
.session-figure img { width: 100%; height: auto; display: block; }
.session-figure figcaption { margin-top: 0.4rem; font-size: 0.75rem; color: var(--ink-40); }

.simchart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 1rem;
}
.simchart-grid .simchart { min-height: 320px; border: 1px solid var(--ink-12); background: white; }

@media (max-width: 860px) {
  .wb { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .wb-rail { max-height: 28dvh; border-right: 0; border-bottom: 1px solid var(--ink-12); }
  .wb-strip-col + .wb-strip-col { border-left: 0; padding-left: 0; }
}
