/* ── Fonts ──────────────────────────────────────────────────────────────── */
@font-face {
  font-family: 'Inter';
  src: url('/fonts/Inter-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/fonts/Inter-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/fonts/Inter-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  --bg: #F5F6F8;
  --panel: #FFFFFF;
  --panel-border: #DDE1E7;
  --text: #1A1D23;
  --text-muted: #6B7280;

  --c-both: #22A55E;
  --c-julian: #EAD020;
  --c-brian: #2D74D8;
  --c-none: #D4D8DF;
  --c-investigation: #7C3AED;

  --c-both-dim: rgba(34,165,94,0.12);
  --c-julian-dim: rgba(234,208,32,0.12);
  --c-brian-dim: rgba(45,116,216,0.12);
  --c-investigation-dim: rgba(124,58,237,0.12);

  --font-ui: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Map hero ───────────────────────────────────────────────────────────── */
#map-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 70%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: grab;
}

#map-container:active {
  cursor: grabbing;
}

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

#map-loading {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 13px;
}

/* Country paths */
#world-map path {
  stroke: #FFFFFF;
  stroke-width: 0.4;
  cursor: pointer;
  transition: filter 0.12s;
}

#world-map path[data-status="both"]          { fill: var(--c-both); }
#world-map path[data-status="julian"]        { fill: var(--c-julian); }
#world-map path[data-status="brian"]         { fill: var(--c-brian); }
#world-map path[data-status="none"]          { fill: var(--c-none); }
#world-map path[data-status="investigation"] { fill: var(--c-investigation); }

#world-map path:hover {
  filter: brightness(0.88);
}

/* ── Legend ─────────────────────────────────────────────────────────────── */
#legend {
  position: fixed;
  bottom: 24px;
  left: 30%;
  transform: translateX(-50%);
  display: flex;
  gap: 20px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 10px 18px;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.legend-item .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-item.both .dot          { background: var(--c-both); }
.legend-item.julian .dot        { background: var(--c-julian); }
.legend-item.brian .dot         { background: var(--c-brian); }
.legend-item.none .dot          { background: var(--c-none); border: 1px solid #b0b6bf; }
.legend-item.investigation .dot { background: var(--c-investigation); }

/* ── Corner stat readout ────────────────────────────────────────────────── */
#stat-readout {
  position: fixed;
  top: 20px;
  left: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(6px);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 8px 14px;
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
  z-index: 20;
  max-width: 280px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  white-space: pre;
}

#stat-readout.visible { opacity: 1; }

/* ── Global stats bar ───────────────────────────────────────────────────── */
#stats-bar {
  position: fixed;
  top: 16px;
  left: 30%;
  transform: translateX(-50%);
  display: flex;
  gap: 24px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px 20px;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.stat {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.stat.highlight {
  color: var(--text);
}

/* ── Investigation count badge ──────────────────────────────────────────── */
#inv-count-badge {
  background: var(--c-investigation);
  color: #FFFFFF;
  border-radius: 10px;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

/* ── Investigations panel ───────────────────────────────────────────────── */
#investigations-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 30%;
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--panel-border);
  z-index: 40;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}

.panel-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--c-investigation);
}


.panel-subtitle {
  padding: 8px 20px 16px;
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

#investigations-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 0 12px;
}

#investigations-list li {
  padding: 12px 8px;
  border-bottom: 1px solid var(--panel-border);
}

#investigations-list li:last-child { border-bottom: none; }

.inv-name {
  font-weight: 500;
  color: var(--text);
  font-size: 13px;
}

.inv-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.inv-badges {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.badge {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 500;
}

.badge.planned {
  background: var(--c-investigation-dim);
  color: var(--c-investigation);
  border: 1px solid rgba(124,58,237,0.25);
}

.inv-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.inv-actions button {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  background: none;
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  font-family: var(--font-ui);
}

.inv-actions button:hover { color: var(--text); border-color: #9CA3AF; }

.inv-actions .delete-btn:hover {
  color: #DC2626;
  border-color: #DC2626;
}

.panel-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--panel-border);
  flex-shrink: 0;
}

#add-investigation-btn {
  width: 100%;
  background: var(--c-investigation-dim);
  border: 1px solid rgba(124,58,237,0.25);
  color: var(--c-investigation);
  border-radius: 6px;
  padding: 9px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
}

#add-investigation-btn:hover {
  background: rgba(124,58,237,0.2);
}

/* ── Add form overlay ───────────────────────────────────────────────────── */
#add-form-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

#add-form-overlay[hidden] {
  display: none;
}

#add-form {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 24px;
  width: 360px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

#add-form h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
}

#add-form label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

#add-form label.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  cursor: pointer;
}

#add-form input[type="text"],
#add-form textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 5px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
}

#add-form textarea {
  resize: vertical;
  min-height: 72px;
}

#add-form input[type="text"]:focus,
#add-form textarea:focus {
  border-color: var(--c-investigation);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.form-actions button {
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 5px;
  cursor: pointer;
  border: 1px solid var(--panel-border);
  background: none;
  color: var(--text-muted);
}

.form-actions button.primary {
  background: var(--c-investigation);
  border-color: var(--c-investigation);
  color: #FFFFFF;
  font-weight: 600;
}

.form-actions button.primary:hover { filter: brightness(0.92); }
.form-actions button:not(.primary):hover { color: var(--text); }


/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--panel-border); border-radius: 3px; }
