/* Urea Cycle Research Hub
   Plain and quiet: one accent colour, hairline rules instead of shadows, a serif for headings.
   Many templates carry inline styles from the live app, so a few rules below need !important. */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,400;8..60,600&family=Source+Sans+3:wght@400;500;600&display=swap');

:root {
  --ink: #1d232b;
  --text: #39424e;
  --muted: #6b7480;
  --rule: #e4e6e9;
  --rule-strong: #cfd3d8;
  --paper: #ffffff;
  --wash: #f6f7f8;
  --accent: #23466e;
  --accent-soft: #e9eef4;
  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --sans: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --measure: 1120px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font: 17px/1.6 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header ---------- */

header {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  padding: 0 24px;
}

header > * { max-width: var(--measure); }

/* The title already links home, so the separate Home button goes. */
.header-home-link,
.header-top-right:empty { display: none; }

header > div[style] {
  display: block !important;
  margin: 0 auto !important;
  padding-top: 22px;
}

header h1 {
  margin: 0;
  font: 600 1.35rem/1.2 var(--serif);
  letter-spacing: -0.01em;
}

header h1 a.site-title-link {
  color: var(--ink);
  text-decoration: none;
}

header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  margin: 14px auto 0;
}

header nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 6px 0 12px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

header nav a:hover { color: var(--ink); }

header nav a.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* The variant explorer is the main draw: a filled button set apart from the eight genes. */
header nav a.nav-variants {
  margin: 0 0 10px auto;
  align-self: center;
  padding: 7px 14px;
  border: none;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.01em;
}

header nav a.nav-variants::after { content: ' →'; }
header nav a.nav-variants:hover { background: var(--ink); color: #fff; }
header nav a.nav-variants.active { background: var(--ink); color: #fff; border: none; }

/* ---------- Shared bits ---------- */

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.btn-primary {
  display: inline-block;
  padding: 11px 20px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}

.btn-primary:hover { background: var(--ink); color: #fff; }

/* ---------- Home: explorer feature ---------- */

.explorer-feature {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 48px;
  margin: 2.25rem 0 2.5rem;
  padding: 36px 40px;
  background: var(--accent-soft);
  border-radius: 6px;
}

.explorer-feature h3 {
  margin: 0 0 14px;
  font-size: 1.65rem;
  line-height: 1.25;
}

.explorer-feature p:not(.eyebrow) { max-width: 34rem; }
.explorer-feature .btn-primary { margin-top: 6px; }

.explorer-bars ul { list-style: none; margin: 0; padding: 0; }
.explorer-bars li { margin: 0; }

.explorer-bars a {
  display: grid;
  grid-template-columns: 4.2rem 1fr 2.6rem;
  gap: 12px;
  align-items: center;
  padding: 5px 0;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.92rem;
}

.explorer-bars .sym { font-weight: 600; }
.explorer-bars .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.explorer-bars .bar { height: 8px; background: rgba(35, 70, 110, 0.12); border-radius: 2px; overflow: hidden; }
.explorer-bars .bar i { display: block; height: 100%; background: var(--accent); }
.explorer-bars a:hover .bar i { background: var(--ink); }
.explorer-bars a:hover .sym { text-decoration: underline; }

@media (max-width: 860px) {
  .explorer-feature { grid-template-columns: 1fr; gap: 28px; padding: 26px 22px; }
  .explorer-feature h3 { font-size: 1.4rem; }
}

/* ---------- Variants landing ---------- */

.variants-landing h2 { max-width: 40rem; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 2rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.stat-row div { padding: 16px 0; }
.stat-row div + div { padding-left: 20px; border-left: 1px solid var(--rule); }
.stat-row dt { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.stat-row dd { margin: 4px 0 0; font: 600 1.9rem/1.1 var(--serif); color: var(--ink); font-variant-numeric: tabular-nums; }

.gene-tiles {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.gene-tiles li { margin: 0; }

.gene-tiles a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100%;
  padding: 18px 20px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s;
}

.gene-tiles a:hover { border-color: var(--accent); }
.gene-tiles a:hover .sym { text-decoration: underline; }

.tile-top { display: flex; justify-content: space-between; align-items: baseline; }
.gene-tiles .sym { font: 600 1.3rem var(--serif); color: var(--accent); }
.uniprot { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.tile-name { font-size: 0.92rem; color: var(--muted); margin-bottom: 10px; }
.tile-count { font-size: 0.92rem; }
.tile-count strong { font: 600 1.5rem var(--serif); }
.tile-bar { height: 6px; margin: 6px 0 4px; background: var(--rule); border-radius: 2px; overflow: hidden; }
.tile-bar i { display: block; height: 100%; background: #b5574b; }
.tile-meta { font-size: 0.8rem; color: var(--muted); }

@media (max-width: 720px) {
  .stat-row { grid-template-columns: 1fr 1fr; }
  .stat-row div:nth-child(3) { padding-left: 0; border-left: none; }
  .stat-row div:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .stat-row dd { font-size: 1.5rem; }
}

/* ---------- Layout and type ---------- */

main {
  flex: 1;
  width: 100%;
  max-width: calc(var(--measure) + 48px);
  margin: 0 auto;
  padding: 40px 24px 64px;
}

h2, h3, h4 {
  font-family: var(--serif);
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.01em;
}

h2 { font-size: 2rem; line-height: 1.2; margin: 0 0 0.6rem; }
h3 { font-size: 1.3rem; line-height: 1.3; margin: 2.25rem 0 0.75rem; }
h4 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
h5 { font-size: 0.95rem; color: var(--ink); }

p { margin: 0 0 1rem; color: var(--text); }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--ink); }

ul, ol { line-height: 1.65; }
li { margin-bottom: 0.35rem; }

strong { color: var(--ink); font-weight: 600; }

code {
  font: 0.85em ui-monospace, 'SF Mono', Menlo, monospace;
  background: var(--wash);
  padding: 1px 5px;
  border-radius: 3px;
}

hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 2rem 0;
}

section {
  margin: 0 0 3rem;
}

.muted { color: var(--muted) !important; }
.small { font-size: 0.86rem; }

/* ---------- Home ---------- */

.home-lede {
  font-size: 1.15rem;
  line-height: 1.65;
  max-width: 44rem;
}

.home-figure {
  margin: 2rem 0 2.5rem;
  padding: 24px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  text-align: center;
}

.home-figure img {
  max-width: 100%;
  max-height: 480px;
  height: auto;
}

.home-figure figcaption {
  margin-top: 12px;
  font-size: 0.86rem;
  color: var(--muted);
}

.home-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
}

.home-cols p, .home-cols li { max-width: 34rem; }

.gene-index {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--rule);
}

.gene-index li {
  margin: 0;
  border-bottom: 1px solid var(--rule);
}

.gene-index a {
  display: flex;
  gap: 16px;
  align-items: baseline;
  padding: 10px 0;
  text-decoration: none;
  color: var(--text);
}

.gene-index a:hover { color: var(--ink); background: var(--wash); }

.gene-index .sym {
  width: 4.5rem;
  flex: none;
  font-weight: 600;
  color: var(--accent);
}

@media (max-width: 760px) {
  .home-cols { grid-template-columns: 1fr; gap: 8px; }
}

/* ---------- Gene pages: publication list ---------- */

ol#papers-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--rule);
}

ol#papers-list > li {
  margin: 0 !important;
  padding: 22px 0 !important;
  border-bottom: 1px solid var(--rule) !important;
}

ol#papers-list > li strong a {
  color: var(--ink) !important;
  font: 600 1.12rem/1.4 var(--serif);
  text-decoration: none !important;
}

ol#papers-list > li strong a:hover { color: var(--accent) !important; text-decoration: underline !important; }

ol#papers-list > li em {
  font-style: italic;
  color: var(--text);
}

ol#papers-list > li small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.86rem;
}

ol#papers-list > li p {
  margin: 12px 0 0;
  font-size: 0.97rem;
  line-height: 1.65;
  max-width: 50rem;
}

.paper-variants-mentioned {
  background: var(--accent-soft) !important;
  border-radius: 3px !important;
}

/* Toolbar above the list */
#export-btn,
#load-more,
#show-all,
#search-form button[type="submit"] {
  font: 500 0.88rem var(--sans) !important;
  padding: 7px 14px !important;
  border-radius: 4px !important;
  border: 1px solid var(--rule-strong) !important;
  background: var(--paper) !important;
  color: var(--ink) !important;
  cursor: pointer;
}

#export-btn:hover,
#load-more:hover,
#show-all:hover { border-color: var(--ink) !important; }

#load-more {
  background: var(--ink) !important;
  border-color: var(--ink) !important;
  color: #fff !important;
}

#load-more:hover { background: var(--accent) !important; border-color: var(--accent) !important; }

#export-menu {
  border: 1px solid var(--rule-strong) !important;
  border-radius: 4px !important;
  box-shadow: 0 6px 20px rgba(20, 30, 40, 0.08) !important;
}

#export-menu a { color: var(--ink) !important; font-size: 0.9rem; }
#export-menu a:hover { background: var(--wash); }

button { font-family: inherit; }

.loading-text {
  text-align: center;
  color: var(--muted);
  display: none;
  margin-top: 0.5rem;
}

/* Inputs (live app only, kept tidy in case they show) */
input[type="text"], textarea, select, #keywords-input {
  font: inherit;
  font-size: 0.92rem;
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  padding: 6px 10px;
  background: var(--paper);
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

/* ---------- Footer ---------- */

footer {
  border-top: 1px solid var(--rule);
  padding: 22px 24px 28px;
}

footer p {
  max-width: var(--measure);
  margin: 0 auto;
  font-size: 0.86rem;
  color: var(--muted);
}

/* ---------- Variant explorer ---------- */

nav.crumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 1rem;
  font-size: 0.88rem;
  color: var(--muted);
}

nav.crumb a { color: var(--muted); text-decoration: none; }
nav.crumb a:hover { color: var(--ink); text-decoration: underline; }
nav.crumb strong { color: var(--ink); font-weight: 600; }

.variants-summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  align-items: baseline;
  margin: 1.5rem 0;
  padding: 14px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-size: 0.93rem;
}

.am-pill {
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.variants-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  margin: 1.5rem 0 1rem;
  align-items: center;
}

.variants-controls label {
  font-size: 0.88rem;
  color: var(--muted);
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.table-wrap { overflow-x: auto; }

.variants-table, .data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.variants-table th, .variants-table td,
.data-table th, .data-table td {
  padding: 9px 12px;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

.variants-table th, .data-table th {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  background: none;
  border-bottom: 1px solid var(--rule-strong);
  white-space: nowrap;
}

.data-table thead { background: none; }
.variants-table tbody tr:hover { background: var(--wash); }
.data-table td.exp-notes { white-space: pre-wrap; max-width: 42rem; word-break: break-word; color: var(--muted); }

.am-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  font-weight: 600;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}
.am-badge.am-good, .am-badge.am-likely-benign, .am-badge.am-benign { background: #e6f1ea; color: #285b3a; }
.am-badge.am-bad, .am-badge.am-likely-pathogenic, .am-badge.am-pathogenic { background: #f7e6e4; color: #8a2b22; }
.am-badge.am-mid, .am-badge.am-ambiguous, .am-badge.am-uncertain { background: #f6efdc; color: #7a5a12; }

.revel-cell { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.exp-score-legend { max-width: 52rem; line-height: 1.5; }

/* Variant detail: score blocks in a ruled row, other cards as plain sections. */
.variant-score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin: 1.75rem 0 1rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.variant-score-grid .card {
  padding: 16px 20px 12px 0 !important;
  margin: 0 !important;
}

.variant-score-grid .card + .card {
  padding-left: 20px !important;
  border-left: 1px solid var(--rule);
}

.variant-score-grid .card h3 {
  margin: 0 0 8px;
  font: 600 0.78rem/1.3 var(--sans);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.variant-score-grid .card p { margin-bottom: 6px; }

.card {
  background: none;
  margin: 0 0 2.25rem;
}

.variant-detail > .card,
.concordance-card {
  margin: 2.25rem 0 !important;
  padding: 0 !important;
}

.variant-detail > .card h3,
.concordance-card h3 {
  margin-top: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}

.plain-list { list-style: none; padding-left: 0; margin: 0; }
.plain-list li { margin-bottom: 6px; }

#molstar-root {
  border: 1px solid var(--rule) !important;
  border-radius: 4px !important;
  background: var(--wash);
}

.molstar-fallback { padding: 1rem; color: #8a2b22; }

.variants-gene-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
  border-top: 1px solid var(--rule);
  max-width: 44rem;
}

.variants-gene-list li {
  margin: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}

.variants-gene-list a { font-weight: 600; text-decoration: none; display: inline-block; width: 4.5rem; }

/* ---------- Small screens ---------- */

@media (max-width: 720px) {
  body { font-size: 16px; }
  header { padding: 0 16px; }
  header nav { gap: 2px 16px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  header nav::-webkit-scrollbar { display: none; }
  header nav a { white-space: nowrap; }
  header nav a.nav-variants { margin: 0 0 10px 8px; padding: 5px 11px; position: sticky; right: 0; }
  main { padding: 28px 16px 48px; }
  footer { padding: 18px 16px 24px; }
  h2 { font-size: 1.6rem; }
  main > div[style*="justify-content: space-between"] { flex-wrap: wrap; gap: 12px; }
  .variant-score-grid { grid-template-columns: 1fr 1fr; }
  .variant-score-grid .card { padding: 14px 12px 10px 0 !important; }
  .variant-score-grid .card + .card { padding-left: 12px !important; }
  .variant-score-grid .card:nth-child(odd) { border-left: none; padding-left: 0 !important; }
  .variant-score-grid .card:nth-child(n+3) { border-top: 1px solid var(--rule); }
}
