/* ─────────────────────────────────────────────────────────────
   Games & Play Research Map — Global Styles
   Aesthetic: Dark cartographic atlas meets editorial precision
   Fonts: Syne (display) + DM Sans (body)
───────────────────────────────────────────────────────────── */

:root {
  --bg:           #0d0f14;
  --surface:      #13161e;
  --surface-2:    #1a1e2a;
  --border:       rgba(255,255,255,0.07);
  --border-hover: rgba(255,255,255,0.15);

  --text:         #e8eaf0;
  --text-muted:   #6b7280;
  --text-dim:     #9ca3af;

  --accent:       #c8f060;       /* electric lime — primary accent */
  --accent-dim:   rgba(200,240,96,0.12);
  --accent-glow:  rgba(200,240,96,0.25);

  --teal:         #2dd4bf;       /* secondary — contributions */
  --teal-dim:     rgba(45,212,191,0.12);

  --cluster-sm:   #c8f060;
  --cluster-md:   #f59e0b;
  --cluster-lg:   #ef4444;
  --marker:       #c8f060;
  --contrib:      #2dd4bf;

  --sidebar-w:    360px;
  --header-h:     56px;
  --radius:       10px;
  --radius-sm:    6px;

  --font-display: 'Syne', sans-serif;
  --font-body:    'DM Sans', sans-serif;

  --shadow:       0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:    0 8px 48px rgba(0,0,0,0.6);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ─── Header ─────────────────────────────────────────────────── */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: rgba(13,15,20,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-icon {
  font-size: 22px;
  color: var(--accent);
  line-height: 1;
}

.logo-text {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 1.1;
}

.logo-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.logo-sub {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.2s, background 0.2s;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
  background: var(--surface-2);
}

.nav-admin {
  border: 1px solid var(--border);
  margin-left: 8px;
}

/* ─── Layout ─────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 900;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.map-container {
  position: fixed;
  top: var(--header-h);
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.map-attribution {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 5;
  margin: 0;
  font-size: 10px;
  line-height: 1.4;
  color: var(--text-muted);
  text-shadow: 0 1px 2px rgba(0,0,0,0.75);
  pointer-events: auto;
}

.map-attribution a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-right: 10px;
}

.map-attribution a:hover {
  color: var(--text-dim);
}

/* ─── Stats Row ──────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 6px;
  border-right: 1px solid var(--border);
  gap: 2px;
}

.stat-item:last-child { border-right: none; }

.stat-num {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
  line-height: 1;
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ─── Filter Section ─────────────────────────────────────────── */
.filter-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.filter-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.reset-btn {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s;
}

.reset-btn:hover { background: var(--accent-dim); }

/* Search */
.search-wrap { position: relative; }

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px 9px 34px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent); }

.filter-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.filter-input::placeholder { color: var(--text-muted); }
.filter-input:focus { border-color: var(--accent); }

.filter-row-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.search-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  z-index: 100;
  display: none;
  box-shadow: var(--shadow);
}

.search-suggestions.visible { display: block; }

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}

.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background: var(--surface); }

.suggestion-type {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 3px;
  flex-shrink: 0;
}

.suggestion-name { font-size: 13px; color: var(--text); }
.suggestion-meta { font-size: 11px; color: var(--text-muted); margin-left: auto; }

/* Filters */
.filter-group { display: flex; flex-direction: column; gap: 6px; }

.filter-label {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.filter-value {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

.filter-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 30px;
}

.filter-select:focus { border-color: var(--accent); }

.range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* Layer toggles */
.toggle-row { display: flex; gap: 8px; }

.toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text-dim);
  transition: all 0.2s;
}

.toggle-btn.active {
  border-color: currentColor;
  color: var(--text);
}

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

.dot-institution { background: var(--accent); }
.dot-contribution { background: var(--teal); }

/* ─── Results List ───────────────────────────────────────────── */
.results-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.results-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.results-count {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.results-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-2) transparent;
}

.results-list::-webkit-scrollbar { width: 4px; }
.results-list::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 2px; }

.search-unlinked-banner {
  margin: 0 12px 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-muted);
}

.search-unlinked-banner.hidden { display: none; }

.search-unlinked-text { margin: 0 0 6px; }

.search-unlinked-titles {
  margin: 0;
  color: var(--text);
  font-weight: 500;
}

.result-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.result-item:hover { background: var(--surface-2); }

.result-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 5px;
  flex-shrink: 0;
}

.result-body { flex: 1; min-width: 0; }

.result-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.result-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.result-match-paper {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.result-pubs {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  gap: 8px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state-icon { font-size: 32px; opacity: 0.4; }
.empty-state-text { font-size: 13px; }

/* ─── Map Controls ───────────────────────────────────────────── */
.map-controls {
  position: absolute;
  bottom: 30px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}

.map-btn {
  width: 36px;
  height: 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  backdrop-filter: blur(8px);
}

.map-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-hover);
  color: var(--accent);
}

/* ─── Loading ────────────────────────────────────────────────── */
.map-loading {
  position: absolute;
  inset: 0;
  background: rgba(13,15,20,0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  pointer-events: none;
  transition: opacity 0.4s;
  backdrop-filter: blur(4px);
}

.map-loading.hidden { opacity: 0; pointer-events: none; }

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--surface-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Detail Panel ───────────────────────────────────────────── */
.detail-panel {
  position: fixed;
  top: var(--header-h);
  right: 0;
  bottom: 0;
  width: 380px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 800;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  scrollbar-width: thin;
}

.detail-panel.open { transform: translateX(0); }

.detail-close {
  position: sticky;
  top: 0;
  float: right;
  margin: 12px 12px 0 0;
  width: 28px;
  height: 28px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: all 0.15s;
}

.detail-close:hover { color: var(--text); border-color: var(--border-hover); }

.detail-content { padding: 16px 20px 32px; }

.detail-header {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.detail-country {
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 10px;
}

.detail-pub-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-dim);
  border: 1px solid rgba(200,240,96,0.2);
  border-radius: 20px;
  padding: 4px 12px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.detail-section {
  margin-bottom: 20px;
}

.detail-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-weight: 600;
}

.researcher-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-dim);
  margin: 0 4px 4px 0;
}

.institution-researchers-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: min(70vh, 520px);
  overflow-y: auto;
  padding-right: 4px;
}

.institution-researcher-block {
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.institution-researcher-block:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.researcher-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}

a.researcher-orcid-name {
  color: var(--teal);
  font-weight: 600;
  text-decoration: none;
}

a.researcher-orcid-name:hover {
  text-decoration: underline;
}

.researcher-name-plain {
  font-weight: 600;
  color: var(--text);
}

a.orcid-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--teal);
  border: 1px solid rgba(45, 212, 191, 0.35);
  border-radius: 4px;
  padding: 2px 6px;
  text-decoration: none;
}

a.orcid-badge:hover {
  background: rgba(45, 212, 191, 0.12);
}

.researcher-pub-total {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

.institution-paper-list {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.45;
}

.institution-paper-list .paper-link,
.institution-paper-list .paper-link-text {
  color: var(--text-dim);
}

.institution-paper-list .paper-link:hover {
  color: var(--teal);
}

.institution-paper-list .paper-year {
  color: var(--text-muted);
  font-size: 11px;
}

.institution-paper-list .paper-list-empty {
  list-style: none;
  margin-left: -18px;
  color: var(--text-muted);
  font-style: italic;
}

.contribution-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

.contrib-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.contrib-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.contrib-avatar-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--teal-dim);
  border: 1px solid rgba(45,212,191,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--teal);
  flex-shrink: 0;
}

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

.contrib-statement {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tag-list { display: flex; flex-wrap: wrap; gap: 4px; }

.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.detail-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  margin-top: 8px;
}

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

/* ─── Mobile sidebar toggle ──────────────────────────────────── */
.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 950;
  width: 44px;
  height: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: var(--text);
  box-shadow: var(--shadow);
}

.sidebar-toggle svg { width: 20px; height: 20px; }

/* ─── MapLibre overrides ─────────────────────────────────────── */
.maplibregl-popup-content {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  padding: 0 !important;
  color: var(--text) !important;
  box-shadow: var(--shadow) !important;
  font-family: var(--font-body) !important;
  max-width: 260px !important;
}

.maplibregl-popup-tip {
  border-top-color: var(--surface) !important;
  border-bottom-color: var(--surface) !important;
}

.maplibregl-popup-close-button {
  color: var(--text-muted) !important;
  font-size: 18px !important;
  padding: 6px 10px !important;
  right: 0 !important;
  top: 0 !important;
}

.maplibregl-ctrl-attrib { display: none; }

.map-popup-inner { padding: 14px 16px; }
.map-popup-country { font-size: 10px; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 3px; }
.map-popup-name { font-family: var(--font-display); font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 8px; letter-spacing: -0.01em; }
.map-popup-pubs { font-size: 12px; color: var(--accent); font-weight: 500; margin-bottom: 8px; }
.map-popup-btn { display: block; width: 100%; padding: 8px; background: var(--accent-dim); border: 1px solid rgba(200,240,96,0.2); border-radius: var(--radius-sm); color: var(--accent); font-family: var(--font-display); font-size: 12px; font-weight: 600; text-align: center; cursor: pointer; transition: background 0.15s; }
.map-popup-btn:hover { background: rgba(200,240,96,0.2); }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: min(var(--sidebar-w), 100vw);
  }

  .sidebar.open { transform: translateX(0); }

  .map-container { left: 0; }

  .sidebar-toggle { display: flex; }

  .detail-panel {
    width: 100%;
    top: var(--header-h);
  }
}
