/* CellNucleus.com — Atlas of Mammalian Genome & Nuclear Organization Models */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #0369a1;
  --primary-soft: #e0f2fe;
  --crimson: #be123c;
  --crimson-soft: #ffe4e6;
  --emerald: #047857;
  --emerald-soft: #d1fae5;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

/* Top Navigation */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1380px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.02rem;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 38%, #38bdf8 0%, #0369a1 52%, #0f172a 100%);
  border: 2px solid #f59e0b;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.22);
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  font-size: 0.85rem;
  font-weight: 600;
}

.nav-links a { color: var(--ink-2); }
.nav-links a:hover { color: var(--primary); text-decoration: none; }

/* Hero */
.hero {
  background: linear-gradient(180deg, #0f172a 0%, #162238 100%);
  color: #f8fafc;
  padding: 48px 24px 44px;
  border-bottom: 1px solid #1e293b;
}

.hero-inner {
  max-width: 1380px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 32px;
  align-items: center;
}

@media (max-width: 900px) {
  .hero-inner { grid-template-columns: 1fr; }
}

.hero-kicker {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.hero h1 {
  margin: 0 0 14px;
  font-family: var(--font-serif);
  font-size: clamp(1.85rem, 3.2vw, 2.75rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.hero p.lead {
  margin: 0 0 22px;
  color: #cbd5e1;
  font-size: 1rem;
  max-width: 68ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary {
  background: #0284c7;
  color: #ffffff;
}
.btn-primary:hover { background: #0369a1; text-decoration: none; }

.btn-ghost {
  background: rgba(255,255,255,0.08);
  color: #e2e8f0;
  border-color: rgba(255,255,255,0.18);
}
.btn-ghost:hover { background: rgba(255,255,255,0.16); text-decoration: none; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 16px 18px;
}

.stat-num {
  font-family: var(--font-mono);
  font-size: 1.7rem;
  font-weight: 700;
  color: #38bdf8;
  line-height: 1.1;
}

.stat-label {
  font-size: 0.78rem;
  color: #cbd5e1;
  margin-top: 4px;
}

/* Main Sections */
.container {
  max-width: 1380px;
  margin: 0 auto;
  padding: 36px 24px;
}

.section-head {
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}

.section-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.65rem;
  letter-spacing: -0.02em;
}

.section-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 75ch;
}

/* Interactive Simulations Section */
.sim-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.sim-tab {
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 8px 13px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sim-tab:hover { border-color: var(--primary); color: var(--primary); }
.sim-tab.active {
  background: var(--ink);
  color: #ffffff;
  border-color: var(--ink);
}

.embed-box {
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
}

.embed-box summary {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
}

.embed-code-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.code-card pre {
  margin: 6px 0 0;
  padding: 10px 12px;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.code-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
}

.copy-btn {
  background: var(--surface-alt);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink-2);
}
.copy-btn:hover { background: var(--primary-soft); color: var(--primary); }

/* Filters & Table Controls */
.toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.search-input {
  flex: 1;
  min-width: 240px;
  padding: 9px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 0.88rem;
  font-family: var(--font-sans);
  color: var(--ink);
}

.search-input:focus {
  outline: 2px solid rgba(3, 105, 161, 0.25);
  border-color: var(--primary);
}

.select-input {
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 0.84rem;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
}

.pill-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  background: var(--surface-alt);
  color: var(--ink-2);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}
.pill:hover { background: #e2e8f0; }
.pill.active { background: var(--primary); color: #ffffff; }

/* Comprehensive Model Table */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-x: auto;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

table.models-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  min-width: 1080px;
}

table.models-table thead th {
  position: sticky;
  top: 0;
  background: #f1f5f9;
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
  padding: 12px 14px;
  border-bottom: 2px solid var(--border-strong);
}

table.models-table tbody tr {
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

table.models-table tbody tr:hover {
  background: #f8fafc;
}

table.models-table td {
  padding: 14px;
}

.col-model { width: 19%; }
.col-concept { width: 25%; }
.col-assump { width: 17%; }
.col-limit { width: 18%; }
.col-pubs { width: 21%; }

.model-idx {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}

.model-name {
  font-weight: 700;
  color: var(--ink);
  font-size: 0.90rem;
  margin: 2px 0 6px;
  line-height: 1.3;
}

.tag {
  display: inline-block;
  font-size: 0.70rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  margin: 2px 4px 2px 0;
}

.tag-cat { background: var(--primary-soft); color: var(--primary); }
.tag-scale { background: var(--surface-alt); color: var(--ink-2); font-family: var(--font-mono); }
.tag-pd { background: var(--emerald-soft); color: var(--emerald); }
.tag-cc { background: var(--amber-soft); color: var(--amber); }

.math-chip {
  margin-top: 8px;
  padding: 6px 9px;
  background: #f8fafc;
  border-left: 3px solid var(--primary);
  border-radius: 0 6px 6px 0;
  font-family: var(--font-mono);
  font-size: 0.73rem;
  color: #0f172a;
  overflow-wrap: anywhere;
}

.mammal-note {
  margin-top: 8px;
  font-size: 0.77rem;
  color: var(--muted);
  border-top: 1px dashed var(--border);
  padding-top: 6px;
}
.mammal-note strong { color: var(--ink-2); }

.model-thumb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  flex-wrap: wrap;
}

.thumb-button, .img-card-media {
  border: 0;
  padding: 0;
  background: transparent;
}

.mini-thumb {
  display: block;
  width: 52px;
  height: 38px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  cursor: pointer;
  background: #0f172a;
}

.sim-jump-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #0f172a;
  color: #38bdf8;
  border: none;
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}
.sim-jump-btn:hover { background: #1e293b; text-decoration: none; }

.pub-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pub-item {
  font-size: 0.78rem;
  line-height: 1.35;
}

.pub-cite-count {
  font-family: var(--font-mono);
  font-size: 0.69rem;
  color: var(--muted);
  margin-left: 4px;
}

.pub-sub {
  display: block;
  font-size: 0.71rem;
  color: var(--muted);
}

/* Public Domain & Open-License Image Gallery */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(265px, 1fr));
  gap: 16px;
}

.img-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.img-card-media {
  width: 100%;
  height: 175px;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
}

.img-card-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #ffffff;
  padding: 6px;
}

.img-card-media.dark-bg img {
  background: #060a14;
  padding: 0;
}

.img-card-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.img-card-title {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink);
  line-height: 1.3;
}

.img-card-meta {
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.4;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.86);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.lightbox.open { display: flex; }

.lightbox-card {
  background: #ffffff;
  color: var(--ink);
  max-width: 920px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 14px;
  padding: 20px;
  position: relative;
}

.lightbox-card img {
  max-width: 100%;
  max-height: 62vh;
  display: block;
  margin: 0 auto 14px;
  border-radius: 8px;
  background: #f8fafc;
}

.lightbox-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: var(--ink);
  color: #ffffff;
  border: none;
  border-radius: 999px;
  width: 30px;
  height: 30px;
  font-size: 1rem;
  cursor: pointer;
}

/* Bibliography & Footer */
.bib-grid {
  columns: 2;
  column-gap: 28px;
  font-size: 0.80rem;
}
@media (max-width: 900px) { .bib-grid { columns: 1; } }

.bib-entry {
  break-inside: avoid;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

footer {
  background: #0f172a;
  color: #94a3b8;
  padding: 32px 24px;
  margin-top: 48px;
  font-size: 0.82rem;
}

footer .footer-inner {
  max-width: 1380px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 18px;
}

footer a { color: #38bdf8; }
