/* The Four Folkways Atlas. Heraldic tinctures on an argent field. */
:root {
  color-scheme: light;
  --argent: #eceeec;         /* page field */
  --argent-2: #e2e5e2;       /* panels */
  --land: #d4d8d4;           /* county with no clear seed */
  --line: #b9beba;           /* county edges, rules */
  --sable: #22252b;          /* ink */
  --ink-2: #4c5058;          /* secondary ink */
  --ink-3: #6f747c;          /* muted ink */
  --azure: #2f5d9e;          /* Puritan */
  --gules: #b8323a;          /* Cavalier */
  --vert: #3a9a6a;           /* Quaker */
  --or: #e0a020;             /* Borderer */
  --celeste: #6fb0e8;        /* the Mormon neo-folkway, azure's child */
  --purpure: #6a4a8c;        /* old colonial stock; officials older-stock than residents */
  --teal: #00918a;           /* officials newer-stock than residents */
  --focus: #2f5d9e;
  --hatch-bg: #f7f8f7;
  --hatch-ink: #22252b;
  --serif: "IM Fell English", "Iowan Old Style", Georgia, serif;
  --serif-sc: "IM Fell English SC", "IM Fell English", Georgia, serif;
  --sans: "Libre Franklin", "Franklin Gothic", "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --argent: #17191c; --argent-2: #1f2226; --land: #2c3035; --line: #3c4147;
    --sable: #e9ebe8; --ink-2: #c3c7c2; --ink-3: #9aa09b;
    --azure: #3d62b4; --gules: #c4404a; --vert: #45a978; --or: #bd8a1f; --celeste: #5598dc; --purpure: #a274d6; --teal: #1ea9a0;
    --focus: #7ea6e0; --hatch-bg: #23262a; --hatch-ink: #e9ebe8;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --argent: #17191c; --argent-2: #1f2226; --land: #2c3035; --line: #3c4147;
  --sable: #e9ebe8; --ink-2: #c3c7c2; --ink-3: #9aa09b;
  --azure: #3d62b4; --gules: #c4404a; --vert: #45a978; --or: #bd8a1f; --celeste: #5598dc; --purpure: #a274d6; --teal: #1ea9a0;
  --focus: #7ea6e0; --hatch-bg: #23262a; --hatch-ink: #e9ebe8;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--argent); color: var(--sable); font: 400 16px/1.55 var(--sans); }
a { color: inherit; text-decoration-color: var(--line); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
cite { font-style: italic; }

.hatch-bg { fill: var(--hatch-bg); }
.hatch-ink { stroke: var(--hatch-ink); stroke-width: 1.1; }
.hatch-dot { fill: var(--hatch-ink); }

/* masthead */
.masthead { padding: 40px 16px 8px; max-width: 1240px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px 40px; align-items: end; }
.masthead-inner { max-width: 44rem; }
.kicker { margin: 0 0 6px; font-size: 14px; color: var(--ink-3); }
.kicker a { text-decoration: none; }
h1 { font: 400 clamp(40px, 6.2vw, 76px)/0.98 var(--serif); letter-spacing: -0.01em; margin: 0 0 14px; }
.lede { font: 400 clamp(18px, 2vw, 21px)/1.45 var(--serif); margin: 0; color: var(--ink-2); max-width: 40rem; }

.shields { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 92px); gap: 10px; }
.shields li { text-align: center; }
.shields button { all: unset; cursor: pointer; display: block; width: 100%; border-radius: 4px; padding: 4px 0 2px; }
.shields button:focus-visible { outline: 2px solid var(--focus); }
.shields button[aria-pressed="true"] .shield-name { text-decoration: underline; text-underline-offset: 3px; }
.shields svg { width: 64px; height: 76px; display: block; margin: 0 auto 4px; }
.shield-name { font: 400 19px/1.1 var(--serif); display: block; }
.shield-tinct { font: italic 400 14px/1.2 var(--serif); color: var(--ink-3); display: block; }

/* atlas */
main { display: block; }
.atlas { max-width: 1240px; margin: 0 auto; padding: 16px 16px 8px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; padding: 10px 0 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { font: 500 14px/1 var(--sans); background: transparent; color: var(--ink-2); border: 0; padding: 8px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--sable); color: var(--argent); }
.sel, .search { display: inline-flex; gap: 8px; align-items: center; color: var(--ink-2); }
select, input[type="search"] { font: 400 14px var(--sans); color: var(--sable); background: var(--argent-2); border: 1px solid var(--line); border-radius: 6px; padding: 7px 8px; max-width: 100%; }
input[type="search"] { width: 160px; }
.chk { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-2); cursor: pointer; }

.mapwrap { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; padding-top: 12px; }
#map { width: 100%; height: auto; display: block; }
#map .county { stroke: var(--argent); stroke-width: 0.25; vector-effect: non-scaling-stroke; }
#map .state { fill: none; stroke: var(--argent); stroke-width: 1.2; vector-effect: non-scaling-stroke; pointer-events: none; }
#map.era-1790 .state { stroke: var(--sable); stroke-opacity: 0.35; stroke-width: 0.8; }
#map .county.hl { stroke: var(--sable); stroke-width: 1.6; }
#map .county.dim { opacity: 0.28; }
#map .ghost { fill: var(--land); opacity: 0.35; pointer-events: none; }
#map .pin { stroke: var(--argent); stroke-width: 1.2; vector-effect: non-scaling-stroke; cursor: pointer; }

.card { border-left: 1px solid var(--line); padding: 4px 0 4px 16px; font-size: 14px; min-height: 360px; }
.card-empty { color: var(--ink-3); font-style: italic; font-family: var(--serif); font-size: 17px; }
.card h3 { font: 400 26px/1.1 var(--serif); margin: 0 0 2px; }
.card .sub { color: var(--ink-3); margin: 0 0 12px; }
.card .verdict { font: 400 18px/1.3 var(--serif); margin: 0 0 12px; }
.bars { display: grid; grid-template-columns: 70px minmax(0, 1fr) 46px; gap: 6px 8px; align-items: center; margin: 0 0 14px; }
.bars .lab { color: var(--ink-2); }
.bars .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.bar { height: 10px; background: var(--argent-2); border-radius: 0 4px 4px 0; position: relative; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; }
.bar .one { position: absolute; top: -3px; bottom: -3px; width: 1px; background: var(--ink-3); }
.facts { display: grid; grid-template-columns: auto auto; gap: 3px 14px; margin: 0; }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; font-size: 14px; color: var(--ink-2); padding: 10px 0 0; }
.legend .sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 6px; }
.legend .ramp { display: inline-flex; gap: 2px; vertical-align: -2px; margin: 0 6px; }
.legend .ramp span { width: 22px; height: 12px; display: inline-block; }
.legend .note { color: var(--ink-3); }

/* prose sections */
.prose { max-width: 1240px; margin: 0 auto; padding: 56px 16px 8px; }
.prose > p, .prose > h3, .prose .lede-p { max-width: 44rem; }
h2 { font: 400 clamp(30px, 3.6vw, 44px)/1.05 var(--serif); margin: 0 0 14px; }
h3 { font: 400 24px/1.2 var(--serif); margin: 36px 0 8px; }
.prose p { margin: 0 0 14px; }
.prose b { font-weight: 600; }

.seedgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin-top: 24px; border-top: 1px solid var(--line); }
.seed { padding: 18px 18px 22px; border-right: 1px solid var(--line); }
.seed:last-child { border-right: 0; }
.seed h3 { margin: 0 0 2px; font-size: 30px; display: flex; gap: 10px; align-items: center; }
.seed h3 svg { width: 28px; height: 34px; flex: none; }
.seed .when { color: var(--ink-3); margin: 0 0 10px; font-size: 14px; }
.seed p { font-size: 15px; }
.seed .names { font: italic 400 17px/1.4 var(--serif); color: var(--ink-2); }
.seed .stat { font: 400 34px/1 var(--serif); display: block; margin-top: 6px; }
.seed .statlab { font-size: 13px; color: var(--ink-3); }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 18px 0; }
.pair figure { margin: 0; }
.pair svg { width: 100%; height: auto; display: block; }
.pair figcaption { font-size: 14px; color: var(--ink-3); margin-top: 6px; }

.holdlist { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; margin-top: 18px; }
.holdlist h4 { font: 400 22px/1.2 var(--serif); margin: 0 0 6px; }
.holdlist ul { list-style: none; margin: 0 0 12px; padding: 0; font-size: 14px; }
.holdlist li button { all: unset; cursor: pointer; display: block; padding: 4px 0; border-bottom: 1px dotted var(--line); width: 100%; }
.holdlist li button:hover, .holdlist li button:focus-visible { color: var(--focus); }
.holdlist .kind { color: var(--ink-3); font-size: 12px; display: block; }

table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
thead th { font-weight: 600; color: var(--ink-2); vertical-align: bottom; }
.tablewrap { overflow-x: auto; margin: 16px 0; }
td .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 8px; }

.chart { margin: 18px 0 8px; overflow-x: auto; scrollbar-width: thin; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--ink-2); font: 400 12px var(--sans); }
.chart .axis line, .chart .axis path { stroke: var(--line); }
.chart .grid line { stroke: var(--line); stroke-opacity: 0.6; }
.chart .title { font: 400 18px var(--serif); fill: var(--sable); }
.chart .lab { fill: var(--sable); font-weight: 500; }
.chart .muted { fill: var(--ink-3); }
.chart-note { font-size: 13px; color: var(--ink-3); max-width: 44rem; }

.houses-table td:nth-child(2), .houses-table th:nth-child(2) { text-align: left; }
.houses-table td { vertical-align: top; }
.houses-table .ev { color: var(--ink-3); font-size: 13px; text-align: left; max-width: 30rem; }
.houses-table td:last-child, .houses-table th:last-child { text-align: left; }
#housefilter { margin: 8px 0 0; }

.method { padding-bottom: 40px; }
.method p, .method li { max-width: 46rem; font-size: 15px; }
.method ol { padding-left: 20px; }
.foot { max-width: 1240px; margin: 0 auto; padding: 24px 16px 48px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-3); }
.foot p { max-width: 60rem; margin: 0; }

.tip { position: fixed; z-index: 10; pointer-events: none; background: var(--sable); color: var(--argent); font-size: 13px; padding: 6px 9px; border-radius: 4px; max-width: 260px; }

@media (max-width: 1000px) {
  .masthead { grid-template-columns: 1fr; }
  .shields { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 420px; }
  .mapwrap { grid-template-columns: 1fr; }
  .card { border-left: 0; border-top: 1px solid var(--line); padding: 12px 0 0; min-height: 0; }
  .seedgrid, .holdlist { grid-template-columns: 1fr 1fr; }
  .seed:nth-child(2) { border-right: 0; }
  .seed { border-bottom: 1px solid var(--line); }
}
@media (max-width: 620px) {
  .seedgrid, .holdlist, .pair { grid-template-columns: 1fr; }
  .seed { border-right: 0; }
  .controls { gap: 8px 12px; }
  input[type="search"] { width: 130px; }
  .shields svg { width: 48px; height: 58px; }
  .shield-name { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.linkish { all: unset; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 2px; }
.linkish:hover, .linkish:focus-visible { text-decoration-color: currentColor; }
.sel select { min-width: 0; max-width: 100%; }
@media (max-width: 620px) {
  .sel { width: 100%; }
  .sel select { flex: 1 1 auto; width: 100%; }
  .search { width: 100%; }
  .search input[type="search"] { flex: 1 1 auto; width: auto; }
}
.facts.gov { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }

/* map interaction */
.mapbox { position: relative; }
#map { cursor: grab; touch-action: none; }
#map:active { cursor: grabbing; }
#map .hoverline { fill: none; stroke: var(--sable); stroke-width: 1.8; vector-effect: non-scaling-stroke; pointer-events: none; }
#map .slabels text { fill: var(--sable); fill-opacity: 0.55; stroke: var(--argent); stroke-opacity: 0.8; paint-order: stroke; font-family: var(--sans); font-weight: 600; letter-spacing: 0.04em; pointer-events: none; }
#map .dpin { stroke: var(--argent); cursor: pointer; }
.zoomctl { position: absolute; left: 8px; top: 8px; display: flex; gap: 4px; }
.zoomctl button { font: 500 14px/1 var(--sans); min-width: 32px; height: 32px; padding: 0 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--argent); color: var(--sable); cursor: pointer; }
.zoomctl button:hover { background: var(--argent-2); }
.toggle { font: 500 14px/1 var(--sans); padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--ink-2); cursor: pointer; }
.toggle[aria-pressed="true"] { background: var(--celeste); border-color: var(--celeste); color: #0f1720; }
.legend .lkey { all: unset; cursor: pointer; display: inline-flex; align-items: center; padding: 2px 6px; margin-left: -6px; border-radius: 4px; }
.legend .lkey:hover, .legend .lkey:focus-visible { background: var(--argent-2); }
.legend .lkey[aria-pressed="true"] { background: var(--argent-2); text-decoration: underline; text-underline-offset: 3px; }
.shields.five { grid-template-columns: repeat(5, 84px); }
.seedgrid.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.seat { margin: 4px 0 14px; }
.seattab { font-size: 13px; width: 100%; }
.seattab th, .seattab td { padding: 3px 4px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.seattab th:first-child { text-align: left; font-weight: 500; }
.seattab td:nth-child(2) { text-align: left; }
.seattab thead th { font-weight: 500; color: var(--ink-3); }
.seattab .n { color: var(--ink-3); font-weight: 400; }
.seatnote { font-size: 12px; color: var(--ink-3); margin: 4px 0 8px; }
@media (max-width: 1000px) { .shields.five { grid-template-columns: repeat(5, minmax(0, 1fr)); max-width: 480px; } .seedgrid.five { grid-template-columns: 1fr 1fr; } }
@media (max-width: 620px) { .seedgrid.five { grid-template-columns: 1fr; } .zoomctl button { min-width: 28px; height: 28px; } }
.seat { overflow-x: auto; }
.seattab { font-size: 12px; }
.seattab th, .seattab td { padding: 3px 3px; }
#map .cdot { stroke: var(--argent); cursor: pointer; }
