/* The Lodge Minutes: archival, restrained. Tokens on :root, dark overrides below. */
:root {
  --bg: #f5f0e6;
  --surface: #fbf8f1;
  --surface-2: #ece5d6;
  --ink: #2b261f;
  --muted: #6c6255;
  --rule: #d6ccb9;
  --accent: #7b3420;
  --accent-ink: #fbf8f1;
  --focus: #b5651d;
  --c-active: #3f6e3a;
  --c-merged: #1f5f9e;
  --c-defunct: #9b3a26;
  --c-unknown: #8a8274;
  --c-ring: #2b261f;
  --tile-filter: none;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1814;
    --surface: #221f1a;
    --surface-2: #2c2821;
    --ink: #e8e0d0;
    --muted: #a99e8c;
    --rule: #3d372e;
    --accent: #d9956b;
    --accent-ink: #1a1814;
    --focus: #e5a66f;
    --c-active: #7fb46f;
    --c-merged: #4f94dc;
    --c-defunct: #d9674a;
    --c-unknown: #a59d90;
    --c-ring: #f2ead9;
    --tile-filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9) saturate(0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1814; --surface: #221f1a; --surface-2: #2c2821; --ink: #e8e0d0; --muted: #a99e8c;
  --rule: #3d372e; --accent: #d9956b; --accent-ink: #1a1814; --focus: #e5a66f;
  --c-active: #7fb46f; --c-merged: #4f94dc; --c-defunct: #d9674a; --c-unknown: #a59d90; --c-ring: #f2ead9;
  --tile-filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9) saturate(0.6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.6 var(--serif);
  overflow-wrap: break-word;
}
a { color: var(--accent); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.25; letter-spacing: 0.005em; }
h1 { font-size: 2rem; margin: 0.2em 0 0.4em; }
h2 { font-size: 1.35rem; margin: 2em 0 0.6em; padding-bottom: 0.25em; border-bottom: 1px solid var(--rule); }
h3 { font-size: 1.1rem; margin: 1.6em 0 0.5em; }
code { font-family: var(--mono); font-size: 0.85em; background: var(--surface-2); padding: 0.05em 0.3em; border-radius: 3px; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2em 0; }
blockquote { margin: 1em 0; padding: 0.2em 1em; border-left: 3px solid var(--rule); color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.skip { position: absolute; left: -9999px; top: 0; z-index: 2000; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; }
.skip:focus { left: 8px; top: 8px; }

/* Header and footer */
.site-header {
  display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px;
  padding: 10px 16px; border-bottom: 1px solid var(--rule); background: var(--surface);
}
.brand { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; color: var(--ink); text-decoration: none; letter-spacing: 0.02em; }
.tagline { font-size: 0.85rem; font-weight: 400; letter-spacing: 0; color: var(--muted); margin-left: 8px; }
@media (max-width: 760px) { .tagline { display: block; margin-left: 0; line-height: 1.3; } }
.site-header nav { display: flex; gap: 16px; font-family: var(--sans); font-size: 0.95rem; }
.site-header nav a { color: var(--ink); text-decoration: none; }
.site-header nav a:hover { color: var(--accent); text-decoration: underline; }
.site-header nav { align-items: baseline; }
.theme-toggle { background: none; color: var(--ink); border: 1px solid var(--rule); border-radius: 999px; padding: 0 8px; min-height: 26px; min-width: 0; line-height: 1; font-size: 0.95rem; }
.site-footer { padding: 24px 16px 32px; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--rule); font-family: var(--sans); }
.site-footer p { max-width: 760px; margin: 0 auto; }
body.is-map .site-footer { display: none; }

/* Document pages */
.doc { max-width: 760px; margin: 0 auto; padding: 16px 16px 48px; }
.doc.wide { max-width: 1000px; }
.crumbs { font-family: var(--sans); font-size: 0.85rem; color: var(--muted); margin: 8px 0 0; }
.lede { font-size: 1.1rem; color: var(--muted); margin-top: 0; }
.facts { display: grid; grid-template-columns: minmax(8rem, max-content) 1fr; gap: 6px 20px; margin: 1.2em 0; padding: 14px 16px; background: var(--surface); border: 1px solid var(--rule); border-radius: 4px; }
.facts dt { font-family: var(--sans); font-size: 0.85rem; color: var(--muted); padding-top: 0.15em; }
.facts dd { margin: 0; min-width: 0; }
@media (max-width: 520px) {
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dt { margin-top: 8px; }
  .facts dt:first-child { margin-top: 0; }
}
.badge { display: inline-block; font-family: var(--sans); font-size: 0.78rem; line-height: 1.4; padding: 0.05em 0.55em; border-radius: 999px; border: 1px solid currentColor; text-transform: capitalize; white-space: nowrap; }
.badge.s-active { color: var(--c-active); }
.badge.s-merged { color: var(--c-merged); }
.badge.s-defunct { color: var(--c-defunct); }
.badge.s-unknown { color: var(--c-unknown); }
.cite { font-family: var(--sans); font-size: 0.72em; vertical-align: 0.35em; line-height: 0; text-decoration: none; white-space: nowrap; margin-left: 1px; }
a.cite:hover { text-decoration: underline; }
.cite-missing { color: var(--muted); }
.note { margin-top: 2.5em; padding: 12px 16px; border: 1px dashed var(--rule); border-radius: 4px; background: var(--surface); }
.note h2 { margin-top: 0.2em; border: 0; font-size: 1.1rem; }
.sources ol { font-size: 0.9rem; padding-left: 1.6em; }
.sources li { margin: 0.3em 0; }
ul.plain, ul.people { list-style: none; padding: 0; }
ul.plain li, ul.people li { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.bio h3 { font-size: 1.2rem; }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--rule); }
.timeline li { position: relative; padding: 0 0 14px 18px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 0.55em; width: 10px; height: 10px; border-radius: 50%; background: var(--bg); border: 2px solid var(--accent); }
.t-date { display: block; font-weight: 600; }
.t-type { display: inline-block; font-family: var(--sans); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-right: 8px; }
.t-detail { display: inline; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 1em 0; border: 1px solid var(--rule); border-radius: 4px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; vertical-align: top; padding: 6px 10px; border-bottom: 1px solid var(--rule); }
thead th { font-family: var(--sans); font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 40%, transparent); }
tbody th { font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.officers td { min-width: 9rem; }
table:not(.list):not(.officers) td:first-child { min-width: 6.4em; } /* ISO dates stay on one line */
@media (max-width: 520px) { th, td { padding: 6px 7px; } table { font-size: 0.88rem; } }
table.narrow { width: auto; min-width: 50%; }

/* Chart */
.chart { margin: 1em 0; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .bars rect { fill: var(--accent); }
.chart .axis { stroke: var(--rule); }
.chart text { fill: var(--muted); font: 12px var(--sans); }
.chart figcaption { font-size: 0.85rem; color: var(--muted); }

/* Map page */
.mapview { display: grid; grid-template-columns: 340px 1fr; grid-template-rows: auto 1fr; height: calc(100vh - 49px); height: calc(100dvh - 49px); }
#map { grid-column: 2; grid-row: 1 / 3; height: 100%; min-height: 300px; background: var(--surface-2); }
.panel { grid-column: 1; padding: 12px 16px 24px; border-right: 1px solid var(--rule); background: var(--surface); font-family: var(--sans); font-size: 0.92rem; }
.panel.p-top { grid-row: 1; padding-bottom: 4px; }
.panel.p-rest { grid-row: 2; overflow-y: auto; padding-top: 4px; }
.panel h1 { font-size: 1.35rem; margin: 0.2em 0 0.2em; }
@media (max-width: 760px) {
  /* Phones: search first, then the map, then filters and legend. */
  .mapview { display: flex; flex-direction: column; height: auto; }
  #map { height: 55vh; height: 55dvh; }
  .panel { border-right: 0; overflow: visible; }
  .panel.p-top { order: -1; }
  .panel.p-rest { border-top: 1px solid var(--rule); }
}
.results .jur { display: block; font-size: 0.8rem; }
.results .more { margin: 6px 0; }
.results button.secondary { background: var(--surface-2); color: var(--ink); border: 1px solid var(--rule); min-height: 32px; }
.field { display: block; margin: 10px 0; }
.field > span { display: block; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 3px; }
input[type="search"], select {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--rule); border-radius: 4px; padding: 7px 8px; min-height: 38px;
}
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 8px; }
@media (max-width: 360px) { .row3 { grid-template-columns: 1fr; } }
.years { border: 1px solid var(--rule); border-radius: 4px; padding: 6px 10px 10px; margin: 12px 0; min-width: 0; }
.years legend { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 0 4px; }
.check { display: flex; gap: 6px; align-items: center; margin: 8px 0; }
.slider-row { display: flex; gap: 10px; align-items: center; }
.slider-row input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); }
#y-out { font-weight: 700; font-variant-numeric: tabular-nums; }
button {
  font: inherit; color: var(--accent-ink); background: var(--accent); border: 0; border-radius: 4px;
  padding: 6px 14px; min-height: 36px; cursor: pointer; min-width: 4.5em;
}
button:hover { filter: brightness(1.08); }
.results { max-height: 260px; overflow-y: auto; }
.results:empty { display: none; }
.results ul { list-style: none; padding: 0; margin: 4px 0 8px; border: 1px solid var(--rule); border-radius: 4px; }
.results li { padding: 6px 8px; border-bottom: 1px solid var(--rule); }
.results li:last-child { border-bottom: 0; }
.results button.linkish { background: none; color: var(--accent); padding: 0; min-height: 0; min-width: 0; text-align: left; text-decoration: underline; }
.legend p { margin: 6px 0; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.legend .li { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.legend .pin { display: inline-block; flex: none; }

/* Markers (shared by map and legend) */
.pin { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--bg); box-shadow: 0 0 0 1px rgba(0,0,0,0.35); }
.pin.sq { border-radius: 2px; width: 12px; height: 12px; }
.pin.ph { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--c-ring); }
.pin.s-active { background: var(--c-active); }
.pin.s-merged { background: var(--c-merged); }
.pin.s-defunct { background: var(--c-defunct); }
.pin.s-unknown { background: var(--c-unknown); }
.leaflet-marker-icon.pin { margin-left: -7px; margin-top: -7px; }
.leaflet-marker-icon.pin.sq { margin-left: -6px; margin-top: -6px; }
.leaflet-marker-icon.cluster { display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--surface); color: var(--ink); border: 2px solid var(--accent); font: 600 12px var(--sans); box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.leaflet-marker-icon.cluster.b { border-radius: 4px; border-style: dashed; }

/* Leaflet theme */
.leaflet-container { font-family: var(--sans); background: var(--surface-2); }
.leaflet-tile-pane { filter: var(--tile-filter); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); box-shadow: 0 2px 10px rgba(0,0,0,0.3); }
.leaflet-popup-content { margin: 12px 14px; font-size: 0.9rem; line-height: 1.45; }
.leaflet-popup-content h3 { font-family: var(--serif); font-size: 1.05rem; margin: 0 0 4px; }
.leaflet-popup-content p { margin: 2px 0; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 85%, transparent) !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--accent); }
.leaflet-bar a { background: var(--surface); color: var(--ink); border-bottom-color: var(--rule); }
.leaflet-bar a:hover { background: var(--surface-2); }

/* Bundled state outlines: a quiet base under the tiles, the whole base when tiles are off. */
.leaflet-container .state-outline { stroke: var(--muted); stroke-opacity: .55; fill: var(--surface); fill-opacity: 0; }
.no-tiles .leaflet-container { background: var(--surface-2); }
.no-tiles .leaflet-container .state-outline { fill-opacity: 1; stroke-opacity: .8; }

/* State charts */
.chart.stacked .s-merged { fill: var(--c-merged); }
.chart.stacked .s-defunct { fill: var(--c-defunct); }
.chart .key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 10px; }
.chart .key:first-child { margin-left: 0; }
.chart .key.s-merged { background: var(--c-merged); }
.chart .key.s-defunct { background: var(--c-defunct); }
.chart details { margin-top: 6px; font-family: var(--sans); font-size: 0.85rem; }
ul.columns { columns: 16em 3; column-gap: 24px; }
ul.columns li { break-inside: avoid; }
