/* NMD Lung Atlas — base styling. Plain CSS, no framework. */
:root {
  --c-bg: #fafafa;
  --c-card: #ffffff;
  --c-text: #1f2937;
  --c-muted: #6b7280;
  --c-border: #e5e7eb;
  --c-accent: #2563eb;
  --c-accent-light: #dbeafe;

  /* Canonical NMD-figure palette (matches project conventions) */
  --c-ptc-pos: #ef8a62;
  --c-ptc-neg: #d95f02;
  --c-control: #67a9cf;
  --c-nmd: #ef8a62;

  /* Cell-type colors */
  --c-ct-AT: #4c72b0;
  --c-ct-DD: #dd8452;
  --c-ct-FB: #55a868;
  --c-ct-MV: #c44e52;

  --c-cds: #4a5568;
  --c-utr: #cbd5e0;

  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 14px;
  line-height: 1.5;
}

header {
  background: #ffffff;
  border-bottom: 1px solid var(--c-border);
  padding: 1.2em 2em;
}
.header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1em; }
header h1 { margin: 0; font-size: 1.5em; font-weight: 600; }
header h1 a { color: inherit; text-decoration: none; }
header h1 a:hover { color: var(--c-accent); }
.subtitle { margin: 0.3em 0 0; color: var(--c-muted); font-size: 0.9em; max-width: 60em; }
.topnav { display: flex; gap: 0.5em; flex-shrink: 0; }
.btn-nav {
  padding: 0.4em 0.9em; background: #fff; color: var(--c-accent);
  border: 1px solid var(--c-border); border-radius: 6px; cursor: pointer;
  font-family: var(--font-body); font-size: 0.85em; font-weight: 500;
}
.btn-nav:hover { background: var(--c-accent-light); border-color: var(--c-accent); }

.filter-bar {
  display: flex; flex-wrap: wrap; gap: 0.5em 1.3em; align-items: center;
  padding: 0.5em 0.7em; margin: 0.4em 0 0.7em;
  background: #f9fafb; border: 1px solid var(--c-border); border-radius: 6px;
  font-size: 0.85em;
}
.filter-bar label { display: flex; align-items: center; gap: 0.4em; cursor: pointer; }
.filter-bar input[type="range"] { width: 8em; }
.filter-bar .mono { font-family: var(--font-mono); min-width: 2em; text-align: right; font-weight: 500; }

.iso-count {
  display: inline-block; font-size: 0.75em; font-weight: 500; color: var(--c-muted);
  background: #f3f4f6; border-radius: 10px; padding: 1px 8px; margin-left: 0.5em;
}
#isoform-table .gencode-only { color: var(--c-muted); font-style: italic; }
#isoform-table .gencode-only td.iso-id::after {
  content: " (annotated, not detected)"; color: var(--c-muted); font-style: italic; font-size: 0.85em;
}
.badge-muted {
  display: inline-block; margin-left: 0.5em; padding: 2px 8px; border-radius: 8px;
  font-size: 0.75em; font-weight: 500; background: #e5e7eb; color: #4b5563; font-style: normal;
}
.placeholder-panel {
  height: 230px; display: flex; align-items: center; justify-content: center;
  color: var(--c-muted); font-size: 0.9em; font-style: italic; text-align: center;
  border: 1px dashed var(--c-border); border-radius: 6px; padding: 1em; background: #fafafa;
}

/* ── Stacked-isoform section ── */
.stack-card { margin-top: 1.2em; }
.stack-header {
  display: flex; justify-content: space-between; align-items: center; gap: 1em;
  flex-wrap: wrap; margin-bottom: 0.4em;
}
.stack-header h3 { margin: 0; }
.stack-actions { display: flex; align-items: center; gap: 0.7em; }
#transcript-stack {
  background: #fff; border: 1px solid var(--c-border); border-radius: 6px;
  overflow-x: auto; overflow-y: hidden; margin-top: 0.3em;
}
#transcript-stack svg { display: block; }

/* ── Modal ── */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }
.modal-panel {
  background: #fff; border-radius: 8px; box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  width: 92vw; max-width: 1400px; height: 88vh;
  display: flex; flex-direction: column;
  padding: 1em 1.5em;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 0.6em; border-bottom: 1px solid var(--c-border); margin-bottom: 0.6em;
}
.modal-header h3 { margin: 0; font-size: 1.1em; }
.modal-body {
  flex: 1; overflow-y: auto; overflow-x: auto;
  background: #fafafa; border: 1px solid var(--c-border); border-radius: 6px;
  padding: 0.3em;
}
.modal-body svg { display: block; }
.modal-footnote { margin-top: 0.6em; }

main { padding: 1.5em 2em; max-width: 90em; margin: 0 auto; }

.search-section { margin-bottom: 1.5em; position: relative; max-width: 30em; }
.search-section label { font-weight: 500; display: block; margin-bottom: 0.3em; }
.search-section input {
  width: 100%; padding: 0.6em 0.8em; font-size: 1em;
  border: 1px solid var(--c-border); border-radius: 6px;
  font-family: var(--font-body);
}
.search-section input:focus { outline: 2px solid var(--c-accent); border-color: var(--c-accent); }
#search-results {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 10;
  margin: 0.2em 0 0; padding: 0; list-style: none; max-height: 18em; overflow-y: auto;
  background: #fff; border: 1px solid var(--c-border); border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
#search-results:empty { display: none; }
#search-results li {
  padding: 0.5em 0.8em; cursor: pointer; border-bottom: 1px solid var(--c-border);
}
#search-results li:last-child { border-bottom: none; }
#search-results li:hover, #search-results li.highlight { background: var(--c-accent-light); }
#search-results .sym { font-weight: 600; }
#search-results .gid { color: var(--c-muted); font-family: var(--font-mono); font-size: 0.85em; margin-left: 0.5em; }
#search-results .badge {
  display: inline-block; margin-left: 0.5em; padding: 1px 6px; border-radius: 8px;
  font-size: 0.75em; background: var(--c-nmd); color: white;
}

.hidden { display: none !important; }

#gene-panel h2 { margin: 0.5em 0 1em; font-size: 1.3em; }
.gene-id-small { color: var(--c-muted); font-family: var(--font-mono); font-size: 0.7em; font-weight: 400; margin-left: 0.5em; }

.panel-grid {
  display: grid;
  grid-template-columns: 28em 1fr;
  gap: 1.2em;
}
@media (max-width: 1100px) { .panel-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--c-card); border: 1px solid var(--c-border);
  border-radius: 8px; padding: 1em 1.2em;
}
.card h3 { margin: 0 0 0.5em; font-size: 1.05em; font-weight: 600; }
.card h4 { margin: 1em 0 0.4em; font-size: 0.95em; font-weight: 600; color: #374151; }
.hint { color: var(--c-muted); font-size: 0.85em; margin: 0 0 0.6em; }
.abbr-legend { margin-top: 0.4em; font-size: 0.78em; font-style: italic; text-align: right; }

#isoform-table-wrap { max-height: 36em; overflow: auto; }
#isoform-table { width: 100%; border-collapse: collapse; font-size: 0.85em; }
#isoform-table th, #isoform-table td {
  padding: 0.4em 0.5em; text-align: left; border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
#isoform-table th {
  position: sticky; top: 0; background: #f3f4f6;
  font-weight: 600; font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.03em;
}
#isoform-table tr { cursor: pointer; }
#isoform-table tr:hover { background: #f9fafb; }
#isoform-table tr.selected { background: var(--c-accent-light); }
#isoform-table td.iso-id { font-family: var(--font-mono); font-size: 0.85em; }
#isoform-table .nmd-true { color: var(--c-nmd); font-weight: 700; }
#isoform-table .nmd-false { color: var(--c-muted); }
#isoform-table td.numeric { text-align: right; font-variant-numeric: tabular-nums; }

.meta-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(11em, 1fr));
  gap: 0.4em 1em; margin: 0.4em 0 1em;
}
.meta-grid div { font-size: 0.85em; }
.meta-grid .label { color: var(--c-muted); }
.meta-grid .value { font-weight: 500; }

.charts-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.2em; margin-top: 0.5em;
}
@media (max-width: 900px) { .charts-row { grid-template-columns: 1fr; } }

#transcript-viz {
  width: 100%; min-height: 110px;
  background: #fff; border: 1px solid var(--c-border); border-radius: 6px;
  margin: 0.2em 0 0.8em; overflow: auto;
}
#transcript-viz svg { display: block; }

/* CDS-provenance banner — visible for every isoform */
.cds-provenance {
  display: flex; flex-direction: column; gap: 0.2em;
  padding: 0.5em 0.8em; margin: 0.2em 0 0.3em; border-radius: 6px;
  border-left: 4px solid;
  font-size: 0.85em;
}
.cds-provenance .cds-src-label { font-weight: 600; }
.cds-provenance .cds-src-detail { color: var(--c-muted); font-size: 0.9em; }
.cds-src-gencode      { background: #eef4ff; border-color: #2563eb; }
.cds-src-gencode-nf   { background: #f3f4f6; border-color: #6b7280; }
.cds-src-refaug       { background: #ecfdf5; border-color: #059669; }
.cds-src-td2          { background: #fef3c7; border-color: #d97706; }
.cds-src-td2 .cds-src-label::after { content: " ⚠"; }
.cds-src-none         { background: #f9fafb; border-color: #d1d5db; }

/* ── Documentation pages (About / Methods / Cite) ── */
.docs-page {
  max-width: 55em;
  margin: 0 auto 3em;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 1.5em 2em;
  line-height: 1.65;
}
.docs-page h2 {
  margin: 0 0 0.4em;
  font-size: 1.5em;
  font-weight: 600;
  border-bottom: 2px solid var(--c-accent);
  padding-bottom: 0.3em;
}
.docs-page h3 {
  margin: 1.3em 0 0.4em;
  font-size: 1.05em;
  font-weight: 600;
  color: #374151;
}
.docs-page .docs-lead {
  font-size: 1.05em;
  color: #374151;
  margin: 0.6em 0 1.2em;
}
.docs-page p { margin: 0.5em 0; }
.docs-page ul, .docs-page ol {
  padding-left: 1.4em;
  margin: 0.4em 0 0.6em;
}
.docs-page li { margin: 0.2em 0; }
.docs-page code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: #f3f4f6;
  padding: 1px 5px;
  border-radius: 3px;
}
.docs-page a {
  color: var(--c-accent);
  text-decoration: none;
}
.docs-page a:hover { text-decoration: underline; }
.docs-page blockquote.cite-block {
  margin: 0.6em 0 1em;
  padding: 0.8em 1.1em;
  background: #f9fafb;
  border-left: 3px solid var(--c-accent);
  border-radius: 0 6px 6px 0;
  font-size: 0.95em;
  color: #1f2937;
}
.docs-page blockquote.cite-block code { background: #e5e7eb; }
.docs-page .tbd {
  color: var(--c-muted);
  font-style: italic;
}

/* Highlight the active nav link */
.topnav a.active,
.topnav button.active {
  background: var(--c-accent-light);
  border-color: var(--c-accent);
}

.welcome { background: var(--c-card); border: 1px solid var(--c-border);
  border-radius: 8px; padding: 1em 1.5em; max-width: 50em; }
.welcome h2 { margin: 0 0 0.4em; font-size: 1.15em; }
.welcome a { color: var(--c-accent); text-decoration: none; }
.welcome a:hover { text-decoration: underline; }

footer { padding: 1.5em 2em; color: var(--c-muted); border-top: 1px solid var(--c-border);
  margin-top: 3em; background: #ffffff; }
footer a { color: var(--c-accent); text-decoration: none; }
