/* ===========================================================
   SOPS — House style (DHR) theme
   Official Department of the House of Representatives palette
   from the Style Guide (May 2024): House of Representatives green
   leads, navy carries the chrome, gold is the accent.
   Fonts: Ubuntu (headings) over Arial (body — Myriad Pro fallback).
   The existing role-based variable names are kept and remapped, so
   the whole stylesheet re-themes from this block.
   =========================================================== */

:root {
  /* Brand tokens (DHR palette) */
  --hor-green:   #006A4D;     /* PMS 342 — primary */
  --hor-green-d: #00513a;     /* darker green for the nav band */
  --navy:        #00334D;     /* PMS 540 — chrome + headings */
  --gold:        #EFBD47;     /* PMS 142 — accent */
  --eucalyptus:  #A3A86B;     /* PMS 5777 */
  --light-tan:   #D1C99D;     /* PMS 4535 */
  --burnt-orange:#E37222;     /* PMS 158 */
  --font-head:   "Ubuntu", "Segoe UI", Arial, sans-serif;
  --font-body:   Arial, "Helvetica Neue", Helvetica, sans-serif; /* = Myriad Pro fallback */

  /* Role variables (names kept from the previous theme; remapped to brand) */
  --eu-deep:    var(--hor-green);  /* primary dark: headings, buttons, badges */
  --eu-mid:     #1c7a58;           /* mid green: hover borders, labels, arrows */
  --eu-soft:    #cfe3da;           /* light green tint: badge fills */
  --eu-bg:      #f7f5f1;           /* warm paper (tan family) */
  --eu-bg-2:    #ece7dd;           /* darker warm: header rows, dropdown hover */
  --terracotta: var(--burnt-orange);  /* warm accent (Practice corpus) */
  --ochre:      var(--gold);           /* gold accent (active underlines, headings) */
  --ink:        #1a1a1a;           /* body text — guide: black for text */
  --muted:      #5b5853;           /* warm grey (≈ DHR grey #5F574F) */
  --line:       #ddd9d1;
  --line-soft:  #eae6dd;
  --card:       #ffffff;
  --link:       #015a41;           /* dark green link */
  --link-hover: var(--navy);
  --hi:         rgba(209, 201, 157, 0.55);  /* light-tan highlight */
  --warn-bg:    #fbe9d6;
  --warn-fg:    #b34f00;

  --so-accent:           var(--eu-mid);
  --practice-accent:     var(--terracotta);
  --constitution-accent: var(--ochre);
  --constitution-deep:   #9a7b1c;
}

/* Accessible label-hiding helper (visually hidden, screen-reader visible) */
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { height: 100%; }
body {
  background: var(--eu-bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px; line-height: 1.6;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}
/* main grows to fill available vertical space, pushing the footer to the
   bottom of the viewport even when content is short */
main { flex: 1 0 auto; }
.top-bar { flex-shrink: 0; }
a { color: var(--link); text-decoration: none; border-bottom: 1px dotted transparent; }
a:hover { color: var(--link-hover); border-bottom-color: var(--link-hover); text-decoration: none; }

.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }

/* ---------- breadcrumb bar (used as footer; deep eucalypt) ---------- */
.top-bar {
  background: var(--navy);
  color: #cdd8de;
  font-size: 0.81rem;
  padding: 14px 0;
  margin-top: 44px;     /* gap above when content is long enough to scroll */
}
.top-bar .container { display: flex; align-items: center; gap: 0; }
.top-bar-links { list-style: none; padding: 0; margin: 0; display: flex; gap: 0; }
.top-bar-links a { color: #cdd8de; border: 0; }
.top-bar-links a:hover { color: #fff; border: 0; }
.top-bar-links li + li::before {
  content: "·"; color: #4f6b7a; padding: 0 10px; font-weight: 700;
}
.top-bar-tag {
  margin-left: auto;
  color: var(--ochre);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-size: 0.72rem;
}
@media (max-width: 720px) {
  .top-bar { padding: 12px 0; }
  .top-bar .container { flex-wrap: wrap; gap: 8px; }
  .top-bar-links li.hide-small { display: none; }
  .top-bar-tag { display: none; }
}

/* ---------- masthead (House green): crest + wordmark + search ---------- */
.site-masthead {
  background: var(--hor-green);
  color: #fff;
}
.site-masthead-inner {
  display: flex;
  align-items: center;
  gap: 22px;
  padding-top: 16px;
  padding-bottom: 16px;
  flex-wrap: wrap;
}
.brand {
  display: flex; align-items: center; gap: 14px;
  text-decoration: none; color: #fff; border: 0;
}
.brand:hover { color: #fff; border: 0; text-decoration: none; }
.brand-crest {
  flex: none;
  width: 50px; height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid var(--gold);
  display: grid; place-items: center;
  font-family: var(--font-head); font-weight: 700; font-size: 0.78rem;
  color: #fff; letter-spacing: 0.02em;
}
.brand-wordmark { display: flex; flex-direction: column; line-height: 1.15; }
.brand-wordmark b {
  font-family: var(--font-head); font-weight: 700;
  font-size: 1.4rem; color: #fff; letter-spacing: -0.005em;
}
.brand-wordmark > span {
  font-size: 0.74rem; color: rgba(255, 255, 255, 0.82);
  margin-top: 4px; letter-spacing: 0.4px;
}
.masthead-search {
  margin-left: auto;
  display: flex; gap: 8px;
  flex: 1 1 320px; max-width: 540px;
}
.masthead-search input {
  flex: 1; min-width: 0;
  padding: 11px 16px;
  font-family: inherit; font-size: 0.95rem;
  border: 0; border-radius: 8px;
  background: #fff; color: var(--ink);
}
.masthead-search input:focus { outline: 3px solid var(--gold); outline-offset: 2px; }
.masthead-search button {
  flex: none;
  padding: 11px 22px;
  background: var(--gold); color: var(--navy);
  border: 0; border-radius: 8px;
  font-family: var(--font-head); font-weight: 500; font-size: 0.95rem;
  cursor: pointer;
}
.masthead-search button:hover { background: #e6ad2e; }
@media (max-width: 720px) {
  .site-masthead-inner { gap: 12px; }
  .brand-crest { width: 42px; height: 42px; }
  .brand-wordmark b { font-size: 1.15rem; }
  .masthead-search { flex-basis: 100%; max-width: none; margin-left: 0; }
}

/* ---------- primary nav (darker House green, gold active underline) ---------- */
.main-nav {
  background: var(--hor-green-d);
  color: #fff;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
}
.main-nav-inner {
  display: flex; align-items: stretch;
  min-height: 48px;
}
.main-nav-links {
  list-style: none; padding: 0; margin: 0;
  display: flex;
}
.main-nav-links a {
  display: flex; align-items: center;
  padding: 0 20px; height: 100%;
  color: rgba(255, 255, 255, 0.85);
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 0.94rem;
  border: 0;
}
.main-nav-links a:hover {
  background: rgba(0, 0, 0, 0.14);
  color: #fff;
  border: 0;
  box-shadow: inset 0 -3px 0 var(--gold);
}
.main-nav-links a.active {
  color: #fff;
  font-weight: 700;
  box-shadow: inset 0 -3px 0 var(--gold);
}
/* Browse dropdown in the main nav */
.has-dropdown { position: relative; }
.nav-dropdown-toggle {
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  border: 0;
  padding: 0 20px;
  height: 100%;
  font-family: var(--font-head);
  font-size: 0.94rem;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.01em;
  display: inline-flex; align-items: center; gap: 6px;
}
.nav-dropdown-toggle .caret { font-size: 0.75em; opacity: 0.85; }
.nav-dropdown-toggle:hover { background: rgba(0, 0, 0, 0.14); color: #fff; box-shadow: inset 0 -3px 0 var(--gold); }
.nav-dropdown-toggle[aria-expanded="true"] { background: rgba(0, 0, 0, 0.2); color: #fff; box-shadow: inset 0 -3px 0 var(--gold); }

.nav-dropdown-menu {
  position: absolute;
  top: 100%; left: 0;
  min-width: 240px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-top: 3px solid var(--ochre);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  list-style: none;
  margin: 0; padding: 6px 0;
  z-index: 200;
}
.nav-dropdown-menu[hidden] { display: none; }
.main-nav-links .nav-dropdown-menu a {
  display: block;
  height: auto;
  padding: 8px 18px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 400;
}
.main-nav-links .nav-dropdown-menu a:hover,
.main-nav-links .nav-dropdown-menu a:focus {
  background: var(--eu-bg-2);
  color: var(--eu-deep);
  outline: none;
}
.nav-dropdown-menu .dropdown-sep {
  height: 1px;
  margin: 6px 0;
  background: var(--line);
}

@media (max-width: 720px) {
  .main-nav-inner { flex-wrap: wrap; }
  .main-nav-links a, .nav-dropdown-toggle { padding: 0 14px; font-size: 0.88rem; }
  .nav-dropdown-menu { min-width: 220px; }
}

/* Search-result tabs (Move 1) */
.results-tabs {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  margin: 4px 0 22px;
}
.results-tab {
  background: transparent;
  border: 0;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 6px;
}
.results-tab:hover { color: var(--eu-deep); }
.results-tab.active {
  color: var(--eu-deep);
  border-bottom-color: var(--ochre);
  font-weight: 700;
}
.results-tab .count {
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--eu-bg-2);
  padding: 1px 8px;
  border-radius: 10px;
  font-weight: 500;
}
.results-tab.active .count {
  color: var(--eu-deep);
  background: rgba(212, 164, 74, 0.18);
}
.results-tab.empty { color: #aaa; cursor: default; }
.results-tab.empty:hover { color: #aaa; }

/* (search now lives in the masthead — see .masthead-search) */

/* ---------- main ---------- */
main {
  padding-top: 28px; padding-bottom: 60px;
}
.loading { color: var(--muted); padding: 40px; text-align: center; font-style: italic; }
.error {
  background: var(--warn-bg); color: var(--warn-fg);
  padding: 12px 16px; border-radius: 6px;
  border-left: 4px solid var(--warn-fg);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-head);
  color: var(--eu-deep);
  line-height: 1.2;
}
h1 { margin-top: 0; font-size: 1.85rem; font-weight: 700; }

/* ---------- home page ---------- */
.home-hero {
  background: var(--card);
  padding: 32px 36px;
  border-radius: 6px;
  margin-bottom: 22px;
  border: 1px solid var(--line-soft);
  position: relative;
  overflow: hidden;
}
.home-hero::before {
  content: "";
  position: absolute;
  top: -40px; right: -40px;
  width: 220px; height: 220px;
  background: radial-gradient(circle, var(--eu-soft) 0%, transparent 70%);
  opacity: 0.4;
}
.home-hero h1 { margin: 0 0 8px; }
.home-hero p { color: var(--muted); margin: 0 0 22px; font-size: 1rem; position: relative; }
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  position: relative;
}
.stat-card {
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--line-soft);
  padding: 16px 12px;
  text-align: center;
  border-radius: 6px;
}
.stat-num {
  font-family: "Open Sans", "Franklin Gothic Book", Helvetica, Arial, sans-serif;
  font-size: 2.1rem; font-weight: 700;
  color: var(--eu-deep);
  line-height: 1;
}
.stat-label {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 6px;
}

.home-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 720px) { .home-cards { grid-template-columns: 1fr; } }
.home-card {
  background: var(--card);
  padding: 24px 28px;
  border: 1px solid var(--line-soft);
  border-left: 4px solid var(--eu-mid);
  border-radius: 6px;
  text-decoration: none;
  color: var(--ink);
  display: block;
  transition: all 0.15s;
}
.home-card:hover {
  text-decoration: none;
  border-color: var(--eu-mid);
  box-shadow: 0 4px 12px rgba(46, 77, 58, 0.1);
  transform: translateY(-1px);
}
.home-card h2 { margin: 0 0 6px; color: var(--eu-deep); font-size: 1.2rem; }
.home-card p { color: var(--muted); margin: 0; font-size: 0.9rem; }
.home-card.practice { border-left-color: var(--terracotta); }
.home-card.practice h2 { color: var(--terracotta); }
.home-card.practice:hover { border-color: var(--terracotta); }
.home-card.constitution { border-left-color: var(--constitution-accent); }
.home-card.constitution h2 { color: var(--constitution-deep); }
.home-card.constitution:hover { border-color: var(--constitution-accent); }

/* ---------- search results ---------- */
.results-section { margin-bottom: 28px; }
.results-section h2 {
  font-size: 1.05rem;
  color: var(--eu-deep);
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin: 0 0 12px;
  font-weight: 600;
}
.results-section.so h2 { color: var(--eu-deep); }
.results-section.practice h2 { color: var(--terracotta); border-bottom-color: var(--terracotta); }
.results-section.constitution h2 { color: var(--constitution-deep); border-bottom-color: var(--constitution-accent); }

.result-card {
  background: var(--card);
  padding: 16px 20px;
  margin-bottom: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.result-card:hover {
  border-color: var(--eu-mid);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(46, 77, 58, 0.08);
}
.results-section.practice .result-card:hover { border-color: var(--terracotta); box-shadow: 0 4px 12px rgba(201, 123, 79, 0.1); }
.results-section.constitution .result-card:hover { border-color: var(--constitution-accent); box-shadow: 0 4px 12px rgba(212, 164, 74, 0.12); }
.result-card .head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.result-card .badge {
  background: var(--eu-soft);
  color: var(--eu-deep);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.74rem;
  font-weight: 600;
}
.results-section.practice .result-card .badge {
  background: var(--terracotta);
  color: #fff;
}
.results-section.constitution .result-card .badge {
  background: var(--constitution-accent);
  color: var(--constitution-deep);
}
.result-card .title { font-weight: 600; color: var(--ink); }
.result-card .path { color: var(--muted); font-size: 0.83rem; }
.result-card .snippet {
  color: #3d3d3d;
  font-size: 0.92rem;
  margin-top: 6px;
  font-family: "Open Sans", "Franklin Gothic Book", Helvetica, Arial, sans-serif;
  line-height: 1.6;
}
.result-card .meta { color: var(--muted); font-size: 0.8rem; margin-left: auto; }

/* ---------- browse / chapter list ---------- */
.browse-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; }
@media (max-width: 1100px) { .browse-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px) { .browse-grid { grid-template-columns: 1fr; } }
.browse-pane h2 {
  margin-top: 0;
  color: var(--eu-deep);
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  font-size: 1.15rem;
}
.browse-pane.practice h2 { color: var(--terracotta); border-bottom-color: var(--terracotta); }
.browse-pane.constitution h2 { color: var(--constitution-deep); border-bottom-color: var(--constitution-accent); }

.chapter-list { list-style: none; padding: 0; margin: 0; }
.chapter-list li {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  margin-bottom: 5px;
  transition: all 0.12s;
}
.chapter-list li:hover { border-color: var(--eu-mid); transform: translateX(2px); }
.browse-pane.practice .chapter-list li:hover { border-color: var(--terracotta); }
.browse-pane.constitution .chapter-list li:hover { border-color: var(--constitution-accent); }
.chapter-list li a {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--ink);
  border: 0;
}
.chapter-list li a:hover {
  color: var(--eu-deep);
  text-decoration: none;
  border: 0;
}
.browse-pane.practice .chapter-list li a:hover { color: var(--terracotta); }
.browse-pane.constitution .chapter-list li a:hover { color: var(--constitution-deep); }
.chapter-list .count { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }

/* ---------- detail view ---------- */
.detail { display: grid; grid-template-columns: 1fr 460px; gap: 24px; }
@media (max-width: 1100px) { .detail { grid-template-columns: 1fr; } }
.detail-main {
  background: var(--card);
  padding: 30px 36px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
}
.detail-main h1 {
  margin: 0 0 6px;
  color: var(--eu-deep);
  font-size: 1.7rem;
}
.detail-main .breadcrumb {
  color: var(--muted);
  font-size: 0.83rem;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.detail-main .breadcrumb a { color: var(--muted); border: 0; }
.detail-main .breadcrumb a:hover { color: var(--eu-deep); border: 0; }
.detail-main .body {
  white-space: pre-wrap;
  line-height: 1.75;
  font-family: "Open Sans", "Franklin Gothic Book", Helvetica, Arial, sans-serif;
  color: #2a2a2a;
  font-size: 0.97rem;
}
.detail-main .body-html {
  line-height: 1.75;
  font-family: "Open Sans", "Franklin Gothic Book", Helvetica, Arial, sans-serif;
  color: #2a2a2a;
  font-size: 0.97rem;
}
.detail-main .body-html p { margin: 0 0 14px; }
.detail-main .body-html h3,
.detail-main .body-html h4 {
  color: var(--eu-deep);
  margin-top: 24px; margin-bottom: 10px;
  font-family: "Open Sans", "Franklin Gothic Book", Helvetica, Arial, sans-serif;
}
.detail-main .body-html a { color: var(--link); }
.detail-main .body-html sup { color: var(--muted); }

/* Tables present in Practice's HTML source */
.detail-main .body-html table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0 18px;
  font-size: 0.92rem;
  background: #fff;
}
.detail-main .body-html table th,
.detail-main .body-html table td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.detail-main .body-html table th {
  background: var(--eu-bg-2);
  color: var(--eu-deep);
  font-weight: 600;
}
.detail-main .body-html table tr:nth-child(even) td { background: #faf8ed; }

/* Tables reconstructed from PDF text (best-effort 2-column parser).
   For tables we can confidently parse, render as a real <table> with a
   description column and a right-aligned value column. Section headings
   inside the table get a banded row; bracketed reference notes (e.g.
   "(standing order 47)") get an italic full-width row. */
.detail-main .body-html table.pdf-data-table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0 18px;
  font-size: 0.92rem;
  background: #fff;
  table-layout: auto;
}
.pdf-data-table th,
.pdf-data-table td {
  border: 1px solid var(--line-soft);
  padding: 6px 12px;
  text-align: left;
  vertical-align: top;
}
.pdf-data-table thead th {
  background: var(--eu-bg-2);
  color: var(--eu-deep);
  font-weight: 600;
  border-bottom: 2px solid var(--eu-mid);
}
.pdf-data-table tbody tr.section th {
  background: var(--eu-bg);
  color: var(--eu-deep);
  font-weight: 700;
  text-align: left;
  border-top: 2px solid var(--eu-mid);
}
.pdf-data-table tbody tr.ref td {
  background: transparent;
  border: 0;
  text-align: center;
  font-style: italic;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 4px 12px;
}
.pdf-data-table td.val,
.pdf-data-table th.val {
  white-space: nowrap;
  text-align: right;
  color: var(--eu-deep);
  font-weight: 600;
  width: 1%;
}
.pdf-data-table tbody tr:not(.section):not(.ref):nth-child(even) td { background: #faf8ed; }

/* Fallback: tables we couldn't parse — keep as monospace <pre>. */
.detail-main .body-html pre.pdf-table {
  font-family: "DM Mono", Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre;
  overflow-x: auto;
  background: #f7f5ed;
  color: #2a2a2a;
  padding: 12px 14px;
  margin: 8px 0 16px;
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--eu-mid);
  border-radius: 3px;
  scrollbar-color: var(--eu-mid) var(--line-soft);
  scrollbar-width: thin;
}
.detail-main .body-html pre.pdf-table::-webkit-scrollbar { height: 8px; }
.detail-main .body-html pre.pdf-table::-webkit-scrollbar-thumb { background: var(--eu-mid); border-radius: 4px; }
.detail-main .body-html pre.pdf-table::-webkit-scrollbar-track { background: var(--line-soft); }

.detail-pdf {
  background: var(--card);
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  position: sticky;
  top: 60px;
  max-height: calc(100vh - 80px);
  overflow: auto;
  align-self: start;
}
.detail-pdf .pdf-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 10px;
  font-size: 0.88rem;
}
.detail-pdf img {
  width: 100%; height: auto;
  cursor: zoom-in;
}

/* ---------- PDF crop wrapper ----------
   The source PDFs are A4-size pages with the actual text in a smaller
   block surrounded by wide white margins. To make the small panel preview
   useful, we wrap the <img> in a fixed-aspect container with overflow
   hidden and scale the image up so the content area fills the container.
   Per-framework offsets are derived from sampling the rendered PNGs:
     SO         margins ~20% L/R, 7% T, 21% B  → content 60% × 72%
     Practice   margins ~20% L/R, 5% T, 22% B  → content 60% × 73%
     Constitution  margins ~9% L/R, 6% T, 4% B → content 83% × 89%
   Toggle the .uncropped class on the wrapper to disable cropping.       */
.pdf-crop {
  position: relative;
  overflow: hidden;
  width: 100%;
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
}
.pdf-crop img {
  display: block;
  position: absolute;
  height: auto;
  border: 0;
  border-radius: 0;
}
.pdf-crop-so          { aspect-ratio: 546 / 950; }
.pdf-crop-so img      { width: 166%; left: -33%; top: -7.5%; }
.pdf-crop-practice    { aspect-ratio: 600 / 959; }
.pdf-crop-practice img{ width: 152%; left: -26%; top: -5%;   }
.pdf-crop-constitution      { aspect-ratio: 633 / 983; }
.pdf-crop-constitution img  { width: 120%; left: -10%; top: -5%;   }
/* GTP and Digest are short per-chapter / per-issue PDFs — keep them
   uncropped by default; users can fine-tune via the toggle. */
.pdf-crop-gtp    { aspect-ratio: auto; overflow: visible; }
.pdf-crop-gtp img    { position: relative; width: 100%; left: 0; top: 0; }
.pdf-crop-digest { aspect-ratio: auto; overflow: visible; }
.pdf-crop-digest img { position: relative; width: 100%; left: 0; top: 0; }

/* Uncropped: revert to full page rendering. */
.pdf-crop.uncropped {
  aspect-ratio: auto !important;
  overflow: visible !important;
}
.pdf-crop.uncropped img {
  position: relative !important;
  width: 100% !important;
  left: 0 !important;
  top: 0 !important;
}
.detail-pdf .nav-btns { display: flex; gap: 4px; }
.detail-pdf button {
  background: #fff;
  border: 1px solid var(--line);
  padding: 4px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--eu-deep);
}
.detail-pdf button:hover {
  background: var(--eu-mid);
  color: #fff;
  border-color: var(--eu-mid);
}
.detail-pdf button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- record-level prev/next navigation ---------- */
/* Sits as a sibling above and below the .detail grid, so it visually wraps
   both the article column and the PDF panel — the navigation steps the
   whole record forward/back, not just the article half. */
.rec-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 18px;
}
.detail + .rec-nav {
  margin-top: 24px;
  margin-bottom: 0;
}
.rec-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  text-decoration: none;
  color: var(--ink);
  transition: all 0.15s;
  min-height: 56px;
}
.rec-nav-link:hover {
  border-color: var(--eu-mid);
  background: rgba(185, 201, 176, 0.18);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(46, 77, 58, 0.08);
}
.rec-nav-disabled { visibility: hidden; }
.rec-nav-prev { justify-content: flex-start; text-align: left; }
.rec-nav-next { justify-content: flex-end;   text-align: right; }
.rec-nav-arrow {
  font-size: 1.6rem;
  color: var(--eu-mid);
  font-weight: 300;
  flex: 0 0 auto;
  line-height: 1;
}
.rec-nav-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.rec-nav-dir {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.rec-nav-label {
  font-size: 0.92rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rec-nav-label strong { color: var(--eu-deep); margin-right: 6px; }
.rec-nav-title { color: var(--muted); }
@media (max-width: 720px) {
  .rec-nav-title { display: none; }
}

/* ---------- xrefs ---------- */
.xref-section {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}
.xref-section h3 {
  color: var(--eu-deep);
  font-size: 0.92rem;
  margin: 0 0 12px;
  font-weight: 600;
}
.xref-list { list-style: none; padding: 0; margin: 0; }
.xref-list li {
  background: rgba(185, 201, 176, 0.25);
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 5px;
  font-size: 0.92rem;
}
.xref-list li a { color: var(--link); border: 0; }
.xref-list li a:hover { color: var(--terracotta); border: 0; }
.xref-list .label {
  background: var(--eu-mid);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  margin-right: 8px;
  font-weight: 600;
}

/* ---------- PDF viewer overlay ---------- */
.pdf-viewer {
  position: fixed; inset: 0;
  background: rgba(46, 77, 58, 0.94);
  z-index: 1000;
  display: flex; flex-direction: column;
}
.pdf-viewer.hidden { display: none; }
.pdf-viewer-bar {
  color: #fff;
  padding: 12px 22px;
  display: flex; justify-content: space-between; align-items: center;
  background: var(--eu-deep);
  border-bottom: 3px solid var(--ochre);
}
.pdf-viewer-actions { display: flex; gap: 6px; align-items: center; }
.pdf-viewer-actions button {
  background: #fff;
  border: 0;
  padding: 6px 14px;
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  color: var(--eu-deep);
}
.pdf-viewer-actions .close { background: var(--terracotta); color: #fff; }
.pdf-viewer-actions #pdf-viewer-page { color: #fff; padding: 0 8px; font-size: 0.9rem; }
.pdf-viewer-body {
  flex: 1;
  overflow: auto;
  padding: 24px;
  display: flex;
  /* "safe center" centers when there's room, but falls back to start
     alignment if the child overflows — otherwise the overflowing top/left
     is unreachable by scrolling. */
  align-items: safe center;
  justify-content: safe center;
}
/* Fullscreen crop wrapper: same content cropping as the side panel, but
   sized to fit the viewport instead of the panel column.
   Drive the size from an explicit height (auto + aspect-ratio collapses
   to 0 because the inner image is position:absolute and contributes
   nothing to intrinsic sizing). Height is clamped to whichever is smaller:
     - viewport height minus toolbar  (vertical fit)
     - max-width times aspect ratio   (horizontal fit)
   Width then derives from aspect-ratio. */
.pdf-viewer-body .pdf-crop.pdf-viewer-crop {
  width: auto !important;
  /* Multiplied by --viewer-zoom (default 1, becomes 1.75 / 2.5 when the
     user clicks Zoom in). When > 1 the wrapper exceeds the viewer body
     and overflow:auto lets the user scroll/pan. */
  height: calc(min(
    calc(100vh - 110px),
    calc(min(96vw, 1100px) * var(--ar-h, 950) / var(--ar-w, 546))
  ) * var(--viewer-zoom, 1));
  aspect-ratio: var(--ar-w, 546) / var(--ar-h, 950);
  border: 0;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  flex-shrink: 0;     /* don't let flex squash us when overflow scrolls */
}
.pdf-crop.pdf-viewer-crop.pdf-crop-so          { --ar-w: 546; --ar-h: 950; }
.pdf-crop.pdf-viewer-crop.pdf-crop-practice    { --ar-w: 600; --ar-h: 959; }
.pdf-crop.pdf-viewer-crop.pdf-crop-constitution{ --ar-w: 633; --ar-h: 983; }
.pdf-crop.pdf-viewer-crop.pdf-crop-gtp         { --ar-w: 595; --ar-h: 842; }
.pdf-crop.pdf-viewer-crop.pdf-crop-digest      { --ar-w: 595; --ar-h: 842; }
.pdf-viewer-body .pdf-crop img {
  cursor: default;
  background: #fff;
}

.pager { display: flex; gap: 8px; margin-top: 16px; align-items: center; }
.pager button {
  padding: 6px 14px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
  color: var(--eu-deep);
}
.pager button:disabled { opacity: 0.4; cursor: not-allowed; }
.pager .info { color: var(--muted); font-size: 0.9rem; }
mark { background: var(--hi); padding: 0 2px; border-radius: 2px; }

/* ---------- footer (deep eucalypt) ---------- */
.footer {
  background: var(--eu-deep);
  color: #d6e0d2;
  margin-top: 44px;
}
.footer-inner {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 36px;
  padding-top: 36px; padding-bottom: 36px;
}
@media (max-width: 720px) {
  .footer-inner { grid-template-columns: 1fr; gap: 22px; }
}
.footer-col h3 {
  color: var(--ochre);
  font-family: "Open Sans", "Franklin Gothic Book", Helvetica, Arial, sans-serif;
  font-size: 1.05rem;
  margin: 0 0 12px;
  text-transform: none;
  letter-spacing: 0;
}
.footer-col p { margin: 0; font-size: 0.88rem; line-height: 1.55; }
.footer-col ul { list-style: none; padding: 0; margin: 0; font-size: 0.88rem; }
.footer-col ul li { margin-bottom: 6px; }
.footer-col a { color: #c4d4c0; border: 0; }
.footer-col a:hover { color: #fff; border: 0; text-decoration: underline; }
.footer-bottom {
  background: rgba(0, 0, 0, 0.2);
  font-size: 0.78rem;
  color: #8aa091;
  padding: 12px 0;
  text-align: center;
}

/* ---------- DHR typography overrides ----------
   Ubuntu on heading contexts, Arial on body contexts — for the remaining
   rules that previously named the Open Sans stack (no longer loaded). */
.stat-num,
.detail-main .body-html h3,
.detail-main .body-html h4,
.footer-col h3 {
  font-family: var(--font-head);
}
.result-card .snippet,
.detail-main .body,
.detail-main .body-html {
  font-family: var(--font-body);
}
