/* African Party Atlas — Africa Elects colours (black, red, green, yellow), same layout as the European Party Atlas */
:root {
  --bg: #F7F6F2; --surface: #FFFFFF; --line: #E4E2DB; --line2: #ECEAE4;
  --navy: #1C1C1C; --blue: #A93636; --gold: #F2C200; --ink: #1A1D23; --ink-2: #3E434D; --muted: #565B66;
  --chip: #EFEDE7; --tag: #F6E3E3; --tagInk: #0B6B2E; --wash: rgba(28,28,28,.05);
  --grid: #E4E2DB; --axis: #C9C6BC; --map-empty: #E6E3DA; --map-stroke: #FFFFFF; --neutral: #D5D3CC;
  --font: 'Advent Pro', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { color: var(--ink); font: 16px/1.35 var(--font); }
a { color: var(--tagInk); }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }

/* ---------- header ---------- */
.top { position: sticky; top: 0; z-index: 10; background: var(--bg); padding: 16px 0 12px; border-bottom: 1px solid var(--line); }
.title-row { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
h1 { margin: 0; padding: 10px 32px; background: var(--navy); color: #fff; font-size: 26px; line-height: 1; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; border-radius: 2px; }
.sub { margin: 6px 0 12px; color: var(--muted); font-size: 15px; }
.sub a { font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; }
.filters input[type=search], .filters select {
  height: 38px; border: 1px solid #D5D3CC; background: #fff; color: var(--ink); border-radius: 6px;
  padding: 0 12px; font: 600 15px var(--font); min-width: 0; }
.filters input[type=search] { flex: 1 1 240px; max-width: 360px; }
.filters select { flex: 0 1 190px; }
.filters input:focus-visible, .filters select:focus-visible, .ghost:focus-visible, .tabs button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.chk { color: var(--muted); font-size: 15px; font-weight: 600; display: flex; gap: 6px; align-items: center; cursor: pointer; }
.chk input { accent-color: var(--navy); width: 16px; height: 16px; }
.ghost { min-height: 38px; border: 1px solid #D5D3CC; background: #fff; color: var(--navy); border-radius: 999px;
  padding: 0 16px; font: 600 15px var(--font); cursor: pointer; }
.ghost:hover { border-color: var(--navy); }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 18px 0; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; border-top: 3px solid var(--gold); }
.kpi .v { font-size: 30px; font-weight: 700; line-height: 1.05; color: var(--navy); font-variant-numeric: tabular-nums; }
.kpi .l { margin-top: 4px; color: var(--blue); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

/* ---------- cards: navy title bar + white body, like the country pages ---------- */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 0 0 16px; min-width: 0; overflow: hidden; }
.card > header { background: var(--navy); color: #fff; padding: 12px 16px; margin-bottom: 14px; border-bottom: 3px solid #D04848; }
.card > *:not(header) { margin-left: 16px; margin-right: 16px; }
.card h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.card > header p { margin: 4px 0 0; color: #DADADA; font-size: 15px; font-weight: 500; line-height: 1.3; }
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } .span-2, .span-3 { grid-column: span 1; } }

.scroll-y { max-height: 520px; overflow-y: auto; overflow-x: hidden; }
.map { aspect-ratio: 4 / 3; max-height: 560px; }
.map svg { width: 100%; height: 100%; display: block; }
.map path.c { stroke: var(--map-stroke); stroke-width: 0.6; cursor: pointer; }
.map path.c.sel { stroke: var(--gold); stroke-width: 2.2; }
.map path.c:hover { stroke: var(--navy); stroke-width: 1.2; }

svg text { fill: var(--muted); font: 500 14px var(--font); }
svg .val { fill: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
svg .axis line, svg .axis path { stroke: var(--axis); }
svg .grid line { stroke: var(--grid); stroke-dasharray: 2 4; }
svg .hit { fill: transparent; cursor: pointer; }
svg .hit:hover { fill: var(--wash); }
svg .lbl { fill: var(--ink); font-weight: 600; }
svg .lbl.clickable { cursor: pointer; }
svg .lbl.clickable:hover { fill: var(--blue); text-decoration: underline; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 10px; font-size: 14px; font-weight: 600; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend-ramp { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--muted); margin-top: 8px; }
.legend-ramp .bar { height: 8px; width: 160px; border-radius: 4px; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tabs button { min-height: 32px; border-radius: 999px; border: 1px solid #D5D3CC; background: #fff; color: var(--ink);
  font: 600 14px var(--font); padding: 0 12px; cursor: pointer; }
.tabs button:hover { border-color: var(--navy); }
.tabs button[aria-selected=true] { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------- table ---------- */
.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line2); white-space: nowrap; }
th { color: var(--blue); font-weight: 700; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; cursor: pointer;
  user-select: none; position: sticky; top: 0; background: var(--surface); border-bottom: 2px solid var(--navy); }
th.sorted::after { content: " ↓"; } th.sorted.asc::after { content: " ↑"; }
tbody tr { cursor: pointer; } tbody tr:hover { background: var(--wash); }
td.num { font-variant-numeric: tabular-nums; }
td .native { color: var(--muted); font-size: 14px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.pill i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.status { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 9px; border-radius: 999px;
  background: var(--chip); color: var(--muted); }
.more { margin: 14px auto 0 !important; display: block; }
.foot { color: var(--muted); font-size: 14px; padding: 24px 0 40px; text-align: center; }

/* ---------- tooltip ---------- */
.tip { position: fixed; pointer-events: none; z-index: 50; background: #fff; color: var(--ink); border: 1px solid var(--line);
  border-top: 3px solid var(--navy); border-radius: 6px; padding: 8px 12px; font-size: 15px; max-width: 300px;
  box-shadow: 0 6px 20px rgba(27,42,74,.16); opacity: 0; transition: opacity .08s; }
.tip b { font-weight: 700; } .tip .m { color: var(--muted); }

/* ---------- detail drawer ---------- */
.drawer { position: fixed; top: 0; right: 0; height: 100%; width: min(520px, 100%); background: var(--surface);
  border-left: 1px solid var(--line); box-shadow: -10px 0 30px rgba(27,42,74,.18); z-index: 40;
  transform: translateX(105%); transition: transform .2s ease; overflow-y: auto; padding: 0 0 40px; }
.drawer.open { transform: none; }
.drawer .close { position: absolute; right: 14px; top: 12px; background: transparent; color: #fff; border-color: rgba(255,255,255,.5); min-height: 34px; padding: 0 12px; }
#drawer-body { padding: 0 20px; }
.drawer h3 { margin: 0 -20px; padding: 16px 70px 14px 20px; background: var(--navy); color: #fff; font-size: 21px; font-weight: 700; line-height: 1.2; }
.drawer h3 span { color: var(--gold) !important; }
.drawer .native { color: var(--muted); margin: 12px 0 14px; font-size: 16px; }
.drawer h4 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--blue); margin: 18px 0 6px; }
.drawer dl { display: grid; grid-template-columns: 180px 1fr; gap: 4px 12px; margin: 0; font-size: 15px; }
.drawer dt { color: var(--muted); } .drawer dd { margin: 0; word-break: break-word; font-weight: 600; }
.drawer .ver { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 6px; cursor: pointer; font-size: 15px; }
.drawer .ver.cur { border-color: var(--navy); box-shadow: inset 3px 0 0 var(--gold); }

.lr-legend { flex-direction: column; gap: 6px; }
.lr-legend > div { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.lr-legend b { color: var(--blue); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-right: 4px; }
.lr-legend i { flex: none; }
.scroll-y.tall { max-height: 760px; }
.note { color: var(--muted); font-size: 14px; font-style: italic; margin: 8px 0 0; }
.rows-2 { grid-row: span 2; }
@media (max-width: 900px) { .rows-2 { grid-row: auto; } }
#aff.scroll-y { max-height: 300px; }
@media (max-width: 560px) { h1 { font-size: 20px; padding: 10px 18px; letter-spacing: .1em; } .drawer dl { grid-template-columns: 1fr; } }
@media (max-width: 700px) {
  .top { position: static; }
  .filters select { flex: 1 1 45%; }
  .filters input[type=search] { max-width: none; flex-basis: 100%; }
}
.drawer .logo-box { margin: 14px 0 0; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; display: flex; justify-content: center; }
.drawer .logo-box[hidden] { display: none; }
.drawer .logo-box img { max-height: 96px; max-width: 100%; object-fit: contain; }
/* embedded in WordPress: the iframe grows to fit, so the panel is placed in the page flow, not fixed to the screen */
.embedded body { overflow: hidden; }
.embedded .top { position: static; }
.embedded .drawer { position: absolute; height: auto; max-height: none; border: 1px solid var(--line); border-radius: 6px; overflow: visible; }
/* ideology legend (as on the country pages) */
.lg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.lg { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 6px; }
.lg .t { display: flex; align-items: center; gap: 8px; }
.lg .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.lg h3 { margin: 0; font-size: 17px; font-weight: 700; }
.lg .count { margin-left: auto; padding: 3px 9px; border-radius: 999px; background: var(--navy); color: #fff; font-size: 12px; font-weight: 700; white-space: nowrap; }
.lg p { margin: 0; font-size: 14px; line-height: 1.45; color: #2B2F36; }
#lg-undef:empty { display: none; }
@media (max-width: 560px) { .lg-grid { grid-template-columns: 1fr; } }
/* credits (replaces the WordPress box) */
.credits { margin: 24px 0 0; padding: 22px 20px 20px; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: 6px; text-align: center; }
.credits h2 { margin: 0 0 6px; font-size: 17px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--navy); }
.credits p { margin: 0; color: var(--muted); font-size: 15px; }
.credits .team { list-style: none; margin: 14px 0 16px; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 26px; }
.credits .team li { display: flex; flex-direction: column; align-items: center; }
.credits .team strong { font-size: 17px; font-weight: 700; color: var(--ink); }
.credits .team span { font-size: 13px; font-weight: 600; color: var(--blue); }
.credits .contact { color: var(--ink); font-weight: 600; }
.credits .contact a { color: var(--tagInk); }
.credits .fine { margin-top: 8px; font-size: 13px; }
main.wrap { padding-bottom: 48px; }
#aff .lbl { font-weight: 600; }
.more[hidden] { display: none !important; }
