/* The whole page: your font, and the cream background of your Flourish charts */
body {
  margin: 0;
  font-family: 'Libre Caslon Text', Georgia, serif;
  color: #222222;
  background: #fcfaf5;
}

/* One chart with its title, subtitle and notes */
.chart-block {
  max-width: 760px;
  padding: 20px 16px 12px;
}

.chart-title {
  font-size: 22px;
  font-weight: 400;
  line-height: 1.3;
  margin: 0 0 8px;
}

.chart-subtitle {
  font-size: 16px;
  line-height: 1.4;
  color: #777777;
  margin: 0 0 12px;
}

/* The box the chart is drawn in: its height is set on the page itself */
.chart-box {
  position: relative;
}

/* Notes and sources under the chart */
.chart-note,
.chart-source {
  font-size: 13px;
  line-height: 1.4;
  color: #555555;
  margin: 12px 0 0;
}

.chart-source a {
  color: #555555;
}

/* ---------- Our own hover box (like Flourish's) ---------- */

.tooltip {
  position: absolute;
  pointer-events: none;            /* the box never blocks the mouse */
  max-width: 260px;
  padding: 9px 12px;
  background: #ffffff;
  border-radius: 3px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.15);
  font-size: 14px;                 /* same size as the country names next to the bars */
  line-height: 1.3;
  opacity: 0;                      /* hidden until you hover */
  transition: opacity 0.1s;
  z-index: 10;
}

/* Small grey headings: "Law targets", "Maximum penalty" */
.tooltip .label {
  font-size: 12px;
  color: #777777;
  margin-top: 10px;
}

/* No extra space above the first heading */
.tooltip .label:first-child {
  margin-top: 0;
}

/* NEW: country name at the top of the map's hover box */
.tooltip .title {
  font-weight: 700;
  margin-bottom: 2px;
}

/* ---------- NEW: the map ---------- */

/* The map's height */
.map-box {
  height: 400px;
}

/* Legend above a chart or map: the SAME for all three graphics */
.legend {
  display: flex;
  flex-wrap: wrap;                 /* items side by side, onto a new line when there is no room */
  gap: 6px 22px;
  font-size: 14px;
  margin: 0 0 16px;                /* the same white space between legend and graphic everywhere */
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
}

/* Small grey extra text in the legend ("small countries") */
.legend-extra {
  font-size: 13px;
  color: #777777;
}

/* Colour squares in the legend */
.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

/* The dot in the legend: a dark dot with a white edge, like on the map */
.swatch-dot {
  border-radius: 50%;
  background: #5f5651;
  box-shadow: 0 0 0 1.5px #ffffff, 0 0 0 2.5px #e2dbd5;
}

/* The zoom buttons in your colours */
.maplibregl-ctrl-group {
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}
/* ---------- Unit chart: one square per country ---------- */

/* Group heading above each block of squares */
.unit-heading {
  font-size: 15px;
  font-weight: 700;
  margin: 18px 0 8px;
}

.unit-heading:first-child {
  margin-top: 0;
}

/* The counts after the heading, in grey */
.unit-count {
  font-weight: 400;
  font-size: 13px;
  color: #777777;
  margin-left: 6px;
}

/* The grid: as many squares per row as fit, each at least 96px wide */
.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 3px;
}

/* One square = one country, with its name inside: compact and quiet */
.unit {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 34px;
  padding: 3px 5px;
  border-radius: 2px;
  font-size: 12px;
  line-height: 1.15;
}

.unit-dark {
  background: #5f5651;
  color: #ffffff;
}

.unit-light {
  background: #e2dbd5;
  color: #3a332f;
}

/* Squares with a hover box get a pointer cursor */
.unit-hover {
  cursor: pointer;
}

/* ---------- Chart 2, test version: rows of member-state blocks ---------- */

/* One row per country: name column on the left, blocks on the right */
.country-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid #e6e0d9;
}

.country-row:first-child {
  border-top: none;
}

.country-name {
  font-size: 14px;
  padding-top: 2px;
}

/* The blocks: side by side, onto a new line when there is no room */
.ms-blocks {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
}

/* One block = one member state */
.ms-block {
  background: #5f5651;
  color: #ffffff;
  font-size: 12px;
  line-height: 1;
  padding: 5px 7px;
  border-radius: 2px;
}

/* "9 lists" after the blocks */
.ms-count {
  font-size: 12px;
  color: #777777;
  margin-left: 6px;
}

/* Law and penalty under the blocks */
.country-detail {
  font-size: 13px;
  color: #555555;
  margin-top: 5px;
}

/* On phones: name above the blocks instead of next to them */
@media (max-width: 520px) {
  .country-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

/* ---------- Chart 2, test version c: HTML bars with the penalty next to them ---------- */

/* Column header row is not needed: one row per country */
.bar-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  align-items: center;
  gap: 10px;
  margin: 4px 0;
}

/* Country name, right-aligned against the bar like in the other charts */
.bar-name {
  font-size: 14px;
  text-align: right;
}

/* Bar and penalty text side by side */
.bar-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* The bar itself, with the number inside at its end */
.bar {
  flex: none;
  min-width: 20px;
  height: 20px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 5px;
  background: #5f5651;
  color: #ffffff;
  font-size: 13px;
  cursor: pointer;
}

/* The penalty, next to the bar; wraps onto a second line on narrow screens */
.bar-penalty {
  font-size: 13px;
  line-height: 1.25;
  color: #555555;
}


/* ---------- When a chart sits inside the article (in an iframe) ----------
   The article adds the class "embedded" to the chart page, so the chart
   blends into the article: no padding, no own background, title sizes like Table 1 */
.embedded body {
  background: transparent;
}

.embedded .chart-block {
  max-width: none;
  padding: 0;
}

.embedded .chart-title {
  font-size: 17px;
}

.embedded .chart-subtitle {
  font-size: 15px;
}

/* Chart 3: the same white space as charts 1 and 2 (measured in the article):
   30px from the legend to the first data, 25px from the last data to the note */
#units {
  margin: 30px 0 25px;   /* vertical margins overlap with the legend's 16px, so the gap becomes 30px */
}

/* Chart 3 on phones: 4 squares per row instead of 3, slightly smaller text,
   so the chart is about a quarter shorter (the chart's own width counts, also inside the article) */
@media (max-width: 520px) {
  .unit-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .unit {
    font-size: 11px;
    padding: 3px 2px;
  }
}
