/* style.css — Bivariate choropleth, warm gray editorial theme */

:root {
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --font-display: "DM Serif Display", Georgia, serif;
  --bg: #eae6de;
  --bg-card: #ffffff;
  --text: #2a2a2a;
  --muted: #7a756c;
  --accent: #c24e80;
  --teal: #3a9e8f;
  --border: #cdc8be;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

/* --- Layout: full viewport, no scroll --- */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.5rem 1.5rem 0.4rem;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Header: editorial title --- */
header {
  flex-shrink: 0;
  margin-bottom: 0.3rem;
}

header h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--text);
}

header .subtitle {
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 0.25rem;
  letter-spacing: 0.01em;
}

/* --- Main area: sidebar left + map right --- */
.main-area {
  flex: 1;
  display: flex;
  gap: 1rem;
  min-height: 0;
}

/* --- Sidebar: legend on top, insight below --- */
.sidebar {
  width: 190px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding-top: 0.15rem;
  min-height: 0;
}

/* --- Legend --- */
#legend { padding: 0; flex-shrink: 0; }

.legend-label {
  font-size: 9px;
  font-weight: 600;
  fill: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.legend-corner {
  font-size: 8px;
  font-weight: 400;
  fill: var(--muted);
  letter-spacing: 0.02em;
}

.legend-nodata {
  font-size: 9px;
  font-weight: 600;
  fill: var(--muted);
  letter-spacing: 0.02em;
}

/* --- How to read — interpretive guide --- */
.how-to-read {
  font-size: 0.68rem;
  line-height: 1.5;
  color: var(--muted);
  flex-shrink: 0;
}
.how-title {
  display: block;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
  margin-bottom: 0.2rem;
}
.how-to-read .hl-teal { color: var(--teal); }
.how-to-read .hl-accent { color: var(--accent); }
.how-to-read .hl-muted { color: #8e7e96; }
.how-to-read .hl-teal-dark { color: #1b6e62; font-weight: 600; }
.how-to-read p { margin: 0.1rem 0; }
.how-to-read .how-dimension { margin-top: 0.35rem; color: var(--text); font-size: 0.65rem; }
.how-to-read .how-example { margin-top: 0.3rem; font-style: italic; }
.how-to-read .how-hover { margin-top: 0.15rem; }
.how-to-read strong { color: var(--text); }

/* --- Insight — narrative tension from data --- */
.insight {
  font-size: 0.72rem;
  line-height: 1.55;
  color: #4a463e;
}

.insight .hl-teal { color: var(--teal); font-weight: 600; }
.insight .hl-accent { color: var(--accent); font-weight: 600; }

/* --- Map: fills remaining space --- */
.map-wrapper {
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
}

#map { width: 100%; height: 100%; }

#map svg {
  width: 100%;
  height: 100%;
  display: block;
}

.region { transition: opacity 0.15s; }
.no-data { fill: #ddd8ce; }

/* --- Tooltip --- */
.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 0.78rem;
  line-height: 1.6;
  max-width: 230px;
  z-index: 10;
  border-radius: 3px;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}

.tooltip strong { display: block; font-size: 0.82rem; color: var(--text); }

.tooltip-country {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-bottom: 5px;
}

.tooltip-row { display: flex; justify-content: space-between; gap: 0.8rem; }
.tooltip-label { color: var(--muted); }
.tooltip-value { font-weight: 600; font-variant-numeric: tabular-nums; }

.change-up { color: var(--accent); }
.change-down { color: var(--teal); }

/* --- Annotations — semantic color --- */
.annotation {
  font-size: 0.68rem;
  font-weight: 600;
  pointer-events: none;
}
.annotation-increase { fill: var(--accent); }
.annotation-reduction { fill: var(--teal); }
.annotation-percapita { fill: #5a554c; }

.annotation-why {
  font-size: 0.58rem;
  font-weight: 400;
  font-style: italic;
  fill: var(--muted);
  pointer-events: none;
}

.annotation-line { stroke-width: 0.8; stroke-dasharray: 3 2; }
.annotation-line-increase { stroke: var(--accent); }
.annotation-line-reduction { stroke: var(--teal); }
.annotation-line-percapita { stroke: #8a857c; }

/* --- Footer — sources + meta + credit --- */
.sources {
  flex-shrink: 0;
  padding-top: 0.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.62rem;
  color: var(--muted);
  line-height: 1.6;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.15rem;
}

.sources a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.meta-inline { font-weight: 500; }
.note { font-style: italic; }
.sep { margin: 0 0.05rem; }

.credit {
  margin-left: auto;
  font-style: italic;
  letter-spacing: 0.02em;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .main-area { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; gap: 0.5rem; }
  header h1 { font-size: 1.4rem; }
}
