/* Reading the Rolls — Luxury / Editorial scholarly styling.
   Palette: warm alabaster + rich charcoal, metallic gold as the sole accent.
   Type: high-contrast serif display (Playfair if present) + humanist sans
   (Inter if present), both with graceful system fallbacks so we ship no
   external fonts (privacy + offline-first). Sharp corners, generous air,
   slow cinematic motion. */

:root {
  --bg: #F9F8F6;            /* warm alabaster */
  --surface: #FFFFFF;
  --surface-2: #EFEBE4;     /* pale taupe */
  --ink: #1A1A1A;           /* rich charcoal */
  --ink-soft: #2B2A28;
  --muted: #6C6863;         /* warm grey, 4.8:1 on bg */
  --accent: #B8932E;        /* metallic gold, darkened for AA text contrast */
  --accent-bright: #D4AF37; /* display gold (borders, fills) */
  --accent-dark: #8a6d1f;
  --rule: rgba(26,26,26,0.14);
  --rule-strong: rgba(26,26,26,0.30);
  --mark: #F2E6BE;
  --amber-bg: #F6EED6;
  --amber-edge: #a16207;
  --amber-ink: #5c3d00;
  --link: #355E8A;          /* restrained blue for inline body links (AA) */
  --link-dark: #21425f;
  --serif: "Playfair Display", "Iowan Old Style", "Hoefler Text", Georgia, Cambria, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --maxw: 84rem;
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --shadow-card: 0 2px 8px rgba(26,26,26,0.04);
  --shadow-lift: 0 10px 30px rgba(26,26,26,0.10);
}

* { box-sizing: border-box; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.02rem;
  line-height: 1.65;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 2rem; }
@media (min-width: 64rem) { .wrap { padding: 0 4rem; } }

/* ---- decorative editorial chrome --------------------------------------- */
.grain {
  position: fixed; inset: 0; z-index: 60; pointer-events: none; opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
/* Decorative full-height background gridlines, disabled: on sparse pages
   (e.g. family view) they read as stray vertical lines rather than as the
   intended critical-edition rule. */
.gridlines { display: none; }
main, .site-footer { position: relative; z-index: 1; }
/* header sits above main so the mobile drop-down nav (absolutely positioned
   inside the header's stacking context) is not painted over by page content */
.site-header { position: relative; z-index: 50; }

/* ---- typography --------------------------------------------------------- */
h1, h2, h3, h4, .site-name-main, .page-h1 {
  font-family: var(--serif); color: var(--ink); font-weight: 500;
  letter-spacing: -0.01em; line-height: 1.1;
}
.page-h1, h1 { font-size: clamp(2.1rem, 1.4rem + 2.6vw, 3.4rem); margin: 1.4rem 0 0.7rem; }
h2 { font-size: clamp(1.4rem, 1.1rem + 1vw, 1.9rem); margin: 2rem 0 0.6rem; }
h3 { font-size: 1.15rem; margin: 1.2rem 0 0.35rem; }
.overline {
  font-family: var(--sans); text-transform: uppercase; letter-spacing: 0.28em;
  font-size: 0.7rem; font-weight: 600; color: var(--muted);
}
em, i { font-style: italic; }

a { color: var(--link); text-decoration: none; text-underline-offset: 3px;
    transition: color 0.4s var(--ease); }
a:hover { color: var(--accent); text-decoration: underline; text-decoration-color: var(--accent-bright); }
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 0;
}

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--ink); color: var(--bg); padding: 0.6rem 1.1rem;
  letter-spacing: 0.1em; text-transform: uppercase; font-size: 0.75rem;
}
.skip-link:focus { left: 0; color: var(--bg); }

/* ---- header / footer ---------------------------------------------------- */
.site-header { background: var(--bg); border-bottom: 1px solid var(--ink); }
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 1.2rem 2rem;
}
@media (min-width: 64rem) { .header-inner { padding: 1.4rem 4rem; } }
.site-name { display: flex; flex-direction: column; gap: 0.15rem; line-height: 1; }
.site-name-over { font-size: 0.62rem; letter-spacing: 0.26em; text-transform: uppercase; color: var(--muted); }
.site-name-main { font-size: 1.4rem; font-weight: 600; color: var(--ink); }
.site-name:hover { color: var(--ink); }
.site-name:hover .site-name-main { color: var(--accent); }
.main-nav { display: flex; flex-wrap: wrap; gap: 1.6rem; list-style: none; margin: 0; padding: 0; }
.main-nav a {
  text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.72rem;
  font-weight: 500; color: var(--ink); padding: 0.3rem 0; position: relative;
}
.main-nav a::after {
  content: ""; position: absolute; left: 0; right: 100%; bottom: -2px; height: 1px;
  background: var(--accent-bright); transition: right 0.5s var(--ease);
}
.main-nav a:hover { color: var(--accent); text-decoration: none; }
.main-nav a:hover::after { right: 0; }
.nav-toggle { display: none; }

.fixture-banner {
  background: var(--amber-bg); color: var(--amber-ink);
  border-bottom: 1px solid var(--amber-edge);
  padding: 0.6rem 2rem; text-align: center; font-size: 0.9rem;
}
.wip-banner {
  background: var(--surface-2); color: var(--ink-soft);
  border-bottom: 1px solid var(--rule-strong);
  padding: 0.55rem 2rem; text-align: center; font-size: 0.85rem;
}
.wip-banner strong { color: var(--ink); }

.site-footer { margin-top: 5rem; padding: 0 0 3rem; font-size: 0.85rem; color: var(--muted); }
.footer-rule { display: none; }  /* decorative divider line removed */
.footer-ack { max-width: 60ch; }
.footer-links { display: flex; flex-wrap: wrap; gap: 1.6rem; list-style: none; padding: 0; margin: 1rem 0; }
.footer-links a { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.7rem; color: var(--ink); }
.footer-build { margin: 0.6rem 0 0; letter-spacing: 0.04em; }

/* ---- buttons & forms ---------------------------------------------------- */
button, .btn, .bho-btn {
  font: inherit; cursor: pointer; position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ink); color: var(--bg); border: 1px solid var(--ink);
  border-radius: 0; padding: 0.7rem 1.5rem; min-height: 2.9rem;
  text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.72rem;
  font-weight: 500; text-decoration: none; box-shadow: 0 4px 16px rgba(26,26,26,0.12);
  /* solid fill — always legible; gold appears only on hover */
  transition: background-color 0.45s var(--ease), color 0.45s var(--ease),
              box-shadow 0.5s var(--ease), border-color 0.45s var(--ease);
}
button:hover, .bho-btn:hover, .btn:hover {
  background-color: var(--accent-bright); color: var(--ink);
  border-color: var(--accent-bright); box-shadow: var(--shadow-lift);
  text-decoration: none;
}
.btn-secondary { background: transparent; color: var(--ink); box-shadow: none; }
.btn-secondary:hover { background-color: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-small { min-height: 2.2rem; padding: 0.35rem 0.9rem; letter-spacing: 0.1em; font-size: 0.66rem; box-shadow: none; }

input[type="search"], input[type="text"], input[type="email"], input[type="number"], select, textarea {
  font: inherit; color: var(--ink); background: transparent;
  border: 0; border-bottom: 1px solid var(--ink); border-radius: 0;
  padding: 0.55rem 0.1rem; width: 100%; max-width: 100%;
  transition: border-color 0.4s var(--ease);
}
input::placeholder { font-family: var(--serif); font-style: italic; color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-bottom-color: var(--accent-bright); }
select { padding-right: 1.2rem; }
textarea { border: 1px solid var(--ink); padding: 0.6rem 0.7rem; }
label { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 0.3rem; font-weight: 600; color: var(--muted); }
fieldset { border: 1px solid var(--rule); border-radius: 0; }
legend { font-family: var(--serif); font-size: 1rem; padding: 0 0.5rem; }

/* ---- home --------------------------------------------------------------- */
.hero { padding: clamp(2.5rem, 5vw, 6rem) 0 2rem; max-width: 52rem; }
.hero-deco { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.4rem; }
.hero-deco .line { display: none; }  /* decorative accent line removed */
.hero h1 { font-size: clamp(2.6rem, 1.5rem + 5vw, 6rem); line-height: 0.96; margin: 0 0 1.2rem; }
.hero h1 em { color: var(--accent); }
.hero-sub { max-width: 42rem; color: var(--muted); font-size: 1.15rem; margin: 0 0 2rem; }
.hero-search { display: flex; gap: 0; max-width: 40rem; border-bottom: 1px solid var(--ink); }
.hero-search input[type="search"] { flex: 1; border: 0; font-size: 1.1rem; }
.hero-search button { box-shadow: none; }
.hero-examples { margin-top: 1.2rem; font-size: 0.9rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 0.5rem 1.2rem; align-items: center; }
.hero-links { display: flex; flex-wrap: wrap; gap: 1.6rem; margin-top: 2.4rem; }
.home-kings { margin-top: 4rem; }
.king-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0; border-top: 1px solid var(--ink); }
.king-list li { border-bottom: 1px solid var(--rule); padding: 1.2rem 1rem 1.2rem 0; transition: padding 0.5s var(--ease); }
.king-list li:hover { padding-left: 0.8rem; }
.king-list .muted { display: block; }

/* ---- search ------------------------------------------------------------- */
.search-form { margin: 1rem 0 1.4rem; }
.search-bar { display: flex; align-items: stretch; border-bottom: 1px solid var(--ink); }
.search-bar input[type="search"] { flex: 1; border: 0; font-size: 1.15rem; }
.search-bar button { box-shadow: none; }
.search-controls { display: flex; flex-wrap: wrap; gap: 0.8rem 1.4rem; align-items: center; margin-top: 0.9rem; }
.control-chip { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; }
.control-chip select { width: auto; border-bottom-color: var(--rule-strong); }
.toggle-line { display: inline-flex; align-items: center; gap: 0.45rem; cursor: pointer; font-size: 0.85rem; text-transform: none; letter-spacing: 0; color: var(--ink); font-weight: 400; margin: 0; }
.toggle-line input { width: auto; }
.mode-toggle, .link-quiet { font-size: 0.85rem; }

.help-q {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.25rem; height: 1.25rem; border: 1px solid var(--rule-strong);
  border-radius: 999px; font-size: 0.72rem; color: var(--muted); cursor: help;
  font-weight: 600; position: relative; flex: none;
}
.help-q:hover { border-color: var(--accent-bright); color: var(--accent); }
.help-q .tip {
  position: absolute; bottom: 150%; left: 50%; transform: translateX(-50%) translateY(6px);
  width: max-content; max-width: 18rem; background: var(--ink); color: var(--bg);
  padding: 0.6rem 0.8rem; font-size: 0.78rem; line-height: 1.5; letter-spacing: 0.01em;
  text-transform: none; font-weight: 400; opacity: 0; visibility: hidden;
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease); z-index: 40;
  box-shadow: var(--shadow-lift); text-align: left;
}
.help-q:hover .tip, .help-q:focus-visible .tip { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }

/* "what's being searched" panel */
.explain-panel {
  border-left: 2px solid var(--accent-bright); background: var(--surface);
  padding: 0.7rem 1rem; margin: 0.4rem 0 1rem; font-size: 0.92rem;
  box-shadow: var(--shadow-card);
}
.explain-panel strong { font-weight: 600; }

/* suggestion chips (accept/reject before searching) */
.suggest-box { border: 1px solid var(--rule); background: var(--surface); padding: 0.8rem 1rem; margin: 0.4rem 0 1rem; box-shadow: var(--shadow-card); }
.suggest-box h2 { font-size: 0.95rem; margin: 0 0 0.5rem; }
.chip-row { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 0.3rem; border: 1px solid var(--rule-strong);
  background: var(--bg); padding: 0.25rem 0.7rem; font-size: 0.82rem; cursor: pointer;
  transition: border-color 0.4s var(--ease), background 0.4s var(--ease), color 0.3s;
  text-decoration: none; color: var(--ink);
}
.chip:hover { border-color: var(--accent-bright); text-decoration: none; }
.chip[aria-pressed="true"], .chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .freq { color: var(--muted); font-size: 0.74rem; }
.chip[aria-pressed="true"] .freq { color: var(--surface-2); }

.adv-fields { margin-top: 1.2rem; border-top: 1px solid var(--rule); padding-top: 1rem; }
.adv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1.2rem; }
.adv-kings { border: none; padding: 0; margin: 0; }
.adv-kings legend { padding: 0; }
.adv-kings label { font-weight: 400; text-transform: none; letter-spacing: 0; }
.adv-kings input { width: auto; margin-right: 0.4rem; }
.adv-actions { margin-top: 1.1rem; display: flex; gap: 1.2rem; align-items: center; }

.search-layout { display: grid; grid-template-columns: 16rem 1fr; gap: 3rem; align-items: start; }
@media (max-width: 56rem) { .search-layout { grid-template-columns: 1fr; gap: 1.5rem; } }

.facets { border-top: 1px solid var(--ink); padding-top: 0.6rem; font-size: 0.9rem; }
.facet-h { margin: 0 0 0.6rem; font-size: 1.05rem; }
.facet-group h3 { margin: 1rem 0 0.3rem; font-family: var(--sans); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.16em; color: var(--muted); }
.facet-group ul { list-style: none; margin: 0; padding: 0; }
.facet-group li { margin: 0.1rem 0; }
.facet-group a { display: flex; justify-content: space-between; gap: 0.6rem; padding: 0.12rem 0; }
.facet-n { color: var(--muted); font-variant-numeric: tabular-nums; }
.facet-active { font-weight: 700; color: var(--accent); }
.facet-x { color: var(--accent); }

/* counts bar: documents · acts · people */
.counts-bar { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--ink); margin: 0.4rem 0 1.2rem; background: var(--surface); }
.count-cell { flex: 1 1 8rem; padding: 0.9rem 1.1rem; border-right: 1px solid var(--rule); }
.count-cell:last-child { border-right: 0; }
.count-num { font-family: var(--serif); font-size: 1.9rem; line-height: 1; display: block; }
.count-label { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.16em; color: var(--muted); margin-top: 0.35rem; display: block; }

.result-count { color: var(--muted); display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: baseline; }
.export-link, .focus-link { font-size: 0.82rem; }
.fuzzy-note { background: var(--amber-bg); color: var(--amber-ink); border-left: 2px solid var(--amber-edge); padding: 0.6rem 1rem; }
.result-list { list-style: none; padding: 0; margin: 0; }
.result { border-bottom: 1px solid var(--rule); padding: 1.3rem 0; transition: background 0.5s var(--ease); }
.result:hover { background: rgba(255,255,255,0.5); }
.result-h { margin: 0 0 0.35rem; font-size: 1.25rem; }
.result-h a { color: var(--ink); }
.result-h a:hover { color: var(--accent); text-decoration: none; }
.result-meta { margin: 0 0 0.4rem; font-size: 0.78rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 0.3rem 0.6rem; align-items: center; }
.result-snippet { margin: 0; font-family: var(--serif); font-size: 1.05rem; }
.result-snippet.focused { border-left: 2px solid var(--accent-bright); padding-left: 0.8rem; }
mark { background: var(--mark); padding: 0 0.12em; color: inherit; }
.pagination { display: flex; gap: 1.6rem; align-items: center; padding: 1.6rem 0; }
.no-results { border: 1px solid var(--rule); padding: 1.4rem; background: var(--surface); }

/* type tag */
.type-tag { display: inline-block; font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.12em; border: 1px solid var(--rule-strong); padding: 0.08rem 0.4rem; color: var(--muted); }

/* ---- badges (color + text, never color alone) -------------------------- */
.badge {
  display: inline-block; font-size: 0.66rem; font-weight: 600; letter-spacing: 0.04em;
  padding: 0.08rem 0.5rem; border-radius: 0; border: 1px solid; vertical-align: middle; cursor: help;
}
.badge-exact { background: #E8EEE6; border-color: #2e6b34; color: #21501f; }
.badge-inferred { background: var(--amber-bg); border-color: #a16207; color: #5c3d00; }
.badge-uncertain { background: #F4E6E2; border-color: #b3372a; color: #802a1e; }
/* THE three-level evidence language (docs/DESIGN_DIRECTION.md):
   verified/exact = green · probable/inferred = amber · uncertain/review = red.
   badge-candidate is the amber level with a help cursor (machine-matched
   lead, unconfirmed) — deliberately NOT a fourth colour. */
.badge-candidate { background: var(--amber-bg); border-color: #a16207; color: #5c3d00; cursor: help; }

/* ---- entry -------------------------------------------------------------- */
.entry-header .breadcrumb { margin: 1.2rem 0 0; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.14em; }
.entry-meta { font-size: 0.9rem; color: var(--muted); margin: 0.25rem 0; display: flex; flex-wrap: wrap; gap: 0.3rem 0.6rem; align-items: center; }
.entry-text { max-width: 74ch; font-family: var(--serif); font-size: 1.18rem; line-height: 1.7; background: var(--surface); border: 1px solid var(--rule); padding: 1.6rem 1.9rem; margin: 1.4rem 0; box-shadow: var(--shadow-card); }
.entry-text p { margin: 0; white-space: pre-line; }
.entry-text .drop p:first-of-type::first-letter { font-family: var(--serif); float: left; font-size: 3.4rem; line-height: 0.72; padding: 0.1rem 0.6rem 0 0; color: var(--accent); }

/* segmented items */
.items-toolbar { display: flex; flex-wrap: wrap; gap: 0.8rem 1.2rem; align-items: center; margin: 1.4rem 0 0.6rem; }
.item-list { list-style: none; padding: 0; margin: 0; counter-reset: itm; }
.item { border-top: 1px solid var(--rule); padding: 0.9rem 0 0.9rem 0; display: grid; grid-template-columns: auto 1fr; gap: 0.9rem; transition: opacity 0.5s var(--ease); }
.item .item-type { font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); border: 1px solid var(--rule-strong); padding: 0.1rem 0.45rem; height: fit-content; white-space: nowrap; }
.item.is-relevant { background: rgba(212,175,55,0.07); }
.item.is-relevant .item-type { border-color: var(--accent-bright); color: var(--accent-dark); }
.item-body { font-family: var(--serif); font-size: 1.08rem; }
.items-hide-irrelevant .item:not(.is-relevant) { display: none; }
.item-source { font-size: 0.7rem; color: var(--muted); }

.bho-line { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin: 1.4rem 0; }
.bho-btn { text-decoration: none; }
.doc-series, .doc-types { margin: 1.8rem 0; }
.doc-guides { font-size: 0.9rem; margin-top: 1rem; }
.type-grid { list-style: none; padding: 0; margin: 1rem 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0.9rem; }
.type-card { border-top: 1px solid var(--ink); padding-top: 0.5rem; }
.type-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem; }
.type-name { font-weight: 600; text-decoration: none; }
.type-card .muted { font-size: 0.82rem; margin: 0.3rem 0 0; }
.ocr-badge { background: #7a4c00; color: #fff; border-color: #7a4c00; }
.ocr-review { background: #8a1c1c; color: #fff; border-color: #8a1c1c; }
.facsimile { margin: 1.4rem 0; border: 1px solid var(--rule, #cbb8); border-radius: 4px; padding: 0.4rem 0.9rem; background: color-mix(in srgb, var(--ink) 3%, transparent); }
.facsimile > summary { cursor: pointer; list-style: none; display: flex; gap: 0.9rem; align-items: baseline; flex-wrap: wrap; }
.facsimile > summary::-webkit-details-marker { display: none; }
.facsimile-cue { font-weight: 600; }
.facsimile-cue::before { content: "▸ "; }
.facsimile[open] .facsimile-cue::before { content: "▾ "; }
.facsimile-meta { font-size: 0.85rem; }
.facsimile-help { font-size: 0.85rem; margin: 0.7rem 0; }
.facsimile-frame { display: block; }
.facsimile-frame img { display: block; max-width: 100%; height: auto; border: 1px solid var(--ink); box-shadow: 0 1px 6px rgba(0,0,0,0.14); }
.facsimile-links { margin: 0.7rem 0 0.3rem; font-size: 0.9rem; }
.crosslinks { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1.2rem; margin: 1.6rem 0; }
.crosslink-card { border-top: 1px solid var(--ink); padding-top: 0.7rem; }
.crosslink-card h3 { margin: 0 0 0.4rem; font-size: 0.95rem; }
.person-list { list-style: none; padding: 0; margin: 0; }
.person-list li { margin: 0.4rem 0; }
.person-chip { font-weight: 600; }
.mini-list { list-style: none; padding: 0; margin: 0; font-size: 0.9rem; }
.mini-list li { padding: 0.18rem 0; border-bottom: 1px solid var(--rule); }

.map { border: 1px solid var(--rule); }
.map-small { height: 17rem; max-width: 38rem; }
.map-large { height: 28rem; margin: 1rem 0 1.5rem; }

.citation-block { background: var(--surface); border-left: 2px solid var(--accent-bright); padding: 1.1rem 1.4rem; margin: 2rem 0; max-width: 74ch; box-shadow: var(--shadow-card); }
.citation-block h2 { margin: 0 0 0.6rem; font-size: 1.15rem; }
.citation-text { font-family: var(--serif); }
.bibtex { font-family: var(--mono); font-size: 0.8rem; overflow-x: auto; background: var(--bg); padding: 0.7rem; border: 1px solid var(--rule); }
.copy-btn { box-shadow: none; }
.copy-feedback { font-size: 0.82rem; color: var(--accent); margin-left: 0.6rem; }
.citation-note { font-size: 0.82rem; color: var(--muted); margin-bottom: 0; }

.prevnext { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 1.8rem 0; border-top: 1px solid var(--rule); padding-top: 1rem; }

/* flag form */
.flag-section { border-top: 1px solid var(--ink); margin-top: 2.5rem; padding-top: 1rem; max-width: 46rem; }
.flag-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 0.8rem; }
@media (max-width: 40rem) { .flag-grid { grid-template-columns: 1fr; } }
.flag-form textarea { margin-bottom: 0.8rem; }
.hp-field { position: absolute !important; left: -9999px !important; top: -9999px !important; height: 1px; overflow: hidden; }

/* ---- tables ------------------------------------------------------------- */
.data-table { border-collapse: collapse; width: 100%; background: var(--surface); border: 1px solid var(--rule); font-size: 0.92rem; margin: 0.8rem 0 1.6rem; }
.data-table caption { text-align: left; font-weight: 600; padding: 0.5rem 0; font-family: var(--serif); }
.data-table th, .data-table td { text-align: left; padding: 0.5rem 0.8rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.data-table thead th { background: var(--surface-2); font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.1em; }
.data-table.compact { width: auto; min-width: 18rem; }
.note-cell { max-width: 24rem; }
.action-cell form { display: inline-block; margin-right: 0.3rem; }

/* ---- browse / cards ----------------------------------------------------- */
.browse-cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 0; border-top: 1px solid var(--ink); }
.browse-cards li { border-bottom: 1px solid var(--rule); border-right: 1px solid var(--rule); padding: 1.6rem 1.4rem; transition: background 0.5s var(--ease); }
.browse-cards li:hover { background: var(--surface); }
.browse-cards h2 { margin: 0 0 0.2rem; }
.browse-cards p { margin: 0.4rem 0 0; color: var(--muted); font-size: 0.9rem; }
.variant-list { columns: 2; list-style: none; padding: 0; max-width: 38rem; }

/* ---- visualizations ----------------------------------------------------- */
.viz-toolbar { display: flex; flex-wrap: wrap; gap: 1rem 1.6rem; align-items: end; margin: 1rem 0 1.6rem; padding-bottom: 1rem; border-bottom: 1px solid var(--rule); }
.viz-filter { display: flex; gap: 0; align-items: stretch; border-bottom: 1px solid var(--ink); max-width: 26rem; flex: 1 1 18rem; }
.viz-filter input { border: 0; }
.viz-filter button { box-shadow: none; }
.gran-switch { display: inline-flex; border: 1px solid var(--ink); }
.gran-switch a { padding: 0.4rem 0.9rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink); border-right: 1px solid var(--rule); transition: background 0.4s var(--ease); }
.gran-switch a:last-child { border-right: 0; }
.gran-switch a:hover { background: var(--surface-2); text-decoration: none; }
.gran-switch a.on { background: var(--ink); color: var(--bg); }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); gap: 1.6rem; }
.chart-card { background: var(--surface); border: 1px solid var(--rule); padding: 1.1rem 1.2rem 1.2rem; box-shadow: var(--shadow-card); transition: box-shadow 0.5s var(--ease); }
.chart-card:hover { box-shadow: var(--shadow-lift); }
.chart-card.wide { grid-column: 1 / -1; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem; margin-bottom: 0.7rem; }
.chart-head h2 { margin: 0; font-size: 1.1rem; }
.chart-dl { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; }
.chart-box { position: relative; height: 17rem; }
.chart-box.tall { height: 22rem; }

/* movement map + slider */
.movement-wrap { position: relative; }
.movement-controls { display: flex; align-items: center; gap: 1rem; margin-top: 0.8rem; }
.movement-controls input[type="range"] { flex: 1; }
.movement-year { font-family: var(--serif); font-size: 1.4rem; min-width: 4rem; }

/* ---- topic page --------------------------------------------------------- */
.topic-hero { border-bottom: 1px solid var(--ink); padding-bottom: 1.4rem; margin-bottom: 1.6rem; }
.topic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
@media (max-width: 56rem) { .topic-grid { grid-template-columns: 1fr; } }
.topic-section { margin: 2.2rem 0; }
.related-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ---- help --------------------------------------------------------------- */
.help-table td { vertical-align: top; }
.help-table code, .prose code { font-family: var(--mono); background: var(--surface-2); padding: 0.1rem 0.35rem; font-size: 0.88rem; }

/* ---- misc --------------------------------------------------------------- */
.muted { color: var(--muted); }
.prose { max-width: 74ch; }
.prose p, .prose li { font-size: 1.05rem; }
.prose blockquote { border-left: 2px solid var(--accent-bright); margin-left: 0; padding-left: 1.2rem; font-family: var(--serif); font-style: italic; }
.lead { font-size: 1.2rem; color: var(--muted); max-width: 60ch; }
.admin-tabs { display: flex; gap: 1.4rem; margin: 1rem 0; }
.tab-active { font-weight: 700; border-bottom: 1px solid var(--accent); }
.thanks, .error-page { max-width: 42rem; padding: 2.5rem 0; }

.network-box { border: 1px solid var(--rule); background: var(--surface); min-height: 12rem; box-shadow: var(--shadow-card); }
.network-box p { margin: 0; }

/* family timeline: a light span bar + one tick line per entry, per person.
   position:relative + solid background keeps the page's decorative gridlines
   from bleeding through the track. */
.fam-timeline { position: relative; z-index: 1; border: 1px solid var(--rule);
  background: var(--surface); padding: 0.9rem 1rem; box-shadow: var(--shadow-card); }
.fam-row { display: grid; grid-template-columns: 12rem 3rem 1fr 3rem;
  gap: 0.5rem; align-items: center; padding: 0.14rem 0; }
.fam-name { font-size: 0.82rem; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; color: var(--ink); }
.fam-name:hover { color: var(--accent); text-decoration: none; }
/* name + an optional "other married name" dot live in one grid cell so the
   row keeps its 4-column layout whether or not she has another identity */
.fam-namecell { display: flex; align-items: center; gap: 0.3rem; min-width: 0; }
.fam-namecell .fam-name { flex: 0 1 auto; min-width: 0; }
.fam-other { flex: none; color: #8c3b2e; font-size: 0.55rem; line-height: 1;
  cursor: help; }
.fam-yr { font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.fam-yr-a { text-align: right; }
.fam-track { position: relative; height: 0.85rem; }
/* the pale span of activity */
.fam-span { position: absolute; top: 50%; transform: translateY(-50%);
  height: 0.34rem; border-radius: 2px; background: rgba(26,26,26,0.13); min-width: 2px; }
.fam-span.inferred { background: rgba(212,175,55,0.30); }
/* one entry */
.fam-tick { position: absolute; top: 0; bottom: 0; width: 1.5px;
  margin-left: -0.75px; background: var(--ink); cursor: pointer;
  display: block; text-decoration: none; }
.fam-tick:hover, .fam-tick:focus { width: 3px; margin-left: -1.5px;
  background: var(--accent, #7a1f1f); outline: none; }
.fam-tick.inferred { background: var(--accent-dark); }
/* an entry that names a woman under another of her families (Burgo page,
   her Damary/Verdon entries): a distinct red so her identities are legible */
.fam-tick.other { background: #8c3b2e; width: 2.5px; margin-left: -1.25px; }
/* faint decade axis */
.fam-axis { position: relative; height: 1rem; grid-column: 1 / -1;
  margin: 0 3rem 0.3rem 12.5rem; }
.fam-axis-mark { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--rule); }
.fam-axis-yr { position: absolute; top: -0.1rem; left: 2px; font-size: 0.66rem; color: var(--muted); }
.fam-swatch { display: inline-block; width: 1rem; height: 0.34rem;
  background: rgba(26,26,26,0.13); vertical-align: middle; border-radius: 2px; }
.fam-swatch.tick { width: 2px; height: 0.7rem; background: var(--ink); border-radius: 0; }
.fam-swatch.inferred { background: rgba(212,175,55,0.30); }
.fam-swatch.tick.other { background: #8c3b2e; }
.fam-group { border-top: 1px solid var(--rule); padding-top: 0.4rem; margin-top: 1rem; }
.fam-group h3 { margin: 0 0 0.3rem; }
@media (max-width: 44rem) {
  .fam-row { grid-template-columns: 7rem 2.4rem 1fr 2.4rem; }
  .fam-axis { margin-left: 7.4rem; margin-right: 2.4rem; }
}

.people-matches { border-top: 1px solid var(--ink); padding-top: 0.6rem; margin: 1rem 0 1.4rem; }
.people-matches .facet-h { margin: 0 0 0.4rem; font-size: 1rem; }
.people-match-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1.4rem; }

/* fade-in for progressive reveals */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.reveal { animation: fadeUp 0.7s var(--ease) both; }

/* ---- responsive nav ----------------------------------------------------- */
@media (max-width: 52rem) {
  .nav-toggle { display: inline-flex; flex-direction: column; gap: 4px; background: none; border: 0; box-shadow: none; padding: 0.5rem; min-height: 0; }
  .nav-toggle::before { display: none; }
  .nav-toggle span { width: 22px; height: 1px; background: var(--ink); display: block; }
  .main-nav { position: absolute; top: 100%; right: 0; left: 0; background: var(--bg); border-bottom: 1px solid var(--ink); flex-direction: column; gap: 0; padding: 0.5rem 2rem 1rem; display: none; z-index: 30; }
  .main-nav.open { display: flex; }
  .main-nav li { border-bottom: 1px solid var(--rule); }
  .main-nav a { display: block; padding: 0.8rem 0; }
  .header-inner { position: relative; flex-wrap: wrap; }
}

/* ---- reduced motion ----------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .main-nav a::after { display: none; }
}

/* Itinerary statistics page */
.itin-reigns { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1.2rem; }
.itin-reign-col h3 { margin: 0 0 .4rem; font-size: 1rem; }
.map-box { border: 1px solid var(--rule); background: var(--surface); box-shadow: var(--shadow-card); }
.map-wrap { position: relative; }
.map-watermark { position: absolute; right: .6rem; bottom: .6rem; z-index: 5;
  font: 11px Georgia, serif; color: rgba(60,50,40,.55);
  background: rgba(255,253,248,.7); padding: .1rem .45rem; border-radius: 2px;
  pointer-events: none; }
.itin-controls { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin: .6rem 0 .4rem; }
.itin-controls .btn { padding: .35rem .9rem; cursor: pointer; }
.itin-label { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 12ch; }
.itin-dot { position: relative; cursor: pointer; }
.itin-dot-circle { display: block; border-radius: 50%;
  background: rgba(122,31,31,.55); border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(122,31,31,.5); margin: 0 auto; }
.itin-dot-label { position: absolute; left: 50%; top: 100%;
  transform: translateX(-50%); white-space: nowrap;
  font: 600 11px Georgia, serif; color: #3c322a;
  background: rgba(255,253,248,.85); padding: 0 .3rem; border-radius: 2px;
  pointer-events: none; }

/* Itinerary v4: attribution, caveats, moves explorer */
.attribution { font-size: .9rem; color: var(--muted); max-width: 64ch; margin: -.3rem 0 1rem; font-style: italic; }
.data-caveat { border: 1px solid var(--rule); border-left: 3px solid var(--gold, #8a6d3b);
  background: rgba(138,109,59,.06); padding: .7rem .9rem; border-radius: 3px;
  font-size: .85rem; max-width: 70ch; margin: 0 0 1.4rem; }
.data-note { font-size: .82rem; color: var(--muted); margin: .5rem 0 0; }
.data-note summary { cursor: pointer; color: var(--ink, #7a1f1f); }
.data-note[open] summary { margin-bottom: .35rem; }
.data-warn { font-size: .82rem; color: #7a1f1f; margin: .4rem 0 0; }
.moves-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }
@media (max-width: 560px) { .moves-grid { grid-template-columns: 1fr; } }

/* About: author card */
.author-card { display: flex; gap: 1.1rem; align-items: flex-start; margin: .4rem 0 1rem; }
.author-photo { border-radius: 50%; flex: 0 0 auto; object-fit: cover; box-shadow: var(--shadow-card); }
.author-card p { margin: 0; }
@media (max-width: 480px) { .author-card { flex-direction: column; align-items: center; text-align: center; } }

/* People/Families subnav + obfuscated-email fallback */
.subnav { font-size: .9rem; margin: -.2rem 0 1rem; color: var(--muted); }
.email-obf { white-space: nowrap; }

/* Network map place labels (HTML markers) */
.net-label { font: 600 11px Georgia, serif; color: #2b2118; white-space: nowrap;
  pointer-events: none; text-shadow: 0 0 2px #fffdf8, 0 0 2px #fffdf8, 0 0 3px #fffdf8;
  transform: translateY(-1px); }
.net-label.sel { font-size: 13px; color: #7a1f1f; }

/* Timeline cursor tooltip */
.tl-tip { position: fixed; z-index: 70; pointer-events: none;
  background: var(--ink, #1a1a1a); color: #fffdf8; font: 600 11px Georgia, serif;
  padding: .15rem .45rem; border-radius: 3px; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,.25); }

/* Compare picker bar on the People directory */
.compare-bar { position: sticky; top: 0; z-index: 20; display: flex; gap: .8rem;
  align-items: center; background: var(--surface, #fff); border: 1px solid var(--rule);
  box-shadow: var(--shadow-card); padding: .5rem .8rem; margin: .4rem 0; border-radius: 3px; }
.compare-bar .btn-small { padding: .3rem .8rem; min-height: 2.1rem; }
.compare-bar[hidden] { display: none; }  /* [hidden] must beat display:flex */

/* Traceability disclosures: evidence is one click away, never a wall of text.
   The summary line is the claim; the body is the trail (indexes, registers,
   histograms). Left border colour carries the evidence level. */
details.trace { border-left: 3px solid var(--rule, #d8d2c7); padding: .35rem .8rem;
  margin: .6rem 0; }
details.trace > summary { cursor: pointer; list-style: none; }
details.trace > summary::-webkit-details-marker { display: none; }
details.trace > summary::before { content: "▸ "; color: #6C6863; font-size: .8em; }
details.trace[open] > summary::before { content: "▾ "; }
details.trace .trace-chart { height: 72px; max-width: 34rem; margin: .5rem 0 .2rem; }
