/* ============================================================
   Heart Cell Atlas — shared v2 design system
   Used by: index-v2.html, foetal-v2.html, v1-v2.html
   Page-specific overrides are scoped under .page-* body classes.
   ============================================================ */

:root {
  --bg: #fbfbfd;
  --surface: #ffffff;
  --text: #1f2230;
  --text-muted: #5b6071;
  --border: #e6e8ef;
  --accent: #b3163a;        /* heart red */
  --accent-soft: #fbe7ec;
  --teal: #0f766e;
  --indigo: #2a2737;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 1px rgba(15,23,42,.04);
  --shadow-md: 0 6px 20px rgba(15,23,42,.08);
  --shadow-lg: 0 20px 50px rgba(15,23,42,.12);
  --radius: 12px;
  --radius-sm: 8px;
  --max-w: 1200px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal); text-decoration: none; transition: opacity .15s; }
a:hover { opacity: .75; text-decoration: underline; }

/* ---------- Icons: CSS-mask sprites (SVG path data lives here, not in HTML) ---------- */
.mi {
  width: 1em; height: 1em;
  display: inline-block; vertical-align: middle; flex-shrink: 0;
  background-color: currentColor;
  -webkit-mask: var(--mi) center / contain no-repeat;
          mask: var(--mi) center / contain no-repeat;
}
.ic-article { --mi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-5 14H7v-2h7v2zm3-4H7v-2h10v2zm0-4H7V7h10v2z'/%3E%3C/svg%3E"); }
.ic-science { --mi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19.8 18.4 14 10.67V6.5l1.35-1.69c.26-.33.03-.81-.39-.81H9.04c-.42 0-.65.48-.39.81L10 6.5v4.17L4.2 18.4c-.49.66-.02 1.6.8 1.6h14c.82 0 1.29-.94.8-1.6z'/%3E%3C/svg%3E"); }
.ic-code { --mi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9.4 16.6 4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0 4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z'/%3E%3C/svg%3E"); }
.ic-download { --mi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 20h14v-2H5v2zM19 9h-4V3H9v6H5l7 7 7-7z'/%3E%3C/svg%3E"); }
.ic-file_download { --mi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z'/%3E%3C/svg%3E"); }
.ic-image { --mi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z'/%3E%3C/svg%3E"); }
.ic-language { --mi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zm6.93 6h-2.95a15.65 15.65 0 0 0-1.38-3.56A8.03 8.03 0 0 1 18.92 8zM12 4.04c.83 1.2 1.48 2.53 1.91 3.96h-3.82c.43-1.43 1.08-2.76 1.91-3.96zM4.26 14C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2 0 .68.06 1.34.14 2H4.26zm.82 2h2.95c.32 1.25.78 2.45 1.38 3.56A7.987 7.987 0 0 1 5.08 16zm2.95-8H5.08a7.987 7.987 0 0 1 4.33-3.56A15.65 15.65 0 0 0 8.03 8zM12 19.96c-.83-1.2-1.48-2.53-1.91-3.96h3.82c-.43 1.43-1.08 2.76-1.91 3.96zM14.34 14H9.66c-.09-.66-.16-1.32-.16-2 0-.68.07-1.35.16-2h4.68c.09.65.16 1.32.16 2 0 .68-.07 1.34-.16 2zm.25 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95a8.03 8.03 0 0 1-4.33 3.56zM16.36 14c.08-.66.14-1.32.14-2 0-.68-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2h-3.38z'/%3E%3C/svg%3E"); }
.ic-open_in_new { --mi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19 19H5V5h7V3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z'/%3E%3C/svg%3E"); }
.ic-pageview { --mi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11.5 9a2.5 2.5 0 0 0 0 5 2.5 2.5 0 0 0 0-5zM20 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-3.21 14.21-2.91-2.91c-.69.44-1.51.7-2.39.7C9.01 16 7 13.99 7 11.5S9.01 7 11.5 7 16 9.01 16 11.5c0 .88-.26 1.69-.7 2.39l2.91 2.9-1.42 1.42z'/%3E%3C/svg%3E"); }

/* ---------- Navbar ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--max-w); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 24px;
}
.nav-brand img { height: 56px; display: block; }
.nav-links { display: flex; gap: 8px; list-style: none; margin: 0; padding: 0; }
.nav-links a {
  color: var(--indigo); font-weight: 500; font-size: 14px;
  padding: 8px 14px; border-radius: 999px;
  transition: background .15s, color .15s;
}
.nav-links a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255,255,255,.0) 0%, rgba(251,251,253,1) 100%),
    url('../images/heart-masthead-bg.jpg') center/cover no-repeat;
  padding: 80px 24px 100px;
  text-align: center;
  /* Fixed height so the `cover` crop is identical across all pages,
     regardless of differing title/subtitle length. */
  min-height: 440px;
  display: flex; flex-direction: column; justify-content: center;
}
.hero h1 {
  font-family: 'Raleway', sans-serif;
  font-weight: 700;
  /* Sized so the longest title ("Developing Heart Cell Atlas") stays on
     one line, keeping the title identical across all pages. */
  font-size: clamp(2.2rem, 5.5vw, 4.4rem);
  letter-spacing: .05em;
  color: var(--indigo);
  margin: 0 0 12px;
}
.hero .sub {
  color: var(--text); font-size: 1.05rem; font-weight: 500;
  max-width: 640px; margin: 0 auto;
  text-shadow: 0 1px 2px rgba(255,255,255,.9), 0 0 14px rgba(255,255,255,.65);
}
.hero-badges {
  margin-top: 28px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap;
}
.badge {
  background: var(--surface); border: 1px solid var(--border);
  padding: 8px 16px; border-radius: 999px; font-size: 13px;
  box-shadow: var(--shadow-sm); color: var(--text);
}
.badge strong { color: var(--accent); }

/* ---------- Layout ---------- */
.layout {
  max-width: var(--max-w); margin: 0 auto;
  display: grid; grid-template-columns: 1fr 220px; gap: 48px;
  padding: 48px 24px;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 32px 16px; gap: 24px; }
  .toc { display: none; }
}

/* ---------- TOC (sticky sidebar) ---------- */
.toc {
  position: sticky; top: 84px; align-self: start;
  max-height: calc(100vh - 100px); overflow-y: auto;
}
.toc h6 {
  text-transform: uppercase; font-size: 11px; letter-spacing: .1em;
  color: var(--text-muted); margin: 0 0 8px; padding-left: 12px;
}
.toc ul { list-style: none; padding: 0; margin: 0; border-left: 1px solid var(--border); }
.toc li a {
  display: block; padding: 6px 12px; font-size: 14px;
  color: var(--text-muted); border-left: 2px solid transparent;
  margin-left: -1px; transition: all .15s;
}
.toc li a:hover { color: var(--text); text-decoration: none; }
.toc li a.active {
  color: var(--accent); border-left-color: var(--accent);
  font-weight: 600; background: var(--accent-soft);
}

/* ---------- Sections ---------- */
.content section { margin-bottom: 64px; scroll-margin-top: 80px; }
.content h2 {
  font-size: 1.75rem; font-weight: 600; margin: 0 0 20px;
  color: var(--indigo); position: relative; padding-bottom: 12px;
}
.content h2::after {
  content: ''; position: absolute; left: 0; bottom: 0;
  width: 48px; height: 3px; background: var(--accent); border-radius: 2px;
}
.content p { margin: 0 0 14px; color: var(--text); }
.content ul { padding-left: 22px; }
.content li { margin: 4px 0; }
.content .cite { color: var(--text-muted); font-style: italic; }

.figure {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-md); overflow: hidden; margin: 20px 0;
}
.figure img { width: 100%; display: block; }
.figure.narrow { max-width: 560px; margin-left: auto; margin-right: auto; }

/* lead paragraph + figure grouped in a card (v1) */
.fig-block {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px; margin: 20px 0;
  box-shadow: var(--shadow-sm);
}
.fig-block p { margin: 0 0 16px; }
.fig-block .figure { margin: 0; box-shadow: none; border-radius: 0; }

mark, .hl {
  background: linear-gradient(180deg, transparent 60%, var(--accent-soft) 60%);
  color: var(--text); padding: 0 2px; font-weight: 500;
}

/* ---------- Info note ---------- */
.note-card {
  background: #f6f7fb; border-left: 3px solid var(--accent);
  padding: 14px 18px; border-radius: var(--radius-sm); margin-top: 16px;
  font-size: 14px; line-height: 1.55; color: var(--text-muted);
}

/* ---------- Collapsible (data section) ---------- */
details.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin: 12px 0; box-shadow: var(--shadow-sm);
  overflow: hidden;
}
details.panel[open] { box-shadow: var(--shadow-md); }
details.panel > summary {
  list-style: none; cursor: pointer;
  padding: 16px 20px; font-weight: 600; color: var(--indigo);
  display: flex; align-items: center; gap: 10px;
  transition: background .15s;
}
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::before {
  content: '\203A'; font-size: 22px; line-height: 1; color: var(--accent);
  transition: transform .2s; display: inline-block;
}
details.panel[open] > summary::before { transform: rotate(90deg); }
details.panel > summary:hover { background: #fafbfd; }
.panel-body { padding: 0 20px 20px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 14px;
  background: var(--surface);
}
table.data th, table.data td {
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--border); vertical-align: top;
}
table.data thead th {
  background: #f6f7fb; font-weight: 600; color: var(--text-muted);
  font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
}
table.data tbody tr:hover { background: #fafbfd; }
table.data td.center, table.data th.center { text-align: center; }
table.data td.dash { text-align: center; color: #c8ccd6; }
table.data .name { font-weight: 600; color: var(--indigo); }
table.data .section-row th {
  background: var(--accent-soft); color: var(--accent);
  text-transform: uppercase; letter-spacing: .05em; font-size: 12px;
}

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  color: var(--teal); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.icon-btn .mi { font-size: 20px; }
.icon-link {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px; border-radius: 6px; font-size: 13px;
  color: var(--teal);
}
.icon-link:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.icon-link .mi { font-size: 16px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 14px;
  background: var(--accent); color: white !important; box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); text-decoration: none; opacity: 1; }
.btn .mi { font-size: 18px; }

/* ---------- Feature cards (summary methods) ---------- */
.feature-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px; margin: 20px 0 4px;
}
.feature-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.feature-card .ft-title {
  font-weight: 600; color: var(--indigo); margin-bottom: 4px;
  display: flex; align-items: baseline; gap: 8px;
}
.feature-card .ft-res {
  font-size: 11px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); padding: 2px 8px; border-radius: 999px;
}
.feature-card p { font-size: 14px; color: var(--text-muted); margin: 0; line-height: 1.55; }

/* ---------- Key figure callout ---------- */
.keystat {
  display: inline-flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  background: var(--accent-soft); border-radius: var(--radius);
  padding: 12px 20px; margin: 18px 0 4px;
}
.keystat-num { font-size: 1.35rem; font-weight: 700; color: var(--accent); line-height: 1.1; }
.keystat-lbl { font-size: 14px; color: var(--text-muted); }

/* ---------- Inline code row ---------- */
.code-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

/* ---------- Visium image grid (index) ---------- */
.visium-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin: 4px 0 16px;
}
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: #eef0f6; color: var(--text-muted); cursor: pointer;
  border: 1px solid transparent; transition: all .15s;
}
.chip:hover { background: var(--accent-soft); color: var(--accent); }
.chip.active { background: var(--accent); color: white; }
.chip-count { opacity: .6; margin-left: 4px; font-weight: 400; }

.visium-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px; margin-top: 16px;
}
.visium-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow-sm); transition: box-shadow .15s, transform .15s;
}
.visium-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.visium-card .thumb {
  width: 100%; aspect-ratio: 1; background: #f0f1f6; border-radius: 6px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.visium-card .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: center; }
.visium-card .meta { display: flex; align-items: center; justify-content: space-between; }
.visium-card .id { font-family: 'SF Mono', Menlo, monospace; font-size: 12px; color: var(--text-muted); }
.region-tag {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); text-transform: uppercase;
}
.region-tag.ffpe { background: #e8eefe; color: #1e40af; }
.visium-card .actions {
  display: flex; gap: 4px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 10px;
}
.visium-card .actions a {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 6px; border-radius: 6px; font-size: 11px; font-weight: 600;
  color: var(--text-muted); background: #f6f7fb;
}
.visium-card .actions a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.visium-card .actions .mi { font-size: 14px; }

/* ---------- Visium interactive sections grouped by stage (foetal) ---------- */
.visium-stage { margin-bottom: 22px; }
.visium-stage:last-child { margin-bottom: 4px; }
.visium-stage-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.visium-stage-head .stage-name { font-weight: 600; color: var(--indigo); font-size: 15px; }
.visium-stage-head .stage-count { font-size: 12px; color: var(--text-muted); }
.visium-stage-head .stage-tag {
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .04em;
  background: #e8eefe; color: #1e40af;
}
.visium-stage-head .stage-tag.t21 { background: #ede8fe; color: #5b21b6; }
.visium-samples { display: flex; flex-wrap: wrap; gap: 8px; }
.sample-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); box-shadow: var(--shadow-sm);
  font-family: 'SF Mono', Menlo, monospace; font-size: 12.5px; color: var(--text);
  transition: all .15s;
}
.sample-pill:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.sample-pill .mi { font-size: 16px; color: var(--teal); }
.sample-pill:hover .mi { color: var(--accent); }

/* ---------- Footer ---------- */
footer { background: #ffffff; border-top: 1px solid var(--border); margin-top: 32px; }
.footer-inner { max-width: var(--max-w); margin: 0 auto; padding: 48px 24px; }
.citation {
  background: #f6f7fb; border-left: 3px solid var(--accent);
  padding: 16px 20px; border-radius: var(--radius-sm);
  font-size: 14px; line-height: 1.55;
}
.citation b { color: var(--indigo); }

.funders-grid {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 24px; align-items: center; margin-top: 16px;
}
.funders-grid a {
  flex: 0 1 230px;
  display: flex; align-items: center; justify-content: center;
  padding: 12px; border-radius: 8px;
  filter: grayscale(.3); opacity: .85; transition: all .2s;
}
.funders-grid a:hover { filter: grayscale(0); opacity: 1; }
.funders-grid img { max-width: 100%; max-height: 60px; }

.team-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-top: 16px;
}
.team-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px; text-align: center; box-shadow: var(--shadow-sm); transition: box-shadow .15s;
}
.team-card:hover { box-shadow: var(--shadow-md); }
.team-card .name { font-weight: 600; color: var(--indigo); margin-bottom: 12px; font-size: 14px; }
.team-card .logo { height: 56px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; overflow: hidden; }
.team-card .logo img { max-height: 56px; max-width: 100%; width: auto; object-fit: contain; }
.team-card .socials { display: flex; gap: 8px; justify-content: center; align-items: center; }
.team-card .socials a { display: inline-flex; }
.team-card .socials img { width: 18px; height: 18px; }
.team-card .socials .site-link .mi { font-size: 20px; color: var(--text); transition: color .15s; }
.team-card .socials .site-link:hover .mi { color: var(--accent); }

.bottom-bar {
  border-top: 1px solid var(--border);
  background: #fafbfd;
  padding: 16px 24px;
  font-size: 13px; color: var(--text-muted);
}
.bottom-bar .inner {
  max-width: var(--max-w); margin: 0 auto;
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px;
}

/* ============================================================
   Page-specific overrides
   ============================================================ */

/* Developing (foetal) — longer title needs a smaller clamp; citations
   lay out as flex rows with a DOI button. */
.page-foetal .hero .sub { max-width: 680px; }
.page-foetal .citation {
  margin-bottom: 16px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.page-foetal .citation .doi { flex-shrink: 0; }
