/* Mammal Dominance Database — site styles */
:root {
  --pri: #0f172a;
  --pri-soft: #1e293b;
  --accent: #6366f1;
  --accent-2: #ec4899;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --pig: #f97316;
  --rat: #14b8a6;
  --mouse: #8b5cf6;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top navbar */
.navbar {
  background: var(--pri);
  color: #fff;
  padding: 0.8rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.navbar-inner { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 2rem; }
.navbar .brand { font-weight: 700; font-size: 1.05rem; color: #fff; }
.navbar .brand small { font-weight: 400; opacity: .7; margin-left: .5rem; font-size: .85em; }
.navbar nav { display: flex; gap: 1.2rem; margin-left: auto; }
.navbar nav a { color: #cbd5e1; font-size: .92rem; }
.navbar nav a:hover { color: #fff; text-decoration: none; }
.navbar nav a.active { color: #fff; font-weight: 600; }

/* Page layout */
.container { max-width: 1280px; margin: 0 auto; padding: 1.5rem; }

/* Hero on landing */
.hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #6366f1 100%);
  color: #fff;
  padding: 3.5rem 1.5rem 4rem;
}
.hero-inner { max-width: 1280px; margin: 0 auto; }
.hero h1 { margin: 0 0 .5rem; font-size: 2.2rem; font-weight: 700; }
.hero .subtitle { font-size: 1.1rem; opacity: .9; max-width: 820px; }
.hero .badges { margin-top: 1.2rem; display: flex; flex-wrap: wrap; gap: .5rem; }
.hero .badge {
  background: rgba(255,255,255,.13);
  border: 1px solid rgba(255,255,255,.25);
  padding: .25rem .7rem;
  border-radius: 999px;
  font-size: .82rem;
}

/* Stat row */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-top: 2rem; }
.stat-card {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  color: #fff;
}
.stat-card .v { font-size: 1.8rem; font-weight: 700; }
.stat-card .k { font-size: .85rem; opacity: .85; }

/* Species cards on homepage */
.species-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; margin-top: 1.5rem; }
.species-card {
  background: var(--card);
  border-radius: 16px;
  padding: 1.6rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform .15s, box-shadow .15s;
}
.species-card:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(0,0,0,.08); }
.species-card .emoji { font-size: 2.8rem; }
.species-card[data-sp="pig"]   { border-top: 4px solid var(--pig); }
.species-card[data-sp="rat"]   { border-top: 4px solid var(--rat); }
.species-card[data-sp="mouse"] { border-top: 4px solid var(--mouse); }
.species-card h3 { margin: .6rem 0 .2rem; font-size: 1.3rem; }
.species-card .cn { color: var(--muted); font-size: .92rem; }
.species-card .nums { display: flex; gap: 1.2rem; margin-top: 1rem; font-size: .9rem; }
.species-card .nums div { display: flex; flex-direction: column; }
.species-card .nums strong { font-size: 1.2rem; color: var(--pri); }
.species-card a.cta { margin-top: 1.2rem; align-self: flex-start; background: var(--accent); color: #fff; padding: .55rem 1.1rem; border-radius: 8px; font-size: .92rem; }
.species-card a.cta:hover { background: #4f46e5; text-decoration: none; }

/* Section heading */
.section-head { margin: 2rem 0 1rem; display: flex; align-items: baseline; gap: 1rem; }
.section-head h2 { margin: 0; font-size: 1.4rem; }
.section-head .desc { color: var(--muted); font-size: .92rem; }

/* Toolbar for species page */
.toolbar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
}
.toolbar input[type=search] {
  width: 100%;
  padding: .55rem .8rem;
  font-size: .95rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.toolbar input[type=search]:focus { outline: 2px solid var(--accent); border-color: transparent; }
.toolbar .info { color: var(--muted); font-size: .9rem; }
.class-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .8rem; }
.chip {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .25rem .6rem;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .82rem;
  cursor: pointer;
  color: var(--text);
  transition: all .12s;
  user-select: none;
}
.chip:hover { background: #e2e8f0; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .n { opacity: .65; font-size: .9em; }

/* Data table */
.table-wrap { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data thead { background: #f1f5f9; }
table.data thead th { padding: .65rem .8rem; text-align: left; font-weight: 600; cursor: pointer; user-select: none; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data thead th:hover { background: #e2e8f0; }
table.data thead th .sort { color: var(--muted); margin-left: .3rem; font-size: .8em; }
table.data tbody tr { border-bottom: 1px solid var(--border); cursor: pointer; }
table.data tbody tr:hover { background: #f8fafc; }
table.data tbody td { padding: .55rem .8rem; vertical-align: top; }
table.data .trait-name { font-weight: 600; color: var(--accent); }
table.data .desc-cell { color: var(--text); max-width: 320px; }
table.data .class-cell { color: var(--muted); font-size: .85rem; white-space: nowrap; }
table.data .num { font-variant-numeric: tabular-nums; }
table.data .bar { display: inline-block; height: 6px; vertical-align: middle; background: var(--accent); border-radius: 3px; margin-right: .35rem; min-width: 2px; }
table.data .bar.dom { background: var(--accent-2); }
.qtl-pill { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; background: #e0e7ff; color: #4338ca; font-weight: 600; }
.qtl-pill.zero { background: #f1f5f9; color: var(--muted); }

/* Pagination */
.pagination { display: flex; justify-content: center; align-items: center; gap: .4rem; padding: 1rem; flex-wrap: wrap; }
.pagination button { background: #fff; border: 1px solid var(--border); padding: .4rem .8rem; border-radius: 6px; cursor: pointer; font-size: .9rem; }
.pagination button:hover:not(:disabled) { background: #f1f5f9; }
.pagination button:disabled { color: var(--muted); cursor: not-allowed; }
.pagination button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination .info { color: var(--muted); font-size: .85rem; margin: 0 .8rem; }

/* Trait detail page */
.breadcrumb { font-size: .88rem; color: var(--muted); margin-bottom: 1rem; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
.trait-hero {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.trait-hero h1 { margin: 0 0 .3rem; font-size: 1.7rem; }
.trait-hero .description { color: var(--muted); margin-bottom: 1rem; }
.trait-hero .meta { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.2rem; }
.trait-hero .meta .tag { background: #f1f5f9; border: 1px solid var(--border); padding: .25rem .65rem; border-radius: 999px; font-size: .85rem; }
.trait-hero .meta .tag.cls { background: #ede9fe; border-color: #c4b5fd; color: #5b21b6; }

.varbar-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-top: .6rem; }
.varbar {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .75rem 1rem;
}
.varbar .k { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.varbar .v { font-size: 1.4rem; font-weight: 700; }
.varbar .v .se { font-size: .75rem; color: var(--muted); font-weight: 400; }
.varbar.add .v { color: #4338ca; }
.varbar.dom .v { color: #be185d; }

/* Image panels in trait detail */
.section { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 1.2rem 1.5rem; margin-bottom: 1.2rem; }
.section > h2 { margin: 0 0 .4rem; font-size: 1.2rem; display: flex; align-items: center; gap: .5rem; }
.section > .desc { color: var(--muted); font-size: .9rem; margin-bottom: 1rem; }
.section .img-grid { display: grid; gap: 1rem; }
.section .img-grid.cols-1 { grid-template-columns: 1fr; }
.section .img-grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.section .img-panel { display: flex; flex-direction: column; }
.section .img-panel .img-label { font-size: .85rem; color: var(--muted); margin-bottom: .35rem; }
.section .img-panel img { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--border); background: #fff; cursor: zoom-in; }
.section .img-panel.missing img { display: none; }
.section .img-panel.missing::after { content: "无可用图片"; color: var(--muted); padding: 2rem; background: #f8fafc; border: 1px dashed var(--border); border-radius: 8px; text-align: center; }

/* QTL section */
table.qtl { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.qtl thead { background: #f1f5f9; }
table.qtl thead th { padding: .5rem .65rem; text-align: left; font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.qtl tbody td { padding: .5rem .65rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.type-tag { display: inline-block; padding: .12rem .55rem; border-radius: 4px; font-size: .76rem; font-weight: 600; }

/* Modal for image zoom */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.85);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 2rem;
}
.modal-backdrop.open { display: flex; }
.modal-backdrop img { max-width: 100%; max-height: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.5); border-radius: 6px; background: #fff; }
.modal-close { position: absolute; top: 1rem; right: 1.5rem; color: #fff; font-size: 2rem; cursor: pointer; background: none; border: 0; }

footer { margin-top: 3rem; padding: 2rem 1.5rem; background: var(--pri); color: #cbd5e1; font-size: .88rem; }
footer .footer-inner { max-width: 1280px; margin: 0 auto; }
footer a { color: #93c5fd; }

/* Responsive */
@media (max-width: 768px) {
  .navbar-inner { flex-wrap: wrap; gap: 1rem; }
  .navbar nav { margin-left: 0; gap: .8rem; }
  .hero h1 { font-size: 1.6rem; }
  .toolbar { grid-template-columns: 1fr; }
  table.data thead th { padding: .5rem; font-size: .85rem; }
  table.data tbody td { padding: .45rem .5rem; }
  .desc-cell { display: none; }
}

.loading { padding: 2rem; text-align: center; color: var(--muted); }
.empty { padding: 3rem; text-align: center; color: var(--muted); }
