/* Tile-grid cartogram map — shared by the EU and ASEAN AI Governance Trackers.
 * Colours follow the page's variables where the viewer defines them. */
.map-head { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; justify-content: space-between; margin: 0 0 0.75rem; }
.map-total { font-size: 0.95rem; }
.map-metrics { display: flex; gap: 0.35rem; flex-wrap: wrap; }
/* The component is shared by two trackers whose pages define different
 * variable names (EU: --text/--border/--accent; ASEAN: --ink/--line, no
 * --accent), so each colour falls back through both names. The active
 * metric uses explicit colours so it reads the same on both. */
.metric { border: 1px solid var(--border, var(--line, #c9d4cf)); background: var(--surface, #fff); color: var(--text, var(--ink, #1c2b26)); border-radius: 999px; padding: 0.3rem 0.7rem; font-size: 0.85rem; cursor: pointer; }
.metric.active { background: #1b5e4f; border-color: #1b5e4f; color: #fff; }
html[data-theme="dark"] .metric.active { background: #7cc4a8; border-color: #7cc4a8; color: #14201c; }
.map-regional { margin: 0 0 0.6rem; }
.map-regional .tile { max-width: 220px; }
.map-grid { display: grid; gap: 0.45rem; }
.tile { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.05rem; min-height: 64px; padding: 0.4rem 0.2rem; border: 1px solid var(--border, var(--line, #c9d4cf)); border-radius: 8px; background: var(--surface, #fff); color: var(--text, var(--ink, #1c2b26)); cursor: pointer; font: inherit; text-align: center; }
.tile:hover, .tile:focus-visible { outline: 2px solid var(--accent, #1b5e4f); outline-offset: 1px; }
.tile.selected { outline: 3px solid var(--accent, #1b5e4f); outline-offset: 1px; }
html[data-theme="dark"] .tile:hover, html[data-theme="dark"] .tile:focus-visible, html[data-theme="dark"] .tile.selected { outline-color: #7cc4a8; }
.tile-code { font-weight: 700; font-size: 0.95rem; line-height: 1.1; }
.tile-name { font-size: 0.68rem; line-height: 1.15; opacity: 0.85; }
.tile-value { font-weight: 700; font-size: 0.85rem; line-height: 1.1; }
.tile.regional .tile-name { font-size: 0.75rem; }
/* Colour bins: 0 = no rows (grey), 1-4 = quartiles of the busiest place.
 * Bins 1-2 have light backgrounds, so they need an explicit dark text colour:
 * in dark mode the page text is near-white, which is unreadable on them. */
.tile.bin-0, .swatch.bin-0 { background: #eceff0; color: #5a6b65; }
.tile.bin-1, .swatch.bin-1 { background: #d6e9e1; }
.tile.bin-2, .swatch.bin-2 { background: #a8d2bf; }
.tile.bin-1, .tile.bin-2 { color: #1c2b26; }
.tile.bin-3, .swatch.bin-3 { background: #5fae8d; color: #1c2b26; }
.tile.bin-4, .swatch.bin-4 { background: #1b5e4f; color: #fff; }
.tile.bin-3 .tile-name, .tile.bin-4 .tile-name { opacity: 0.9; }
/* Tooltip: shown on hover / keyboard focus / tap (tap also selects). */
.tile-tip { display: none; position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); z-index: 20; width: max-content; max-width: 240px; background: #1c2b26; color: #fff; font-size: 0.8rem; font-weight: 400; line-height: 1.4; text-align: left; padding: 0.5rem 0.65rem; border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,0.25); pointer-events: none; }
.tile:hover .tile-tip, .tile:focus-visible .tile-tip, .tile.selected .tile-tip { display: block; }
/* Edge tiles: align the tooltip to the tile's edge instead of centring it,
 * so it never hangs off the side of the screen on a phone. */
.tile.tip-left .tile-tip { left: 0; transform: none; }
.tile.tip-right .tile-tip { left: auto; right: 0; transform: none; }
/* Top-row and regional tiles: show the tooltip below the tile, so it never
 * hangs off the top of the viewport when the map is at the top of the
 * screen. */
.tile.tip-below .tile-tip { bottom: auto; top: calc(100% + 6px); }
.map-legend { display: flex; flex-wrap: wrap; gap: 0.4rem 0.9rem; align-items: center; margin: 0.75rem 0 0.25rem; font-size: 0.85rem; }
.legend-title { font-weight: 600; }
.legend-item { display: inline-flex; align-items: center; gap: 0.35rem; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border, var(--line, #c9d4cf)); }
.map-note { font-size: 0.85rem; opacity: 0.85; margin: 0.5rem 0 0; }
@media (max-width: 640px) {
  .tile { min-height: 64px; padding: 0.35rem 0.05rem; }
  .tile-code { font-size: 0.85rem; }
  /* Country names stay visible on mobile: smaller type that wraps, never hidden.
   * overflow-wrap:anywhere (not break-word) so a long name's minimum width is
   * one character — otherwise the grid track grows past its container. */
  .tile-name { display: block; font-size: 0.55rem; line-height: 1.15; overflow-wrap: anywhere; }
  .tile-value { font-size: 0.8rem; }
  .metric { padding: 0.45rem 0.8rem; min-height: 40px; }
  .map-grid { gap: 0.35rem; }
  .tile-tip { max-width: 70vw; }
}

/* Empty tiles: full-strength name text so it meets 4.5:1 contrast */
.tile.bin-0 .tile-name { opacity: 1; }

/* ---------- chart builder (chart-builder.js), shared by both trackers ----------
 * Uses each tracker's own colours: ASEAN names them --line/--ink, the EU --border/--text. */
.cb{display:grid;gap:.9rem}
.cb [hidden]{display:none!important} /* the layout rules below must not override hiding */
.cb-controls{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:.7rem 1rem;align-items:start}
.cb-f{display:grid;gap:.3rem;font-size:.88rem;font-weight:600;margin:0;padding:0;border:0;min-width:0}
.cb-f legend{font-weight:600;padding:0;margin-bottom:.3rem}
.cb-wide{grid-column:1/-1}
.cb-f select,.cb-f input[type=text]{font:inherit;font-weight:400;padding:.4rem .55rem;border:1px solid var(--line,var(--border));border-radius:6px;background:var(--surface);color:var(--ink,var(--text));width:100%;min-width:0}
.cb-r,.cb-chk{display:inline-flex;gap:.35rem;align-items:center;font-weight:400;margin-right:.8rem;cursor:pointer}
.cb-places{display:flex;flex-wrap:wrap;gap:.2rem .4rem}
.cb-figure{background:#fff;border:1px solid var(--line,var(--border));border-radius:8px;overflow:hidden}
.cb-figure svg{display:block;width:100%;height:auto}
.cb-actions{display:flex;flex-wrap:wrap;gap:.5rem;align-items:center}
.cb-btn{font:inherit;font-size:.88rem;font-weight:600;border:1px solid var(--line,var(--border));background:var(--surface);color:var(--ink,var(--text));border-radius:6px;padding:.4rem .8rem;cursor:pointer}
.cb-btn:hover{border-color:currentColor}
.cb-msg{font-size:.85rem;color:var(--muted)}
.cb-empty{color:var(--muted);margin:.4rem 0}
.cb-tablewrap{overflow-x:auto}
.cb-tbl{border-collapse:collapse;width:100%;font-size:.88rem;margin-top:.5rem}
.cb-tbl th,.cb-tbl td{text-align:left;padding:.4rem .5rem;border-bottom:1px solid var(--line,var(--border));vertical-align:top}
.cb-r input,.cb-chk input{accent-color:#0d5e57}
