/* ── Stacks theme — gitbook overrides ────────────────────────────── */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --stacks-accent:    #089488;
  --stacks-accent-hi: #067a70;
  --stacks-text:      #1a1a1a;
  --stacks-body:      #3d3d3d;
  --stacks-muted:     #8a8a8a;
  --stacks-border:    #ececec;
  --stacks-border-lt: #f3f3f3;
  --stacks-bg:        #ffffff;
}

/* ── Body / typography ───────────────────────────────────────────── */
/* gitbook sets html { font-size: 10px } which makes every rem-based rule
   undershoot. Force the root back to browser default so our px rules and
   gitbook's rem rules both land at reasonable sizes. */
html {
  font-size: 16px !important;
}

html,
body,
.book,
.book-body,
.page-inner,
.book-summary {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  color: var(--stacks-body);
  -webkit-font-smoothing: antialiased;
}

.book-body {
  background: #ffffff;
}

.markdown-section {
  font-size: 16px !important;
  line-height: 1.7 !important;
  color: var(--stacks-body);
  max-width: 760px;
  padding: 40px 32px 64px;
}

.markdown-section p,
.markdown-section li,
.markdown-section ul,
.markdown-section ol {
  font-size: 16px !important;
}

/* Dataset label above page title */
.markdown-section .dataset-label {
  color: var(--stacks-accent);
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0;
  border: none;
}

.markdown-section h1 {
  color: var(--stacks-text);
  font-weight: 700;
  text-transform: lowercase;
  letter-spacing: -0.015em;
  font-size: 2rem;
  border-bottom: none;
  margin: 0 0 1.2em;
}

.markdown-section h2 {
  color: var(--stacks-text);
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: 2.6em;
  margin-bottom: 0.8em;
  padding-bottom: 0;
  border-bottom: none;
}

.markdown-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--stacks-text);
  margin-top: 1.8em;
}

.markdown-section p {
  margin: 0 0 1em;
}

.markdown-section a {
  color: var(--stacks-accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(8, 148, 136, 0.25);
}

.markdown-section a:hover,
.markdown-section a:focus {
  color: var(--stacks-accent-hi);
  border-bottom-color: var(--stacks-accent-hi);
}

.markdown-section blockquote {
  border-left: 2px solid var(--stacks-border);
  color: var(--stacks-muted);
  padding: 0.2em 1em;
  margin: 1.2em 0;
}

/* ── Left summary (navigation) ───────────────────────────────────── */
.book-summary {
  background: #ddd;
  border-right: 1px solid var(--stacks-border);
  width: 25vw;
  min-width: 350px;
  max-width: 450px;
  padding: 0 5vw;
  font-family: "Inter var", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
}

@media (min-width: 769px) {
  .book-summary {
    left: 0 !important;
    transform: none !important;
  }

  .book-body {
    left: clamp(350px, 25vw, 450px) !important;
  }
}

/* Logo — inserted by JS above the search box */
.book-summary::before {
  display: none;
}

a.stacks-logo-link {
  display: block;
  height: 38px;
  margin-top: 50px;
  background: url("../assets/stacks-logo.png") no-repeat left center;
  background-size: contain;
  border: none !important;
}

.book-summary ul.summary {
  padding: 0 0 50px;
}

/* Search box */
#book-search-input {
  padding: 40px 0 20px 0;
  border: none;
  background: #ddd;
}

#book-search-input input,
#book-search-input input:focus {
  background: #fafafa;
  border: 1px solid var(--stacks-border);
  border-radius: 6px;
  font-size: 14px !important;
  padding: 8px 12px;
  box-shadow: none;
  color: var(--stacks-body);
  max-width: 250px;
}

#book-search-input input::placeholder {
  color: var(--stacks-muted);
}

/* Hide gitbook's "results matching" / "No results matching" headings.
   Note: .search-noresults wraps the actual page content when not searching,
   so only hide the titles, not the container. */
#book-search-results .search-results-title {
  display: none !important;
}

/* Hide the text site-name link (we render a logo link instead via footer.js) */
.book-summary ul.summary li > a.custom-link {
  display: none;
}

/* Hide dividers, Welcome link, and MkDocs/GitBook attribution links */
.book-summary ul.summary li.divider {
  display: none;
}

/* Custom section divider (inserted via '---' entry in nav) */
.book-summary ul.summary li.nav-divider {
  height: 1px;
  background: #434c4b;
  margin: 32px 0 16px;
  list-style: none;
}

.book-summary ul.summary > li > a[href^="http"] {
  display: none;
}

.book-summary ul.summary > li.chapter[data-path=""] {
  display: none;
}

/* Nav items */
.book-summary ul.summary li {
  list-style: none;
}

/* Page links: bold, #0d1111, 16px */
.book-summary ul.summary li a,
.book-summary ul.summary li span {
  color: #0d1111;
  font-size: 16px !important;
  font-weight: 700;
  padding: 6px 0;
  border-radius: 4px;
  line-height: 1.5;
}

.book-summary ul.summary li a:hover {
  color: #08968a;
  background: transparent;
  text-decoration: none;
}

/* Selected / active page link */
.book-summary ul.summary li.active > a {
  color: #08968a !important;
  font-weight: 700;
  background: transparent;
}

/* Dataset headers (Campaign Finance, Context, etc.) — bold, not links */
.book-summary ul.summary li.header {
  color: #0d1111 !important;
  font-weight: 700 !important;
  font-size: 16px !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  padding: 20px 0 6px !important;
  cursor: default;
}

/* Table links (bare <li> without a class, rendered after li.header) */
.book-summary ul.summary > li:not(.header):not(.chapter):not(.divider):not(.nav-divider) > a {
  font-size: 14px !important;
  color: #434c4b;
  font-weight: 400 !important;
  font-family: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  padding: 4px 0;
}

.book-summary ul.summary > li:not(.header):not(.chapter):not(.divider):not(.nav-divider) > a:hover {
  color: #08968a;
}

.book-summary ul.summary > li:not(.header):not(.chapter):not(.divider):not(.nav-divider) > a.active {
  color: #08968a !important;
  font-weight: 600 !important;
}

/* Remove gitbook's folder triangles / expand icons */
.book-summary ul.summary li.chapter > a.expanded::before,
.book-summary ul.summary li.chapter > a::before,
.book-summary ul.summary li .summary > li > a::before {
  display: none !important;
}


/* ── Tables ──────────────────────────────────────────────────────── */
.markdown-section table {
  border: none;
  border-collapse: collapse;
  width: 100%;
  font-size: 14px !important;
  display: table;
  margin: 1em 0 1.6em;
}

.markdown-section table th,
.markdown-section table td {
  font-size: 14px !important;
}

.markdown-section table th {
  background: transparent;
  color: var(--stacks-text);
  font-weight: 600;
  border: none;
  border-bottom: 1px solid var(--stacks-border);
  padding: 0.7em 1em 0.7em 0;
  text-align: left;
}

.markdown-section table td {
  border: none;
  border-top: 1px solid var(--stacks-border-lt);
  padding: 0.8em 1em 0.8em 0;
  color: var(--stacks-body);
  vertical-align: top;
}

.markdown-section table tr {
  background: transparent !important;
  border: none;
}

.markdown-section table td:first-child {
  color: var(--stacks-text);
  font-weight: 600;
  padding-right: 1.8em;
}

/* ── Code ────────────────────────────────────────────────────────── */
.markdown-section code {
  color: var(--stacks-accent);
  background: #f5f5f5;
  border: none;
  border-radius: 4px;
  padding: 0.12em 0.4em;
  font-size: 0.85em;
  font-family: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}

.markdown-section pre {
  background: #fafafa;
  border: 1px solid var(--stacks-border);
  border-radius: 6px;
  padding: 1em;
}

.markdown-section pre > code {
  border: none;
  color: var(--stacks-text);
  background: transparent;
  padding: 0;
}

/* ── Page header / top bar ───────────────────────────────────────── */
.book-header {
  background: #ffffff;
  border-bottom: 1px solid var(--stacks-border);
  box-shadow: none;
  min-height: 0;
  height: 0;
  padding: 0;
}

.book-header h1 {
  display: none;
}

.book-header .btn,
.book-header .js-toolbar-action {
  display: none !important;
}

/* ── Mobile ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .book-summary {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 85vw !important;
    max-width: 360px;
    height: 100vh !important;
    padding-left: 2em !important;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto !important;
  }

  .book-summary.stacks-open {
    transform: translateX(0);
  }

  .book-body {
    left: 0 !important;
    position: relative !important;
  }

  .book-header {
    height: auto !important;
    padding: 0 !important;
    border: none !important;
  }

  .stacks-hamburger {
    display: block !important;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1001;
    background: #fff;
    border: 1px solid var(--stacks-border);
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    line-height: 0;
  }

  .stacks-hamburger svg {
    width: 20px;
    height: 20px;
    display: block;
  }

  .stacks-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 999;
  }

  .stacks-overlay.stacks-open {
    display: block;
  }

  .page-wrapper {
    padding-top: 48px;
  }

  .navigation {
    width: 42% !important;
  }
}

/* Hide mobile-only elements on desktop */
@media (min-width: 769px) {
  .stacks-hamburger,
  .stacks-overlay {
    display: none !important;
  }
}

/* ── Prev / next pager at bottom ─────────────────────────────────── */
.navigation {
  background: transparent;
  color: var(--stacks-muted);
  border: 1px solid var(--stacks-border);
  border-radius: 6px;
  width: 45% !important;
  height: auto !important;
  line-height: 1.4 !important;
  padding: 1em 1.2em !important;
  top: auto !important;
  margin-top: 3rem;
  font-size: 0.85rem;
  opacity: 1 !important;
}

.navigation:hover {
  border-color: var(--stacks-accent);
  color: var(--stacks-accent) !important;
  text-decoration: none;
}

.navigation-prev {
  left: 2rem !important;
  text-align: left;
}

.navigation-next {
  right: 2rem !important;
  text-align: right;
}

.navigation::before {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--stacks-muted);
  margin-bottom: 0.25em;
  font-weight: 600;
}

.navigation-prev::before { content: "← Previous"; }
.navigation-next::before { content: "Next →"; }

/* Hide gitbook's default chevron icons on the pager */
.navigation .fa {
  display: none !important;
}

/* ── Footer (Docs powered by …) ──────────────────────────────────── */
.page-inner {
  padding: 0 2em 3em 2em;
}

.stacks-footer {
  max-width: 720px;
  margin: 4rem 2rem 2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--stacks-border);
  font-size: 0.75rem;
  color: var(--stacks-muted);
  text-align: center;
}
