/* Local Budget Book — Cabarrus County FY 2027 Adopted Budget
   Self-contained styles. No external fonts, frameworks, or CDNs. */

:root {
  --ink: #1b2330;
  --ink-soft: #4a5566;
  --muted: #6b7686;
  --line: #dfe4ec;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --accent: #1f4eae;        /* the budget book's blue */
  --accent-dark: #16307a;
  --accent-soft: #eaf0fb;
  --maxw: 1100px;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20,34,64,.06), 0 6px 18px rgba(20,34,64,.06);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
}

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

.skip {
  position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff;
  padding: .6rem 1rem; border-radius: 0 0 var(--radius) 0; z-index: 100;
}
.skip:focus { left: 0; }

.muted { color: var(--muted); font-size: .9em; }
.eyebrow {
  text-transform: uppercase; letter-spacing: .08em; font-size: .72rem;
  font-weight: 700; color: var(--accent); margin: 0 0 .35rem;
}

/* ---------- header / nav ---------- */
.topbar {
  background: #1a3a6b;
  color: #fff;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 80;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.topbar-brand {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  text-decoration: none;
  color: inherit;
  flex: 0 1 auto;
}
.topbar-brand:hover { text-decoration: none; }
.topbar-brand-main {
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .01em;
}
.topbar-brand-sub {
  color: rgba(255,255,255,.78);
  font-size: .7rem;
  font-weight: 400;
}
.topbar-sep {
  width: 1px;
  height: 28px;
  background: rgba(255,255,255,.2);
  flex: 0 0 auto;
}
.topbar-panel {
  margin-left: auto;
}
.topbar-nav {
  display: flex;
  align-items: center;
  gap: .15rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.topbar-nav a,
.topbar-nav button {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  color: #d8e8ff;
  text-decoration: none;
  font-size: .82rem;
  font-weight: 500;
  padding: .35rem .7rem;
  border-radius: 4px;
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
  font-family: inherit;
}
.topbar-nav a:hover,
.topbar-nav button:hover,
.topbar-nav a.active,
.topbar-nav button.active {
  background: rgba(255,255,255,.15);
  color: #fff;
  text-decoration: none;
}
.topbar-nav a.active,
.topbar-nav button.active {
  background: rgba(255,255,255,.22);
}
.topbar-nav .nav-ico {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  opacity: .85;
}
.topbar-nav .nav-search {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.25);
}
.topbar-nav .nav-search:hover,
.topbar-nav .nav-search.active {
  background: rgba(255,255,255,.22);
  border-color: rgba(255,255,255,.32);
}
.nav-dropdown {
  position: relative;
}
.nav-dropdown-toggle::after {
  content: "\25BE";
  font-size: .7rem;
  opacity: .85;
  margin-left: .15rem;
}
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  width: 640px;
  max-width: calc(100vw - 2rem);
  padding: .6rem .35rem;
  border: 1px solid #d0d8e8;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  z-index: 120;
}
.nav-dropdown.open .nav-dropdown-menu {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .25rem .75rem;
}
.nav-dropdown.open .nav-dropdown-toggle,
.nav-dropdown:hover .nav-dropdown-toggle {
  background: rgba(255,255,255,.15);
  color: #fff;
}
.menu-group {
  padding: .35rem .25rem;
}
.menu-group-title {
  display: block;
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #6a7895;
  font-weight: 700;
  padding: .25rem .6rem;
  margin-bottom: .1rem;
}
.nav-dropdown-menu a {
  display: block;
  color: #1a3a6b;
  font-size: .85rem;
  font-weight: 500;
  padding: .45rem .6rem;
  border-radius: 5px;
  text-decoration: none;
  white-space: normal;
  line-height: 1.25;
}
.nav-dropdown-menu a:hover,
.nav-dropdown-menu a.active {
  background: #eef3fb;
  color: #1a3a6b;
}
.nav-dropdown-menu a.active {
  background: #e1eafb;
}
.menu-item-name {
  display: block;
  font-weight: 600;
  color: #1a3a6b;
}
.menu-item-desc {
  display: block;
  font-size: .73rem;
  color: #6a7895;
  font-weight: 400;
  line-height: 1.3;
  margin-top: .1rem;
}
.nav-dropdown-menu a:hover .menu-item-desc,
.nav-dropdown-menu a.active .menu-item-desc {
  color: #4a6090;
}
@media (hover: hover) and (min-width: 821px) {
  .nav-dropdown:hover .nav-dropdown-menu {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .25rem .75rem;
  }
}
.nav-burger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 36px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,.3);
  background: none;
  color: #fff;
  cursor: pointer;
  flex: 0 0 auto;
}
.nav-burger svg {
  width: 20px;
  height: 20px;
}

/* ---------- layout ---------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 1.6rem 1.1rem 3rem; }

.site-footer { border-top: 1px solid var(--line); background: var(--panel); }
.site-footer p {
  max-width: var(--maxw); margin: 0 auto; padding: 1.2rem 1.1rem;
  color: var(--muted); font-size: .82rem; text-wrap: pretty;
}

h1 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.01em; text-wrap: pretty; }
h2 { font-size: 1.25rem; margin: 2rem 0 .8rem; text-wrap: pretty; }
.lede { font-size: 1.05rem; color: var(--ink-soft); max-width: 86ch; text-wrap: pretty; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block; padding: .6rem 1rem; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-weight: 600; font-size: .92rem; cursor: pointer;
  text-wrap: pretty;
}
.btn:hover { text-decoration: none; border-color: var(--accent); color: var(--accent-dark); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }

/* ---------- hero / home ---------- */
.hero {
  background: linear-gradient(180deg, #fff, var(--accent-soft));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 2.2rem 1.8rem; box-shadow: var(--shadow); margin-bottom: 2rem;
}
.hero h1 { font-size: 2.3rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.2rem; }

.sec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 1rem; }
.sec-card {
  display: flex; flex-direction: column; gap: .25rem; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow); color: var(--ink); border-left: 4px solid var(--accent);
}
.sec-card:hover { text-decoration: none; transform: translateY(-1px); border-left-color: var(--accent-dark); }
.sec-card-pages { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); font-weight: 700; }
.sec-card-title { font-size: 1.1rem; font-weight: 800; text-wrap: pretty; }
.sec-card-blurb { color: var(--ink-soft); font-size: .9rem; text-wrap: pretty; }

/* ---------- home: budget at a glance ---------- */
.overview { margin-bottom: 2.4rem; }
.overview > .lede { margin-bottom: 1.3rem; }
.stat-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 1rem; margin-bottom: 1.4rem;
}
.stat-card {
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow);
}
.stat-value { display: block; font-size: 1.55rem; font-weight: 800; letter-spacing: -.01em; color: var(--ink); }
.stat-label { display: block; color: var(--ink-soft); font-size: .82rem; margin-top: .1rem; line-height: 1.45; text-wrap: pretty; }

.chart-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
  gap: 1rem; margin-bottom: 1.4rem;
}
.chart-card, .fund-block {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.2rem 1.3rem;
}
.fund-block { margin-bottom: 0; }
.chart-card h3, .fund-block h3 { margin: 0 0 .15rem; font-size: 1.05rem; text-wrap: pretty; }
.chart-sub { color: var(--muted); font-size: .82rem; margin: 0 0 1rem; text-wrap: pretty; }

.donut-wrap { display: flex; gap: 1.3rem; align-items: center; flex-wrap: wrap; }
.donut { width: 168px; height: 168px; position: relative; flex: 0 0 auto; }
.donut svg { width: 100%; height: 100%; display: block; }
.donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; pointer-events: none;
}
.donut-center b { font-size: 1.25rem; color: var(--ink); letter-spacing: -.02em; }
.donut-center span { font-size: .64rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 700; }
.legend { flex: 1 1 240px; min-width: 220px; display: flex; flex-direction: column; gap: .42rem; }
.legend-item { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: .55rem; align-items: center; font-size: .82rem; color: var(--ink-soft); }
.legend-item > :nth-child(2) { min-width: 0; text-wrap: pretty; }
.legend-item .sw { width: 12px; height: 12px; border-radius: 3px; }
.legend-item b { color: var(--ink); font-weight: 700; }

.bars { margin-top: 1.1rem; display: flex; flex-direction: column; gap: .65rem; }
.bar-row .bar-meta {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline;
  gap: .35rem .8rem; font-size: .8rem; font-weight: 600; margin-bottom: .25rem; color: var(--ink-soft);
}
.bar-row .bar-meta span:first-child { min-width: 0; text-wrap: pretty; }
.bar-row .bar-meta span:last-child { color: var(--ink); white-space: nowrap; }
.track { height: 9px; background: var(--accent-soft); border-radius: 99px; overflow: hidden; }
.track > i { display: block; height: 100%; border-radius: 99px; }

/* ---------- section pages ---------- */
.section-head { margin-bottom: 1.4rem; }
.subnav {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.15rem 1.3rem 1.25rem; margin-bottom: 1.6rem; box-shadow: var(--shadow);
}
/* "In this section" reads as a polished section label (matching the site's
   eyebrow / nav group-title convention) rather than a plain bold heading. */
.subnav h2 {
  margin: 0 0 .8rem; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--accent);
}
.subnav ul {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: .5rem;
}
.subnav li { margin: 0; min-width: 0; }
/* Each quick link is a tappable tile (like the section cards / dropdown items)
   with a trailing arrow that nudges on hover — the same "jump to" affordance the
   "View the original page →" links use. */
.subnav a {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  padding: .62rem .85rem;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink);
  font-weight: 600; font-size: .92rem; line-height: 1.3;
  text-wrap: pretty;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .15s;
}
.subnav a::after {
  content: "\2192"; flex: 0 0 auto;
  color: var(--accent); font-weight: 700; opacity: .5;
  transition: transform .15s, opacity .15s;
}
.subnav a:hover {
  text-decoration: none; background: var(--accent-soft);
  border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px);
}
.subnav a:hover::after { transform: translateX(3px); opacity: 1; }
.subnav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Readable section content (web text rather than page scans).
   Each source page becomes a card with a narrower reading measure so long
   sections scan more like an article and less like a wall of extracted text. */
.prose { max-width: none; }
.prose .page-seg {
  scroll-margin-top: 6rem;
  padding: 1.35rem 1.45rem 1.25rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.prose .page-seg + .page-seg { margin-top: 1rem; }
.page-anchor {
  display: block;
  scroll-margin-top: 6rem;
}
/* The reading card can be wider than the prose measure so wide finance tables
   are not trapped in the 78ch column (where they would scroll sideways even on a
   desktop). Prose elements are individually held to a comfortable measure below;
   finance tables and their clusters are free to use the wider card width. */
.page-copy {
  max-width: min(100%, 52rem);
}
.page-copy > :first-child { margin-top: 0; }
.page-copy > p,
.page-copy > h2,
.page-copy > h3,
.page-copy > .topic-block,
.page-copy > .text-list,
.page-copy > .number-list,
.page-copy > .label-strip,
.page-copy > .detail-list,
.page-copy > .list-block {
  max-width: 78ch;
}
.prose p {
  margin: 0 0 1rem; line-height: 1.78; color: var(--ink);
  text-wrap: pretty;
  -webkit-hyphens: auto; hyphens: auto; overflow-wrap: break-word;
}
.table-wrap {
  margin: .8rem 0 1.3rem; overflow-x: auto; border: 1px solid var(--line);
  border-radius: 8px; background: #fff;
  /* Size to the table: a narrow table isn't stretched across the card, and a wide
     table uses the available card width, only falling back to scroll-in-place on
     viewports narrower than the table itself (e.g. phones). */
  width: fit-content; max-width: 100%;
}
.data-table {
  width: 100%; border-collapse: collapse; min-width: 620px; font-size: .92rem;
}
.data-table th,
.data-table td {
  padding: .48rem .6rem; border-bottom: 1px solid var(--line);
  text-align: right; vertical-align: top; white-space: nowrap;
}
.data-table th:first-child,
.data-table td:first-child {
  text-align: left; white-space: normal; min-width: 220px; color: var(--ink);
  font-weight: 650;
}
.data-table th {
  background: #eef2f7; color: var(--ink); font-weight: 800;
}
.data-table tbody tr:nth-child(even) { background: #fafbfd; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-grid {
  min-width: 0;
  font-variant-numeric: tabular-nums;
}
.data-grid th[scope="row"] {
  text-align: left;
  white-space: normal;
  min-width: 180px;
  background: #f4f7fb;
  font-weight: 650;
  color: var(--ink);
}
.data-grid td { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.data-grid-wrap { margin: .25rem 0 .35rem; }
.data-cluster .data-grid-wrap { margin: .15rem 0 .25rem; }
.prose h2 {
  margin: 1.85rem 0 .75rem; font-size: 1.24rem; line-height: 1.28; color: var(--ink);
  letter-spacing: -.01em; scroll-margin-top: 6rem;
}
.prose .page-seg:first-child h2:first-child { margin-top: 0; }
.topic-block {
  margin: 0 0 1rem;
  padding: .95rem 1rem;
  border: 1px solid #d7e2f4;
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  background: linear-gradient(180deg, #f8fbff, #f1f6ff);
}
.topic-block h3 {
  margin: 0 0 .35rem;
  font-size: 1rem;
  line-height: 1.35;
  color: var(--ink);
}
.topic-block p:last-child { margin-bottom: 0; }
.text-list {
  margin: 0 0 1.15rem;
  padding-left: 1.1rem;
  columns: 2 18rem;
  column-gap: 2rem;
}
.text-list li {
  margin: 0 0 .45rem;
  break-inside: avoid;
  color: var(--ink);
  line-height: 1.55;
}
.text-list-compact {
  margin: 0;
  padding-left: 1rem;
  columns: 1 12rem;
}
.text-list-long {
  columns: 1;
  padding-left: 1.25rem;
}
.text-list-long li {
  margin-bottom: .58rem;
  line-height: 1.65;
}
.label-strip {
  margin: 0 0 1.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}
.label-strip span {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: .32rem .62rem;
  border: 1px solid #dbe3f0;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: .82rem;
  font-weight: 650;
  line-height: 1.25;
  text-wrap: pretty;
}
.number-list {
  margin: 0 0 1.15rem;
  padding-left: 1.35rem;
}
.number-list li {
  margin: 0 0 .58rem;
  line-height: 1.68;
  text-wrap: pretty;
}
.list-block {
  margin: 0 0 1.1rem;
  padding: .85rem 1rem;
  border: 1px solid #dbe3f0;
  border-radius: 12px;
  background: #fbfcff;
}
.list-block h3 {
  margin: 0 0 .55rem;
  font-size: .96rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink);
}
.detail-list {
  margin: 0 0 1.15rem;
  display: grid;
  /* min(230px, 100%) floor: keeps the two-up detail cards side-by-side on desktop
     but lets a column collapse to fit a narrow phone, so a detail-list (e.g. the
     Personnel Management / budget-level cards on Financial Structure p25-p26) can't
     overflow and scroll the page sideways below ~312px viewports (e.g. the 280px
     Galaxy Fold). Only ever widens available space, so no page can regress. */
  grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr));
  gap: .65rem;
}
.detail-list div {
  min-width: 0;
  padding: .75rem .85rem;
  border: 1px solid #dbe3f0;
  border-radius: 10px;
  background: #fbfcff;
}
.detail-list dt {
  margin: 0 0 .18rem;
  font-size: .75rem;
  font-weight: 800;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.detail-list dd {
  margin: 0;
  color: var(--ink);
  line-height: 1.55;
  overflow-wrap: break-word;
}
.data-cluster {
  margin: 0 0 1.1rem;
  padding: .9rem 1rem;
  border: 1px solid #dbe3f0;
  border-radius: 12px;
  background: #f8fbff;
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.data-cluster .table-wrap {
  margin: .15rem 0 .25rem;
}
.data-cluster .detail-list {
  margin: .15rem 0 .25rem;
}
.data-cluster .label-strip {
  margin: .1rem 0 .25rem;
}
.data-cluster .label-strip span {
  background: #fdfefe;
}
/* A cluster that holds a finance table may grow with the card so the table is
   fully visible; a cluster that is only narrative/label rows (or holds a
   budget-grid / detail-list, which size themselves) stays at the reading measure
   so it doesn't sprawl. Narrative rows inside a wide table-cluster keep the
   readable measure too. */
.data-cluster:not(:has(.table-wrap)) {
  max-width: 78ch;
}
.data-cluster .data-row:not(.data-row-label) {
  max-width: 78ch;
}
.budget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .8rem;
}
.budget-card {
  min-width: 0;
  padding: .85rem .9rem;
  border: 1px solid #d7e2f4;
  border-radius: 12px;
  background: #fff;
}
.budget-card h4 {
  margin: 0 0 .65rem;
  font-size: .86rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent-dark);
}
.budget-pairs {
  margin: 0;
  display: grid;
  gap: .45rem;
}
.budget-pairs div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .35rem .7rem;
  align-items: baseline;
  padding-top: .45rem;
  border-top: 1px solid #edf2f8;
}
.budget-pairs div:first-child {
  padding-top: 0;
  border-top: 0;
}
.budget-pairs dt {
  min-width: 0;
  margin: 0;
  color: var(--ink-soft);
  font-size: .78rem;
  line-height: 1.4;
  text-wrap: pretty;
}
.budget-pairs dd {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
  font-size: .82rem;
  white-space: nowrap;
}
.data-row {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .84rem;
  line-height: 1.6;
  color: var(--ink-soft);
  white-space: normal;
  overflow-wrap: anywhere;
  word-spacing: .15em;
  font-variant-numeric: tabular-nums;
}
.data-row-label {
  font-family: inherit;
  font-size: .92rem;
  font-weight: 650;
  color: var(--ink);
  white-space: normal;
}
.prose .orig { margin: .4rem 0 1.8rem; }
.prose .orig a {
  font-size: .82rem; font-weight: 600; color: var(--muted);
  text-decoration: none; border-bottom: 1px dotted var(--line);
}
.prose .orig a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- inline figures (images cropped from the page scans) ---------- */
/* Photos, charts, org charts, certificates, maps, diagrams, and color-formatted
   tables lifted out of the page scans to illustrate the readable text. */
.page-figures {
  display: grid;
  /* min(320px, 100%) floor: keeps the multi-figure rows side-by-side on desktop but
     lets a column collapse to fit a narrow phone, so a 3-up figure row (e.g. p8 of the
     Introduction) can't overflow and scroll the page sideways. */
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: 1.1rem;
  margin: 0 0 1.2rem;
}
.page-figure {
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .7rem .7rem .55rem;
}
.page-figure a { display: block; }
.page-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  background: #fff;
}
.page-figure figcaption {
  margin-top: .55rem;
  font-size: .85rem;
  color: var(--muted);
  text-wrap: pretty;
  line-height: 1.35;
}
/* A lone figure on a page shouldn't stretch to full content width. */
.page-figures:has(.page-figure:only-child) { grid-template-columns: minmax(0, 760px); }

/* Page scans only appear in the All Pages grid and the single-page viewer. */
.viewer img {
  display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff;
}

/* Legacy Table of Contents page (contents.html). Its page blocks embed full page
   scans inline; without a width cap a 1600px scan overflows and scrolls the page
   sideways, so constrain the image to its column. */
.pageblocks { display: flex; flex-direction: column; gap: 1.4rem; }
.pageblock {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem 1.1rem;
}
.pageblock-head { margin-bottom: .55rem; }
.pageblock img {
  display: block; width: 100%; height: auto;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
}

.page-text { margin-top: .7rem; }
.page-text summary { cursor: pointer; color: var(--accent); font-size: .9rem; font-weight: 600; }
.page-text pre {
  white-space: pre-wrap; word-wrap: break-word; font-size: .82rem; line-height: 1.5;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: .9rem 1rem;
  margin-top: .6rem; color: var(--ink-soft); max-height: 26rem; overflow: auto;
}

.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2rem; }

/* ---------- all-pages grid ---------- */
.page-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 1rem;
}
.page-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.page-card img { display: block; width: 100%; height: auto; border-bottom: 1px solid var(--line); background: #fff; }
.page-card-meta { padding: .55rem .7rem; display: flex; flex-direction: column; gap: .1rem; }
.page-card-link { font-weight: 700; font-size: .9rem; text-wrap: pretty; }
.page-card-sec { color: var(--muted); font-size: .76rem; text-wrap: pretty; }
.page-card.summary-ready:hover,
.page-card.summary-ready:focus-within {
  border-color: #bfd0e8;
  box-shadow: 0 2px 5px rgba(20,34,64,.08), 0 12px 28px rgba(20,34,64,.12);
  transform: translateY(-1px);
}
.page-summary-popover {
  position: fixed;
  z-index: 75;
  width: min(370px, calc(100vw - 2rem));
  max-height: min(72vh, 560px);
  overflow: auto;
  padding: 1rem 1.05rem 1.05rem;
  border: 1px solid #c8d4e8;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 34px rgba(20,34,64,.18), 0 3px 10px rgba(20,34,64,.1);
  opacity: 0;
  pointer-events: none;
  transform: translateX(8px);
  transition: opacity .18s ease, transform .18s ease;
}
.page-summary-popover[data-side="left"] { transform: translateX(-8px); }
.page-summary-popover.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}
.page-summary-popover[hidden] { display: none; }
.page-summary-eyebrow {
  margin: 0 0 .28rem;
  color: var(--accent);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1.25;
  text-transform: uppercase;
}
.page-summary-popover h3 {
  margin: 0 0 .55rem;
  font-size: 1.05rem;
  line-height: 1.25;
  color: var(--ink);
  text-wrap: pretty;
}
.page-summary-copy {
  margin: 0 0 .75rem;
  color: var(--ink-soft);
  font-size: .9rem;
  line-height: 1.62;
  text-wrap: pretty;
}
.page-summary-points {
  margin: 0;
  padding-left: 1.05rem;
  color: var(--ink);
  font-size: .86rem;
  line-height: 1.5;
}
.page-summary-points li { margin: 0 0 .42rem; }
.page-summary-points li:last-child { margin-bottom: 0; }
.page-summary-note {
  margin: .85rem 0 0;
  padding: .68rem .72rem;
  border: 1px solid #d8e4f5;
  border-radius: 8px;
  background: #f6f9fe;
  color: var(--ink-soft);
  font-size: .82rem;
  line-height: 1.5;
}
.page-summary-note b {
  color: var(--ink);
  font-weight: 800;
}

/* ---------- single page viewer ---------- */
.viewer-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin-bottom: 1rem; flex-wrap: wrap;
}
.viewer-where { text-align: center; flex: 1 1 260px; min-width: 0; }
.viewer-where h1 { margin: 0; font-size: 1.3rem; text-wrap: pretty; }
.viewer-foot { margin-top: 1rem; color: var(--muted); text-wrap: pretty; }
.pager a { text-wrap: pretty; }
.notice {
  background: #fff7e6; border: 1px solid #f0d399; border-radius: var(--radius); padding: 1rem 1.2rem;
  text-wrap: pretty;
}

/* ---------- search ---------- */
.search-form { display: flex; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.search-form input {
  flex: 1 1 420px; min-width: 0; padding: .7rem .9rem; font-size: 1rem; border: 1px solid var(--line); border-radius: 9px;
}
.search-form input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.results { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .8rem; }
.result {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1.1rem; box-shadow: var(--shadow);
}
.result h3 { margin: 0 0 .3rem; font-size: 1rem; text-wrap: pretty; }
.result .snippet { color: var(--ink-soft); font-size: .9rem; line-height: 1.6; text-wrap: pretty; }
.result mark { background: #fff1a8; color: inherit; padding: 0 .1em; border-radius: 2px; }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  .topbar {
    padding: 0 .9rem;
    flex-wrap: wrap;
  }
  .topbar-sep {
    display: none;
  }
  .nav-burger {
    display: inline-flex;
    margin-left: auto;
  }
  .topbar-panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-left: 0;
    background: #1a3a6b;
    border-top: 1px solid rgba(255,255,255,.12);
    box-shadow: 0 6px 14px rgba(0,0,0,.25);
    display: none;
  }
  .topbar-panel.open {
    display: block;
  }
  .topbar-nav {
    flex-direction: column;
    align-items: stretch;
    padding: .5rem .75rem .75rem;
    gap: .1rem;
  }
  .topbar-nav a,
  .topbar-nav button {
    width: 100%;
    justify-content: flex-start;
    font-size: .95rem;
    padding: .65rem .75rem;
  }
  .nav-dropdown-menu {
    position: static;
    right: auto;
    width: 100%;
    max-width: none;
    margin-top: .25rem;
    box-shadow: none;
    border-color: rgba(255,255,255,.15);
  }
  .nav-dropdown.open .nav-dropdown-menu {
    grid-template-columns: 1fr;
  }
  .subnav ul { grid-template-columns: 1fr; }
  .text-list { columns: 1; }
}

@media (max-width: 720px) {
  .hero h1 { font-size: 1.8rem; }
}
