/* nvp_viewport.css -- styling for the in-house CAD viewport renderers
 * (static/nvp_core.js, nvp_map.js, nvp_sequence.js, nvp_structure.js).
 *
 * Every colour, radius, spacing and font here resolves through the app's
 * existing --n-* / --mono design tokens (static/app.css, documented normatively
 * in UI_Overhaul_W0_Report.md). There are NO raw colour literals in this file
 * and no private copy of any token, so the viewport follows the theme -- light,
 * dark, and any future theme -- without a second definition to keep in sync.
 *
 * The one exception, stated deliberately: feature FILL colours are not tokens.
 * They come from the render model, which sources them from
 * engine/plasmid_map.COLORS -- a per-feature-type biology vocabulary shared
 * with the GenBank export, not a theme choice.
 */

/* ===================================================================== *
 * Shared chrome
 * ===================================================================== */
.nvp-empty,
.nvp-error {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  padding: 24px;
  text-align: center;
  color: var(--n-ink-3);
}
.nvp-empty-title,
.nvp-error-title {
  font-weight: 600;
  color: var(--n-ink-2);
}
.nvp-empty-detail,
.nvp-error-detail {
  max-width: 52ch;
  font-size: 12.5px;
  line-height: 1.5;
}
.nvp-error-title { color: var(--n-err); }
.nvp-retry { margin-top: 8px; }

/* Feature-colour swatch, reused by every legend and the track rail. */
.nvp-sw {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: -1px;
  border: 1px solid var(--n-line-2);
}

/* Shared hover tooltip. The single overlay node nvp_core.js owns. */
.nvp-tip {
  position: absolute;
  z-index: 9000;
  max-width: 320px;
  padding: 7px 9px;
  border: 1px solid var(--n-line-1);
  border-radius: 5px;
  background: var(--n-bg-1);
  color: var(--n-ink-1);
  box-shadow: var(--n-shadow-2);
  font-size: 11.5px;
  line-height: 1.45;
  pointer-events: none;
}

/* ===================================================================== *
 * Track rail: per-feature-type visibility + 3-state density
 * ===================================================================== */
.nvp-rail {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 172px;
  max-width: 210px;
  padding: 10px;
  border: 1px solid var(--n-line-2);
  border-radius: 6px;
  background: var(--n-bg-2);
  font-size: 12px;
}
.nvp-rail-label {
  display: block;
  margin-bottom: 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--n-ink-3);
}
.nvp-rail-dens { display: block; }
.nvp-dens-btn {
  padding: 3px 7px;
  border: 1px solid var(--n-line-1);
  background: var(--n-bg-1);
  color: var(--n-ink-2);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.nvp-dens-btn:first-of-type { border-radius: 4px 0 0 4px; }
.nvp-dens-btn:last-of-type { border-radius: 0 4px 4px 0; }
.nvp-dens-btn + .nvp-dens-btn { border-left: none; }
.nvp-dens-btn.active {
  background: var(--n-accent);
  border-color: var(--n-accent);
  color: var(--n-on-accent);
}
.nvp-dens-btn:focus-visible { outline: 2px solid var(--n-focus-ring); outline-offset: 1px; }

.nvp-rail-types { display: flex; flex-direction: column; gap: 2px; }
.nvp-rail-type {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 3px;
  border-radius: 3px;
  cursor: pointer;
}
.nvp-rail-type:hover { background: var(--n-bg-3); }
.nvp-rail-name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nvp-rail-count {
  font-variant-numeric: tabular-nums;
  font-size: 10.5px;
  color: var(--n-ink-3);
}
.nvp-rail-none { color: var(--n-ink-3); font-size: 11.5px; }

/* ===================================================================== *
 * Map view (circular + linear)
 * ===================================================================== */
.nvp-map-host { display: block; width: 100%; }
.nvp-map-wrap { display: flex; gap: 12px; align-items: flex-start; }
.nvp-map-rail-holder { flex: 0 0 auto; }
.nvp-map-main { flex: 1 1 auto; min-width: 0; }

.nvp-map-info {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--n-ink-2);
}
.nvp-info-line { flex: 1 1 260px; min-width: 0; }
.nvp-map-tools { display: flex; gap: 4px; flex: 0 0 auto; }
.nvp-topo-btn,
.nvp-enz-btn {
  padding: 3px 9px;
  border: 1px solid var(--n-line-1);
  border-radius: 4px;
  background: var(--n-bg-1);
  color: var(--n-ink-2);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.nvp-topo-btn.active,
.nvp-enz-btn.active {
  background: var(--n-accent);
  border-color: var(--n-accent);
  color: var(--n-on-accent);
}
.nvp-topo-btn:focus-visible,
.nvp-enz-btn:focus-visible { outline: 2px solid var(--n-focus-ring); outline-offset: 1px; }

.nvp-map-canvas {
  width: 100%;
  border: 1px solid var(--n-line-2);
  border-radius: 6px;
  background: var(--n-bg-1);
  overflow: hidden;
}
.nvp-map { display: block; width: 100%; height: auto; }
.nvp-map-circular { max-height: 640px; }

/* A drawn feature. The fill is data (see the file header); only the
 * interaction affordance is styled here. */
.nvp-feature { cursor: pointer; }
.nvp-feature:hover .nvp-arc,
.nvp-feature:hover .nvp-arrow {
  fill-opacity: 1;
  stroke: var(--n-ink-1);
  stroke-width: 1.1;
}
.nvp-arc-label,
.nvp-arrow-label {
  font-family: var(--font-mono, var(--mono));
  paint-order: stroke;
  stroke: var(--n-scrim);
  stroke-width: 2.4px;
  stroke-linejoin: round;
}
.nvp-tick-label,
.nvp-enz-label { font-family: var(--font-mono, var(--mono)); }
.nvp-cassette-label { font-family: inherit; }

.nvp-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--n-ink-2);
}
.nvp-lg-item { display: inline-flex; align-items: center; }
.nvp-lg-note { color: var(--n-ink-3); font-style: italic; }

/* ===================================================================== *
 * Sequence view
 * ===================================================================== */
.nvp-seq-host { display: block; width: 100%; }
.nvp-seq-wrap { display: flex; gap: 12px; align-items: flex-start; }
.nvp-seq-rail-holder { flex: 0 0 auto; }
.nvp-seq-main { flex: 1 1 auto; min-width: 0; }

.nvp-seq-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  align-items: center;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--n-ink-2);
}
.nvp-seq-opt { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.nvp-seq-wrapsel {
  padding: 1px 4px;
  border: 1px solid var(--n-line-1);
  border-radius: 3px;
  background: var(--n-bg-1);
  color: var(--n-ink-1);
  font: inherit;
  font-size: 11px;
}
.nvp-seq-status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 5px;
  font-size: 11.5px;
  color: var(--n-ink-3);
}
.nvp-seq-stale { color: var(--n-warn); }

.nvp-seq-scroll {
  height: 460px;
  overflow: auto;
  border: 1px solid var(--n-line-2);
  border-radius: 6px;
  background: var(--n-bg-1);
}
.nvp-seq-scroll:focus-visible { outline: 2px solid var(--n-focus-ring); outline-offset: -2px; }

.nvp-seq-row {
  display: flex;
  gap: 8px;
  padding: 5px 10px 7px;
  border-bottom: 1px solid var(--n-line-2);
}
.nvp-seq-num {
  flex: 0 0 auto;
  min-width: 6.5ch;
  text-align: right;
  font-family: var(--font-mono, var(--mono));
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--n-ink-3);
  user-select: none;
}
.nvp-seq-body { flex: 1 1 auto; min-width: 0; position: relative; }

/* Every character grid in a row shares one font metric so the ruler, the
 * bases, the complement, the translation and the enzyme markers line up
 * column-for-column. This is the whole reason the view is monospace. */
.nvp-seq-ruler,
.nvp-seq-bases,
.nvp-seq-aa,
.nvp-seq-enz,
.nvp-seq-enz-names {
  font-family: var(--font-mono, var(--mono));
  font-size: 12.5px;
  line-height: 16px;
  letter-spacing: .5px;
  white-space: pre;
  overflow: hidden;
}
.nvp-seq-ruler { color: var(--n-ink-3); user-select: none; }
.nvp-seq-fwd { color: var(--n-ink-1); }
.nvp-seq-rev { color: var(--n-ink-3); }
.nvp-seq-aa { color: var(--n-accent); }
.nvp-seq-enz { color: var(--n-ink-2); user-select: none; }
.nvp-seq-enz-names {
  font-size: 10px;
  line-height: 13px;
  letter-spacing: 0;
  color: var(--n-ink-3);
}

/* Annotation lane inside a sequence row. Chips are absolutely positioned as a
 * percentage of the row, so they track the base columns at any wrap width. */
.nvp-seq-track {
  position: relative;
  height: 13px;
  margin-top: 1px;
}
.nvp-seq-track.squish { height: 6px; }
.nvp-seq-chip {
  position: absolute;
  top: 0;
  height: 100%;
  min-width: 2px;
  border-radius: 2px;
  overflow: hidden;
  font-size: 9.5px;
  line-height: 13px;
  white-space: nowrap;
  color: var(--n-on-accent);
  text-align: center;
  cursor: pointer;
}
.nvp-seq-chip:hover { outline: 1px solid var(--n-ink-1); }

.nvp-seq-pad { width: 100%; }

/* ===================================================================== *
 * 3-D structure view
 * ===================================================================== */
.nvp-struct-host { display: block; width: 100%; }
.nvp-struct-wrap { display: flex; flex-direction: column; gap: 6px; }
.nvp-struct-info,
.nvp-struct-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--n-ink-2);
}
.nvp-struct-opt { display: inline-flex; align-items: center; gap: 4px; }
.nvp-struct-repr {
  padding: 2px 5px;
  border: 1px solid var(--n-line-1);
  border-radius: 3px;
  background: var(--n-bg-1);
  color: var(--n-ink-1);
  font: inherit;
  font-size: 11px;
}
.nvp-struct-canvas {
  position: relative;
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--n-line-2);
  border-radius: 6px;
  background: var(--n-bg-2);
  overflow: hidden;
}
.nvp-struct-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 11.5px;
  color: var(--n-ink-2);
}
.nvp-struct-legend-title {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--n-ink-3);
}
.nvp-struct-prov {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--n-ink-3);
}
.nvp-struct-cite { font-style: italic; }
.nvp-struct-loading,
.nvp-struct-nogl {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: 24px;
  text-align: center;
  color: var(--n-ink-3);
}
.nvp-struct-nogl-title { font-weight: 600; color: var(--n-warn); }
.nvp-struct-nogl-detail { max-width: 52ch; font-size: 12px; line-height: 1.5; }

/* ===================================================================== *
 * Compact layout: stack the rail above the drawing rather than beside it.
 * ===================================================================== */
@media (max-width: 900px) {
  .nvp-map-wrap,
  .nvp-seq-wrap { flex-direction: column; }
  .nvp-rail {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    max-width: none;
    width: 100%;
  }
  .nvp-rail-types { flex-direction: row; flex-wrap: wrap; gap: 2px 10px; }
}

/* Printing / PDF export: drop the interactive chrome, keep the drawing. */
@media print {
  .nvp-rail,
  .nvp-map-tools,
  .nvp-seq-toolbar,
  .nvp-struct-tools,
  .nvp-tip { display: none !important; }
  .nvp-seq-scroll { height: auto; overflow: visible; }
}
