/* Shared styles for the data companion pages (Incumbents, Meta-analysis).
   Inherits the look of the main site (style.css): EB Garamond, black on white,
   blue links. Slightly wider container to hold maps, tables, and plots. */

@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,700;1,400&display=swap');

html { background: #fff; }

body {
  font-family: "EB Garamond", Garamond, Georgia, "Times New Roman", Times, serif;
  font-size: 19px;
  line-height: 1.55;
  color: #000;
  background: #fff;
  max-width: 860px;
  margin: 2em auto 3em auto;
  padding: 0 1.2em;
}

a { color: #0033aa; text-decoration: underline; }
a:visited { color: #551a8b; }
a:hover { color: #cc0000; }

.site-back {
  font-size: 0.92em;
  margin: 0 0 1.6em 0;
}
.site-back a { text-decoration: none; }
.site-back a:hover { text-decoration: underline; }

h1 {
  font-size: 1.65em;
  margin: 0 0 0.25em 0;
  font-weight: normal;
  letter-spacing: 0.01em;
}

h2 {
  font-size: 1.2em;
  margin: 2em 0 0.55em 0;
  border-bottom: 1px solid #999;
  padding-bottom: 0.15em;
  font-weight: bold;
}

h3 {
  font-size: 1.02em;
  margin: 1.3em 0 0.45em 0;
  font-weight: bold;
  font-style: italic;
}

p { margin: 0 0 0.85em 0; }

.authors { font-size: 1.02em; margin: 0 0 0.15em 0; }
.subtitle { color: #333; margin-bottom: 0.2em; }
.updated { font-size: 0.82em; color: #777; margin: 0 0 0.4em 0; }

.pagenav {
  font-size: 0.95em;
  margin: 0.2em 0 0.4em 0;
}
.pagenav a { margin-right: 0.2em; }

hr {
  border: 0;
  border-top: 1px solid #aaa;
  margin: 1.4em 0;
}

.lead { font-size: 1.02em; }
.note { font-size: 0.9em; color: #555; }
.note-italic { font-size: 0.9em; color: #555; font-style: italic; }

/* ---- Summary cards ---- */
.cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9em;
  margin: 1em 0 0.4em 0;
}
.card {
  flex: 1 1 160px;
  border: 1px solid #bbb;
  padding: 0.7em 0.9em 0.8em 0.9em;
  background: #fcfcfc;
}
.card-number {
  font-size: 1.9em;
  line-height: 1.1;
  color: #0033aa;
}
.card-label { font-weight: bold; margin-top: 0.1em; }
.card-detail { font-size: 0.86em; color: #555; margin-top: 0.15em; }

/* ---- Plot container ---- */
.plot-container {
  width: 100%;
  margin: 0.6em 0 0.4em 0;
}

/* ---- Inline chart legend ---- */
.legend-note {
  list-style: none;
  padding-left: 0;
  margin: 0.4em 0 0.8em 0;
  font-size: 0.95em;
}
.legend-note li {
  margin-bottom: 0.3em;
}
.swatch {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  margin-right: 0.45em;
  border-radius: 50%;
  vertical-align: baseline;
}
.swatch-intra { background: #0033aa; }
.swatch-inter { background: #d97706; }
.swatch-multi { background: #0033aa; }
.swatch-single { background: #9aa3b2; }

/* ---- Controls (filters) ---- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em;
  align-items: center;
  margin: 0.6em 0 0.8em 0;
}
.controls select,
.controls input[type="text"] {
  font-family: inherit;
  font-size: 0.92em;
  padding: 0.28em 0.5em;
  border: 1px solid #bbb;
  background: #fff;
  color: #000;
}
.controls label { font-size: 0.92em; color: #333; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92em;
}
table.data th, table.data td {
  text-align: left;
  padding: 0.42em 0.7em;
  border-bottom: 1px solid #ddd;
  vertical-align: top;
}
table.data thead th {
  border-bottom: 1.5px solid #999;
  font-weight: bold;
  white-space: nowrap;
}
table.data th[data-sort] { cursor: pointer; }
table.data th[data-sort]:hover { color: #cc0000; }
table.data tbody tr.clickable-row { cursor: pointer; }
table.data tbody tr.clickable-row:hover { background: #f3f6ff; }
table.data tbody tr:hover { background: #fafafa; }

.detail-indicator { color: #0033aa; font-size: 0.85em; }
.outcome-lost { color: #b00020; }
.outcome-won { color: #555; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.table-count { font-size: 0.86em; color: #555; margin-top: 0.5em; }

/* ---- Election detail panel ---- */
.detail-panel {
  border: 1px solid #999;
  background: #fcfcfc;
  padding: 0.9em 1.1em 1em 1.1em;
  margin-top: 1em;
}
.detail-header {
  display: flex;
  align-items: baseline;
  gap: 0.6em;
  flex-wrap: wrap;
  border-bottom: 1px solid #ddd;
  padding-bottom: 0.4em;
  margin-bottom: 0.6em;
}
.detail-header h3 { margin: 0; font-style: normal; }
.detail-type { font-size: 0.85em; color: #555; font-style: italic; }
.detail-outcome {
  font-size: 0.82em;
  padding: 0.05em 0.5em;
  border: 1px solid currentColor;
  border-radius: 2px;
}
.detail-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 1.3em;
  line-height: 1;
  cursor: pointer;
  color: #888;
}
.detail-close:hover { color: #cc0000; }
.detail-body {
  display: flex;
  align-items: stretch;
  gap: 0.8em;
  flex-wrap: wrap;
}
.detail-candidate { flex: 1 1 220px; }
.candidate-label { font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.03em; color: #777; }
.candidate-name { font-size: 1.1em; }
.candidate-party { color: #555; font-style: italic; }
.candidate-pct { font-size: 1.25em; color: #0033aa; margin-top: 0.1em; }
.detail-vs { align-self: center; color: #999; font-style: italic; }

/* Stacked detail blocks (meta-analysis study panel) */
.detail-stack { display: flex; flex-direction: column; gap: 0.7em; }
.detail-stack .candidate-label { margin-bottom: 0.15em; }
.rate-row { display: flex; flex-wrap: wrap; gap: 0.4em; }
.rate-pill {
  font-size: 0.9em;
  padding: 0.1em 0.55em;
  border: 1px solid #cdd6ea;
  border-radius: 2px;
  background: #f3f6ff;
}
.rate-pill b { color: #0033aa; }
.detail-footer {
  margin-top: 0.7em;
  padding-top: 0.5em;
  border-top: 1px solid #ddd;
  font-size: 0.88em;
  color: #555;
  display: flex;
  gap: 1.2em;
  flex-wrap: wrap;
}

footer {
  margin-top: 3em;
  padding-top: 0.8em;
  border-top: 1px solid #aaa;
  font-size: 0.85em;
  color: #555;
}

/* ---- Narrow screens ---- */
@media (max-width: 600px) {
  body { font-size: 16px; padding: 0 1em; margin: 1em auto 2em auto; }
  .card-number { font-size: 1.6em; }
  .detail-vs { display: none; }
}
