/* ============================================================
   Parcenomics — Stockbridge Profile
   Shared stylesheet for landing + per-chapter pages
   ============================================================ */

:root {
  --bg:        #0B1512;
  --surface:   #111D17;
  --surface-2: #16241D;
  --accent:    #4ADE80;
  --accent-2:  #22C55E;
  --text:      #E2F0E8;
  --text-soft: #C9DBD0;
  --muted:     #6B9E7C;
  --muted-2:   #4F7860;
  --border:    #1E3329;
  --border-2:  #2A4435;

  --serif:     'Fraunces', Georgia, 'Times New Roman', serif;
  --sans:      'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono:      'IBM Plex Mono', 'Courier New', monospace;

  --sidebar-w: 17rem;
  --topbar-h:  3.75rem;
  --max-content-w: 46rem;
  --gutter:    1.5rem;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 1rem); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 0.2em; }

/* ── Top bar (site-level) ─────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: rgba(11, 21, 18, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  height: 100%;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  max-width: 90rem;
  margin: 0 auto;
}
.topbar-brand {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.3rem;
  color: var(--text);
  letter-spacing: -0.01em;
}
.topbar-brand:hover { color: var(--accent); text-decoration: none; }
.topbar-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  font-size: 0.92rem;
}
.topbar-links a { color: var(--text-soft); font-weight: 500; }
.topbar-links a:hover { color: var(--accent); text-decoration: none; }
.topbar-cta {
  background: var(--accent);
  color: var(--bg) !important;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  font-weight: 600;
}
.topbar-cta:hover { background: var(--accent-2); text-decoration: none; }

/* Sidebar toggle (mobile only) */
.sidebar-toggle {
  display: none;
  background: none;
  border: 0;
  color: var(--text);
  cursor: pointer;
  padding: 0.5rem;
  flex-direction: column;
  gap: 4px;
  width: 2.5rem;
  height: 2.5rem;
  align-items: center;
  justify-content: center;
}
.sidebar-toggle span {
  display: block;
  width: 1.4rem;
  height: 2px;
  background: var(--text);
  transition: transform 200ms, opacity 200ms;
}
.sidebar-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.sidebar-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.sidebar-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ── Layout ──────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  max-width: 90rem;
  margin: 0 auto;
  min-height: calc(100vh - var(--topbar-h));
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.sidebar-inner {
  position: sticky;
  top: var(--topbar-h);
  padding: 2rem 1.5rem;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.sidebar-header { padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.sidebar-eyebrow {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.3rem;
  font-weight: 500;
}
.sidebar-meta {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0;
}
.sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1;
}
.sidebar-nav li { margin: 0; }
.sidebar-nav a {
  display: block;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  color: var(--text-soft);
  font-weight: 500;
  border-radius: 6px;
  border-left: 3px solid transparent;
  transition: background 120ms, color 120ms, border-color 120ms;
  text-decoration: none;
}
.sidebar-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}
.sidebar-nav li.active a {
  background: var(--surface-2);
  color: var(--accent);
  border-left-color: var(--accent);
}
.sidebar-footer { padding-top: 1rem; border-top: 1px solid var(--border); }
.sidebar-pdf {
  display: block;
  text-align: center;
  background: var(--accent);
  color: var(--bg);
  padding: 0.7rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.88rem;
}
.sidebar-pdf:hover { background: var(--accent-2); text-decoration: none; }

/* ── Content area ────────────────────────────────────────── */
.content {
  padding: 2rem var(--gutter) 4rem;
  min-width: 0; /* prevent grid blowout on long content */
}
.content--chapter,
.content--landing { display: flex; flex-direction: column; }

.chapter,
.content--landing > * {
  width: 100%;
  max-width: var(--max-content-w);
  margin-left: auto;
  margin-right: auto;
}

/* ── Hero (landing only) ─────────────────────────────────── */
.hero {
  padding: 1rem 0 1.5rem;
  max-width: none !important;
}
.hero-eyebrow {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
}
.hero h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 4.5vw, 3.2rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 0.6rem;
  color: var(--text);
}
.hero-sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.05rem, 1.6vw, 1.25rem);
  color: var(--muted);
  margin: 0 0 1.5rem;
  max-width: 50rem;
}
.hero-cover {
  width: 100%;
  max-height: 22rem;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.anchor-paragraphs {
  max-width: none !important;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin: 2rem 0;
}
@media (max-width: 900px) {
  .anchor-paragraphs { grid-template-columns: 1fr; gap: 1.5rem; }
}
.anchor-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.8rem 1.8rem 1.5rem;
}
.anchor-card h2 {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1rem;
  font-weight: 500;
}
.anchor-card p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-soft);
}
.anchor-card p strong { color: var(--text); font-weight: 600; }

.cta-row {
  max-width: none !important;
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
  align-items: center;
  margin: 0 0 3rem;
}
.pdf-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--accent);
  color: var(--bg);
  padding: 0.85rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.98rem;
}
.pdf-btn:hover { background: var(--accent-2); text-decoration: none; }
.cta-secondary {
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 500;
}
.cta-secondary:hover { color: var(--accent); text-decoration: none; }

/* ── Chapter index grid (landing) ────────────────────────── */
.chapter-index { max-width: none !important; }
.ci-eyebrow {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.5rem;
}
.ci-title {
  font-family: var(--serif);
  font-size: 1.8rem;
  font-weight: 500;
  margin: 0 0 0.8rem;
  letter-spacing: -0.01em;
}
.ci-lede {
  color: var(--text-soft);
  max-width: 40rem;
  margin: 0 0 2rem;
}
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: 1rem;
}
.chapter-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.4rem 1.4rem 1.6rem;
  color: var(--text);
  position: relative;
  transition: border-color 120ms, transform 120ms;
}
.chapter-card:hover {
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-2px);
}
.cc-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.6rem;
  font-weight: 500;
}
.cc-desc {
  font-family: var(--sans);
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-soft);
  margin: 0 0 1rem;
}
.cc-arrow {
  position: absolute;
  bottom: 1rem;
  right: 1.2rem;
  color: var(--muted);
  font-size: 1.2rem;
  transition: color 120ms, transform 120ms;
}
.chapter-card:hover .cc-arrow { color: var(--accent); transform: translateX(3px); }

/* ── Chapter typography ──────────────────────────────────── */
.chapter-title {
  font-family: var(--serif);
  font-size: clamp(1.9rem, 3.5vw, 2.6rem);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0 0 2rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
  line-height: 1.15;
}
.chapter h2 {
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 500;
  margin: 2.5rem 0 1rem;
  letter-spacing: -0.005em;
  color: var(--text);
}
.chapter p {
  margin: 0 0 1.2rem;
  color: var(--text-soft);
}
.chapter p strong { color: var(--text); font-weight: 600; }
.chapter ul, .chapter ol { padding-left: 1.4rem; margin: 0 0 1.4rem; color: var(--text-soft); }
.chapter ul li, .chapter ol li { margin-bottom: 0.5rem; }

/* Charts */
.chart {
  margin: 2rem 0;
  padding: 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.chart img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
}
.chart figcaption {
  margin-top: 0.9rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* Tables */
.table-wrap {
  margin: 2rem 0;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.table-wrap caption {
  caption-side: top;
  padding: 1rem 1.2rem 0.4rem;
  text-align: left;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.table-wrap th, .table-wrap td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.table-wrap th {
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  font-size: 0.85rem;
}
.table-wrap td { color: var(--text-soft); }
.table-wrap tr:last-child td { border-bottom: 0; }

/* Quote */
blockquote {
  margin: 2rem 0;
  padding: 1.2rem 1.5rem;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--text);
}

/* Key findings */
.key-findings {
  margin: 3rem 0 1rem;
  padding: 1.6rem 1.8rem;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
}
.key-findings h3 {
  margin: 0 0 0.8rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
}
.key-findings p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.96rem;
  line-height: 1.7;
}

/* Equation */
.equation {
  margin: 1.5rem 0;
  padding: 1rem 1.2rem;
  background: var(--surface);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--text);
  overflow-x: auto;
  text-align: center;
}

/* ── Footnotes ───────────────────────────────────────────── */
.fn-marker { line-height: 0; }
.fn-link {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.7em;
  padding: 0 0.15em;
  border-radius: 3px;
  position: relative;
  cursor: pointer;
}
.fn-link:hover { background: var(--surface-2); text-decoration: none; }

/* Desktop hover sidenote */
@media (min-width: 1100px) {
  .fn-link::after {
    content: attr(data-fn-text);
    position: absolute;
    bottom: calc(100% + 0.5em);
    left: 50%;
    transform: translateX(-50%);
    width: 22rem;
    max-width: 22rem;
    padding: 0.9rem 1.1rem;
    background: var(--surface-2);
    border: 1px solid var(--border-2);
    border-radius: 6px;
    color: var(--text-soft);
    font-family: var(--sans);
    font-size: 0.85rem;
    line-height: 1.55;
    font-weight: 400;
    letter-spacing: normal;
    text-transform: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 120ms;
    pointer-events: none;
    z-index: 200;
    text-align: left;
    white-space: normal;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  }
  .fn-link:hover::after, .fn-link:focus::after {
    opacity: 1;
    visibility: visible;
  }
}
@media (max-width: 1099px) {
  .fn-link {
    background: var(--surface-2);
    padding: 0.1em 0.35em;
  }
}

.chapter-footnotes {
  margin: 4rem 0 2rem;
  padding: 1.5rem 1.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.chapter-footnotes h2 {
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1.2rem;
  font-weight: 500;
  border: none;
  padding: 0;
}
.footnote-list {
  margin: 0;
  padding-left: 2rem;
  font-size: 0.86rem;
  color: var(--text-soft);
  line-height: 1.6;
}
.footnote-list li { margin-bottom: 0.8rem; }
.footnote-list li:target {
  background: var(--surface-2);
  padding: 0.5rem;
  border-radius: 4px;
  border-left: 3px solid var(--accent);
}
.fn-backref { color: var(--muted); margin-left: 0.3em; font-size: 1.1em; }
.fn-backref:hover { color: var(--accent); }

/* ── Prev/next ───────────────────────────────────────────── */
.prev-next {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 4rem 0 0;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  max-width: var(--max-content-w);
  margin-left: auto;
  margin-right: auto;
}
.prev-next-link {
  display: flex;
  flex-direction: column;
  padding: 1.2rem 1.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  transition: border-color 120ms;
}
.prev-next-link:hover { border-color: var(--accent); text-decoration: none; }
.prev-next-link.next { text-align: right; align-items: flex-end; }
.pn-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.4rem;
}
.pn-title {
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--text);
  line-height: 1.3;
}

/* ── Footer ──────────────────────────────────────────────── */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 3rem var(--gutter) 2rem;
}
.footer-inner {
  max-width: 72rem;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 2rem;
}
.footer h4 {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.8rem;
  font-weight: 500;
}
.footer p, .footer ul { margin: 0; color: var(--text-soft); font-size: 0.9rem; line-height: 1.7; }
.footer ul { padding-left: 0; list-style: none; }
.footer ul li { margin-bottom: 0.4rem; }
.footer-bottom {
  max-width: 72rem;
  margin: 2rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  letter-spacing: 0.04em;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .topbar-links { display: none; }
  .sidebar-toggle { display: flex; }
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: min(20rem, 85vw);
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 240ms cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-inner { height: calc(100vh - var(--topbar-h)); padding: 1.5rem 1.2rem; }
  body.sidebar-open { overflow: hidden; }
  body.sidebar-open::after {
    content: '';
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 89;
  }
  .footer-inner { grid-template-columns: 1fr; gap: 1.5rem; }
  .prev-next { grid-template-columns: 1fr; }
  .prev-next-link.next { text-align: left; align-items: flex-start; }
}

@media (min-width: 901px) and (max-width: 1100px) {
  .topbar-links { gap: 1rem; font-size: 0.85rem; }
  :root { --sidebar-w: 14rem; }
}

/* Print */
@media print {
  .topbar, .sidebar, .prev-next, .footer { display: none; }
  .layout { display: block; }
  body { background: white; color: black; }
  .chart, .table-wrap, .key-findings, blockquote { border-color: #ccc; background: white; }
}
