/* Four neighbourhoods (index.html): a figure of four small maps, white and
   flat as the orain style of the map. */

:root {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #5c5c5c;
  --rule: #d4d4d4;
  --hover: #f2f2f2;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.4 Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}

[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

#figure { max-width: 760px; margin: 0 auto; padding: 24px 16px 32px; }
/* In an article's iframe (?embed=1): the column's width, no outer margins. */
:root[data-embed] #figure { max-width: none; padding: 0 0 4px; }

/* A row (winner, then turnout): its legend over its two squares. */
.row { margin-top: 20px; }
.row:first-child { margin-top: 0; }
.row + .row { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--rule); }

/* The row's head: its title on the left, its legend on the right, their
   feet on one line; on a narrow screen the legend goes under. */
.row-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px 24px;
}
.row-title { margin: 0 0 14px; font-size: 18px; font-weight: 900; line-height: 1.2; }

/* Legend: the colour bar of the row's shares. */
.bar { width: 260px; }
.legend-bar { display: flex; height: 10px; overflow: hidden; }
.legend-ticks { position: relative; height: 18px; }
.legend-ticks span {
  position: absolute;
  top: 2px;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* The two squares of a row, side by side. */
.panels {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px 16px;
  margin-top: 12px;
}
/* The map at the foot of each square, so the two of a row line up however
   many lines their texts take. */
.panel { display: flex; flex-direction: column; }
.panel h2 { margin: 0; font-size: 16px; font-weight: 400; line-height: 1.25; }
.panel h2 strong { font-weight: 900; }
/* The vote of a fifth: one bar, a segment per party, as the map's card. */
.vote-bar {
  display: flex;
  height: 10px;
  margin: 6px 0 2px;
  overflow: hidden;
  background: var(--hover);
}
.vote-bar span { flex: none; height: 100%; }
.panel-line { margin: 1px 0 0; font-size: 14px; }
.panel-line:empty { display: none; }
.panel-line.muted { color: var(--muted); }
.panel-map { flex: none; height: 340px; margin-top: auto; background: #eee; }
.panel > p:last-of-type { padding-bottom: 8px; }
/* The plain arrow over the maps, not MapLibre's grabbing hand. */
.panel-map .maplibregl-canvas-container.maplibregl-interactive,
.panel-map .maplibregl-canvas-container.maplibregl-interactive:active { cursor: default; }
/* The zoom buttons of each square: one white box with + and −. */
.panel-map .maplibregl-ctrl-group {
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
.maplibregl-ctrl-scale {
  border-color: var(--fg);
  background: rgba(255, 255, 255, 0.85);
  font: 12px Roboto, sans-serif;
  color: var(--fg);
}

#status { margin: 16px 0 0; color: var(--muted); }
#status:empty { display: none; }
#source { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: right; }

/* The section under the pointer. */
/* Small, as El País's: a line with the place, then a short table. */
#tip {
  position: fixed;
  z-index: 10;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.3;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
  pointer-events: none;
}
#tip p { margin: 0; }
#tip .tip-head { margin-bottom: 3px; font-size: 13px; white-space: nowrap; }
#tip .tip-muted { color: var(--muted); }
#tip table { border-collapse: collapse; }
#tip td { padding: 1px 0; }
#tip .tip-label { padding-right: 14px; color: var(--muted); }
#tip .num { text-align: right; white-space: nowrap; }
#tip .tip-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-radius: 2px;
}

@media (max-width: 640px) {
  .panels { grid-template-columns: 1fr; }
  .panel-map { height: 260px; }
}

/* In an article's iframe (?embed=1): the figure is as tall as the iframe,
   whatever height the article gives it, with no scroll of its own. The two
   rows share it and the maps take what their texts leave; two squares a row
   on a phone too, or four maps one under another would get too small. */
:root[data-embed],
:root[data-embed] body { height: 100%; }
:root[data-embed] #figure { display: flex; flex-direction: column; height: 100%; }
:root[data-embed] #rows,
:root[data-embed] .row { display: flex; flex-direction: column; flex: 1; min-height: 0; }
:root[data-embed] .row + .row { margin-top: 14px; padding-top: 12px; }
:root[data-embed] .row-title { margin-bottom: 8px; }
:root[data-embed] .panels {
  flex: 1;
  min-height: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
  margin-top: 8px;
}
:root[data-embed] .panel { min-height: 0; }
:root[data-embed] .panel-map { flex: 1 1 0; height: auto; min-height: 90px; }
:root[data-embed] #status,
:root[data-embed] #source { flex: none; margin-top: 8px; }
@media (max-width: 640px) {
  :root[data-embed] .row-title { font-size: 16px; }
  :root[data-embed] .panel h2 { font-size: 13px; }
  :root[data-embed] .panel-line { font-size: 12px; }
}
