/* Colours: light-dark(<light>, <dark>). The scheme follows the OS unless the theme
   switcher sets data-theme="light" | "dark" on <html> (see js/theme-init.js). */
:root {
  color-scheme: light dark;

  --bg: light-dark(#f6f3ee, #11151d);
  --surface: light-dark(#ffffff, #1a202b);
  --surface-2: light-dark(#f0ece5, #222a37);
  --text: light-dark(#1d2433, #e8ebf1);
  --muted: light-dark(#667085, #97a1b3);
  --border: light-dark(#e3ded5, #2b3443);
  --sea: light-dark(#e4ecf1, #151b25);

  --province: light-dark(#c9d6e3, #34435a);
  --province-alt: light-dark(#bccbdb, #2f3d52);
  --province-hover: light-dark(#9fb5cc, #4a5f7e);
  --province-dim: light-dark(#dde5ed, #252f3f);
  --province-stroke: var(--bg);
  --accent: light-dark(#e5621b, #f07a36);          /* Dutch orange */
  --accent-soft: light-dark(#fbe3d4, #3a2518);
  --accent-text: light-dark(#b8480c, #f7a26f);
  --city: var(--text);

  --shadow-1: light-dark(rgba(20, 30, 50, .05), rgba(0, 0, 0, .3));
  --shadow-2: light-dark(rgba(20, 30, 50, .08), rgba(0, 0, 0, .35));
  --shadow: 0 1px 2px var(--shadow-1), 0 12px 32px var(--shadow-2);

  --radius: 18px;
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-serif: 'Fraunces', Georgia, serif;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px clamp(16px, 4vw, 40px);
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-flag {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  background: linear-gradient(#ae1c28 0 33.3%, #fff 33.3% 66.6%, #21468b 66.6%);
  box-shadow: 0 0 0 1px var(--border);
}

h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(20px, 2.4vw, 26px);
  line-height: 1.15;
  letter-spacing: -.01em;
}

.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.controls { display: flex; align-items: center; gap: 8px; }

/* Pill-shaped segmented control: language and theme switchers. */
.segmented {
  display: flex;
  padding: 4px;
  gap: 2px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.segmented button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  border: 0;
  padding: 0 12px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: 600 12px/1 var(--font-sans);
  letter-spacing: .04em;
  cursor: pointer;
  transition: background .2s, color .2s;
}

.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.segmented button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.theme-switch button { width: 30px; padding: 0; }
.theme-switch svg { width: 15px; height: 15px; }

/* ---------- Layout ---------- */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 24px;
  padding: 0 clamp(16px, 4vw, 40px) 24px;
  min-height: 0;
}

.map-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  border-radius: var(--radius);
  background: radial-gradient(ellipse at 40% 35%, var(--surface) 0%, var(--sea) 75%);
  border: 1px solid var(--border);
  overflow: hidden;
}

.map {
  width: 100%;
  height: calc(100vh - 170px);
  min-height: 420px;
  max-height: 900px;
  padding: 24px;
  overflow: visible;
}

.map-hint {
  position: absolute;
  left: 20px;
  bottom: 14px;
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  pointer-events: none;
  transition: opacity .3s;
}

.has-selection .map-hint { opacity: 0; }

/* ---------- Map shapes ---------- */

.province {
  fill: var(--province);
  stroke: var(--province-stroke);
  stroke-width: 1.6;
  stroke-linejoin: round;
  cursor: pointer;
  transition: fill .25s ease, opacity .25s ease;
  outline: none;
}

.province:nth-child(even) { fill: var(--province-alt); }
.province:hover, .province.is-hover { fill: var(--province-hover); }
.province:focus-visible { fill: var(--province-hover); stroke: var(--text); stroke-width: 2; }

.has-selection .province { fill: var(--province-dim); }
.has-selection .province:hover { fill: var(--province-hover); }
.province.is-selected,
.has-selection .province.is-selected { fill: var(--accent); }

.cities { pointer-events: none; }
.city-dot { fill: var(--city); stroke: var(--surface); stroke-width: 1.5; transition: fill .25s; }
.city-dot.is-selected { fill: #fff; stroke: var(--city); stroke-width: 2; }
.city-capital { fill: none; stroke: var(--city); stroke-width: 1.5; }

/* ---------- Tooltip ---------- */

.tooltip {
  position: absolute;
  z-index: 5;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 14px));
}

.tooltip small { opacity: .7; font-weight: 400; margin-left: 6px; }

/* ---------- Side panel ---------- */

.panel {
  min-height: 0;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: auto;
  max-height: calc(100vh - 124px);
}

.panel-inner { padding: 28px; animation: panel-in .35s ease both; }

@keyframes panel-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .panel-inner { animation: none; }
  .province, .city-dot { transition: none; }
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: -6px 0 18px -8px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: 500 13px var(--font-sans);
  cursor: pointer;
}

.back:hover { background: var(--surface-2); color: var(--text); }

.panel-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }

.flag {
  width: 72px;
  height: 48px;
  flex: none;
  object-fit: cover;
  border-radius: 6px;
  box-shadow: 0 0 0 1px var(--border), 0 4px 12px rgba(20, 30, 50, .12);
  background: var(--surface-2);
}

.flag-nl { background: linear-gradient(#ae1c28 0 33.3%, #fff 33.3% 66.6%, #21468b 66.6%); }

.panel h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: -.015em;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.description { margin: 0 0 16px; color: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 22px; padding: 0; list-style: none; }

.chips li {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12.5px;
  font-weight: 500;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 0 0 20px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--border);
  border: 1px solid var(--border);
}

.stat { padding: 14px 16px; background: var(--surface); }
.stat.wide { grid-column: 1 / -1; }
.stat dt { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.stat dd { margin: 0; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat dd.big { font-family: var(--font-serif); font-size: 26px; font-weight: 600; }
.stat .note { display: block; margin-top: 2px; color: var(--muted); font: 400 12.5px/1.45 var(--font-sans); }

.bar {
  height: 6px;
  margin-top: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transform-origin: left;
  animation: bar-in .6s .1s ease both;
}

@keyframes bar-in { from { transform: scaleX(0); } }

.wiki-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-text);
  font-weight: 500;
  text-decoration: none;
}

.wiki-link:hover { text-decoration: underline; }

.province-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 4px 0 20px;
  padding: 0;
  list-style: none;
}

.province-list button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: 500 13.5px var(--font-sans);
  text-align: left;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}

.province-list button:hover { border-color: var(--accent); background: var(--accent-soft); }
.province-list img { width: 24px; height: 16px; object-fit: cover; border-radius: 3px; box-shadow: 0 0 0 1px var(--border); }

.section-title { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }

/* ---------- Footer ---------- */

.footer { padding: 0 clamp(16px, 4vw, 40px) 20px; color: var(--muted); font-size: 12px; }
.footer p { margin: 0; }

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .map { height: 62vh; min-height: 360px; padding: 16px; }
  .panel { max-height: none; }
}

@media (max-width: 520px) {
  .topbar { flex-wrap: wrap; padding-top: 16px; }
  .subtitle { display: none; }
  .panel-inner { padding: 22px 18px; }
  .panel h2 { font-size: 26px; }
  .map { height: 58vh; }
  .map-hint { left: 14px; bottom: 10px; }
}
