/* Project Cytoplasm — pixel-art RPG aesthetic on a warm light palette
   (preview theme: bg #FFF9F5 / ink #3E474F). Lean, dependency-free; one vendored
   web font (Source Sans 3, self-hosted — see vendor/fonts/source-sans-3.css). */

:root {
  /* Site typeface: Source Sans 3 everywhere (team-leader directive). --font-mono
     stays available for any numeric/code readout that wants fixed width. */
  --font-sans: 'Source Sans 3', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "DejaVu Sans Mono", monospace;

  --bg: #FFF9F5;         /* warm off-white */
  --bg-2: #F7EDE4;       /* header / control-bar tint */
  --panel: #FFFFFF;
  --panel-2: #F7EDE4;
  --ink: #3E474F;        /* dark slate text */
  --muted: #8A929B;
  --accent: #0E9C8A;     /* cytoplasm teal (deepened for contrast on cream) */
  --accent-2: #C8860B;   /* pixel gold (deepened) */
  --line: #E7D9CD;
  --danger: #C2453F;
  --gap: #ECE3DB;        /* no-data / canvas backdrop (light) */
  --radius: 4px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
}

body { display: flex; flex-direction: column; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* --- Top bar --- */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-2);
  border-bottom: 2px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.logo-placeholder {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px;
  background: var(--panel-2); color: var(--accent);
  border: 2px solid var(--accent); border-radius: var(--radius);
  font-size: 16px; transform: translateY(4px);
}
.title { font-weight: 700; letter-spacing: 3px; color: var(--accent); }
.subtitle { color: var(--muted); font-size: 11px; letter-spacing: 1px; }
#topbar nav { display: flex; gap: 16px; }
#topbar nav a { color: var(--ink); padding: 4px 6px; border-bottom: 2px solid transparent; }
#topbar nav a.active { border-bottom-color: var(--accent); color: var(--accent); }

/* --- Layout --- */
#layout { display: flex; flex: 1; min-height: 0; gap: 14px; }
#catalog {
  width: 250px; flex-shrink: 0;
  background: var(--panel);
  border-right: 2px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.catalog-controls { padding: 10px; display: flex; flex-direction: column; gap: 8px; border-bottom: 2px solid var(--line); }
#search, select, input[type="range"] { font-family: inherit; }
#search, select {
  background: var(--bg); color: var(--ink);
  border: 2px solid var(--line); border-radius: var(--radius);
  padding: 6px 8px; font-size: 12px;
}
.scroll { overflow-y: auto; min-height: 0; flex: 1; }

/* --- Catalog cards --- */
.exp-card, .chr-card {
  padding: 9px 12px; margin: 6px 8px;
  background: var(--panel-2);
  border: 2px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: var(--radius); cursor: pointer;
}
.exp-card:hover, .chr-card:hover { border-color: var(--accent); background: #223256; }
.exp-card.selected, .chr-card.selected { border-color: var(--accent-2); border-left-color: var(--accent-2); }
.exp-card .acc { font-weight: 700; color: var(--accent); }
.exp-card .row, .chr-card .row { display: flex; justify-content: space-between; gap: 8px; min-width: 0; }
.exp-card .row > *, .chr-card .row > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chr-card .pearson, .badge { flex-shrink: 0; }
.exp-card .meta-line, .chr-card .meta-line { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted);
}
.chr-card .pearson { color: var(--accent); }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-family: inherit; font-size: 12px; padding: 4px; }
#chromosome-panel { display: flex; flex-direction: column; min-height: 0; flex: 1; }
#chromosome-meta { padding: 6px 12px; border-bottom: 1px solid var(--line); }
#chromosome-meta .acc { color: var(--accent); font-weight: 700; }

/* --- Viewer --- */
#viewer { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: auto; }
.empty-state { display: grid; place-items: center; height: 100%; color: var(--muted); padding: 40px; text-align: center; }
#viewer-header { padding: 12px 16px 0; }
#vh-title { margin: 0; color: var(--accent); letter-spacing: 1px; }
/* Three-column grid:
   col 1: IGV (row 1) → contact map (row 2)
   col 2: metadata (row 1) → MSD (row 2) → loss-tangent (row 3)
   col 3: (empty row 1) → 3D model (row 2) */
#panes { display: grid; grid-template-columns: 650px 600px 600px; row-gap: 30px; column-gap: 30px; padding: 12px 16px; align-items: start; }
@media (max-width: 1350px) { #panes { grid-template-columns: 650px 600px; } }
@media (max-width: 900px)  { #panes { grid-template-columns: 1fr; } }

#igv-pane       { grid-column: 1; grid-row: 1; }
#metadata-panel { grid-column: 2; grid-row: 1; }
#heatmap-pane   { grid-column: 1; grid-row: 2; }
#msd-lt-stack   { grid-column: 2; grid-row: 2; display: flex; flex-direction: column; gap: 10px; }
#model-pane     { grid-column: 3; grid-row: 2; }

.pane { background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-width: 0; }
#igv-pane, #heatmap-pane { width: 650px; }
#metadata-panel, #model-pane, #msd-pane, #lt-pane { width: 600px; }
.igv-host { background: #f7f8fb; height: 300px; border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius); overflow: hidden; }
.igv-msg { color: var(--muted); padding: 24px; font-size: 12px; }
.igv-msg code { color: var(--accent); }
.pane-head {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  padding: 8px 10px; border-bottom: 2px solid var(--line); background: var(--bg-2);
  font-size: 12px;
}
.pane-head .controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pane-head label { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 11px; }
.pane-head .chk { gap: 4px; }
.pane-head select { padding: 2px 4px; font-size: 11px; }
.pane-head input[type="range"] { width: 84px; vertical-align: middle; }
#d3-slice-label { font-size: 11px; min-width: 74px; display: inline-block; }

.canvas-wrap { position: relative; aspect-ratio: 1 / 1; width: 100%; background: var(--gap); }
.canvas-wrap canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
/* Contact map: square canvas. */
#heatmap-pane .canvas-wrap { width: 100%; aspect-ratio: 1 / 1; }
/* ECharts host fills its wrap; ECharts manages its own canvas. */
.echarts-host { position: absolute; inset: 0; width: 100%; height: 100%; }
/* Crosshair over the 2D contact map. */
.hm-cross { position: absolute; pointer-events: none; background: rgba(14, 156, 138, 0.85); }
.hm-cross-v { top: 0; bottom: 0; width: 1px; }
.hm-cross-h { left: 0; right: 0; height: 1px; }
/* MSD + loss-tangent: fixed height (locus axis is horizontal). */
#msd-pane .canvas-wrap, #lt-pane .canvas-wrap { aspect-ratio: auto; height: 300px; }
/* Hide the auto-generated axis captions below MSD and loss-tangent maps. */
#msd-caption, #lt-caption { display: none; }
/* 3D model: square canvas matching the contact map. */
#model-pane .canvas-wrap { width: 100%; aspect-ratio: 1 / 1; }
.map-caption { padding: 6px 10px; font-size: 11px; border-top: 1px solid var(--line); }

/* Color legend / colorbar (heatmap + maps). */
.colorbar-row { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-top: 1px solid var(--line); font-size: 10px; }
.colorbar { flex: 1 1 auto; height: 10px; min-width: 40px; border: 1px solid var(--line); border-radius: 3px; display: block; }
#hm-cbar-unit { margin-left: 2px; }
.readout {
  position: absolute; left: 8px; bottom: 8px;
  background: rgba(255, 249, 245, 0.92); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 3px 7px; font-size: 11px; pointer-events: none; opacity: 0;
  transition: opacity 0.1s;
}

/* --- Metadata panel --- */
.meta-body { padding: 12px; min-height: 300px; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px 16px; }
.meta-grid .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.meta-grid .v { color: var(--ink); }
.download {
  display: inline-block; margin-top: 12px; padding: 8px 14px;
  background: var(--accent); color: #06231d; font-weight: 700;
  border-radius: var(--radius); border: 2px solid #2fae99;
}
.download:hover { text-decoration: none; background: #6ff0d9; }

.about { padding: 20px 28px; max-width: 760px; }
.about h2 { color: var(--accent); }

/* --- Footer --- */
#footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  padding: 10px 16px; background: var(--bg-2);
  border-top: 2px solid var(--line); color: var(--muted); font-size: 11px;
}
